Skip to content

Commit aa9e82e

Browse files
committed
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 634224a commit aa9e82e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mypy/typeshed/stdlib/builtins.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1637,11 +1637,11 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
16371637
# Instead, we special-case the most common examples of this: bool and literal integers.
16381638
if sys.version_info >= (3, 8):
16391639
@overload
1640-
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[misc]
1640+
def sum(__iterable: Iterable[bool], start: int = 0) -> int: ... # type: ignore[misc]
16411641

16421642
else:
16431643
@overload
1644-
def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = 0) -> int: ... # type: ignore[misc]
1644+
def sum(__iterable: Iterable[bool], __start: int = 0) -> int: ... # type: ignore[misc]
16451645

16461646
@overload
16471647
def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ...

0 commit comments

Comments
 (0)