Skip to content

Commit de96159

Browse files
hauntsaninjamypybot
authored andcommitted
Revert sum literal integer change (#13961)
This is allegedly causing large performance problems, see 13821 typeshed/8231 had zero hits on mypy_primer, so it's not the worst thing to undo. Patching this in typeshed also feels weird, since there's a more general soundness issue. If a typevar has a bound or constraint, we might not want to solve it to a Literal. If we can confirm the performance regression or fix the unsoundness within mypy, I might pursue upstreaming this in typeshed. (Reminder: add this to the sync_typeshed script once merged)
1 parent 78b78b9 commit de96159

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
21082108
# without creating many false-positive errors (see #7578).
21092109
# Instead, we special-case the most common examples of this: bool and literal integers.
21102110
@overload
2111-
def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ...
2111+
def sum(iterable: Iterable[bool], /, start: int = 0) -> int: ...
21122112
@overload
21132113
def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ...
21142114
@overload

0 commit comments

Comments
 (0)