-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
stubs: false negativeType checkers do not report an error, but shouldType checkers do not report an error, but should
Description
Currently the stub for the sum built-in allows any iterable as an argument
Lines 1480 to 1489 in ae6ff79
| @overload | |
| def sum(__iterable: Iterable[_T]) -> _T | Literal[0]: ... | |
| if sys.version_info >= (3, 8): | |
| @overload | |
| def sum(__iterable: Iterable[_T], start: _S) -> _T | _S: ... | |
| else: | |
| @overload | |
| def sum(__iterable: Iterable[_T], __start: _S) -> _T | _S: ... |
This means mypy has no issue with:
sum("hello")Which results in this error at runtime:
TypeError: unsupported operand type(s) for +: 'int' and 'str'
context: I was introducing someone to mypy and used the example above as something that mypy should flag, but turns out it wasn't being flagged so logging here.
Metadata
Metadata
Assignees
Labels
stubs: false negativeType checkers do not report an error, but shouldType checkers do not report an error, but should