Skip to content

Commit d132999

Browse files
hauntsaninjaJelleZijlstra
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 d25e4a9 commit d132999

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypy/typeshed/stdlib/builtins.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
15901590
# without creating many false-positive errors (see #7578).
15911591
# Instead, we special-case the most common examples of this: bool and literal integers.
15921592
@overload
1593-
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[overload-overlap]
1593+
def sum(__iterable: Iterable[bool], start: int = 0) -> int: ... # type: ignore[overload-overlap]
15941594
@overload
15951595
def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ...
15961596
@overload

0 commit comments

Comments
 (0)