Repository navigation
builtins stubtest exceptions - #5219
Conversation
hatal175
commented
Apr 15, 2021
- I've just left 'class function' - anyone can explain what it is and why it is there?
|
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/operations/install/wheel.py:620: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:646: error: Incompatible types in assignment (expression has type "filterfalse[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:650: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
bidict (https://github.com/jab/bidict.git)
+ bidict/_orderedbidict.py:63: error: "object" not callable
|
|
There's #2999 for builtins.function |
|
The |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/operations/install/wheel.py:620: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:646: error: Incompatible types in assignment (expression has type "filterfalse[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:650: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
bidict (https://github.com/jab/bidict.git)
+ bidict/_orderedbidict.py:63: error: "object" not callable
|
1 similar comment
|
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip.git)
+ src/pip/_internal/operations/install/wheel.py:620: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:646: error: Incompatible types in assignment (expression has type "filterfalse[File]", variable has type "map[File]")
+ src/pip/_internal/operations/install/wheel.py:650: error: Incompatible types in assignment (expression has type "chain[File]", variable has type "map[File]")
bidict (https://github.com/jab/bidict.git)
+ bidict/_orderedbidict.py:63: error: "object" not callable
|
| def __iter__(self) -> Iterator[int]: ... | ||
| def __str__(self) -> str: ... | ||
| def __repr__(self) -> str: ... | ||
| def __int__(self) -> int: ... |
There was a problem hiding this comment.
I wonder if these were added on purpose to make bytes fulfill the SupportsInt and SupportsFloat protocols. int(b'12') works at runtime. Probably safer to keep them.
There was a problem hiding this comment.
- no mypy primer diffs
- the int __new__ function specifically gets bytes (so does float) and treats it as a string: https://github.com/python/cpython/blob/62ec63864822de1dd1933225584e8503ac40c1f9/Objects/longobject.c#L4960
- Other functions that receive SupportsInt fail on bytes - itertools.count(b'1',1)
There was a problem hiding this comment.
Sounds good, I will merge
|
Why were all these overloaded functions changed to classes? This breaks deduction in certain contexts. |
|
I'm not yet convinced that this PR has anything to do with that. I added this function to your mypy playground link, based on what this PR deletes, and used it instead of It still gives the same number of errors. |