Now overloads with ambiguous self are handled properly#11366
Now overloads with ambiguous self are handled properly#11366sobolevn wants to merge 1 commit intopython:masterfrom sobolevn:issue-11347
self are handled properly#11366Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: edgedb (https://github.com/edgedb/edgedb.git)
+ edb/schema/name.py:264:2: error: Untyped decorator makes function "_serialize_to_markup" untyped
+ edb/schema/objects.py:3209:2: error: Untyped decorator makes function "_serialize_to_markup" untyped
+ edb/schema/objects.py:3210:2: error: Untyped decorator makes function "_serialize_to_markup" untyped
+ edb/ir/ast.py:815:2: error: Untyped decorator makes function "_serialize_to_markup" untyped
- edb/ir/staeval.py:265:1: error: Dispatch type "TypeCast" must be subtype of fallback function first argument "ConstExpr"
+ edb/ir/staeval.py:205:2: error: Untyped decorator makes function "empty_set_to_python" untyped
+ edb/ir/staeval.py:213:2: error: Untyped decorator makes function "const_set_to_python" untyped
+ edb/ir/staeval.py:220:2: error: Untyped decorator makes function "int_const_to_python" untyped
+ edb/ir/staeval.py:234:2: error: Untyped decorator makes function "float_const_to_python" untyped
+ edb/ir/staeval.py:248:2: error: Untyped decorator makes function "str_const_to_python" untyped
+ edb/ir/staeval.py:256:2: error: Untyped decorator makes function "bool_const_to_python" untyped
+ edb/ir/staeval.py:264:2: error: Untyped decorator makes function "cast_const_to_python" untyped
tornado (https://github.com/tornadoweb/tornado.git)
- tornado/test/iostream_test.py:814: error: "IOLoop" has no attribute "selector_loop"
|
|
Nice! It seems this PR fixes most of the issues. from typing import Generic, TypeVar, overload, Any
T = TypeVar('T')
class Some(Generic[T]):
@overload
def method(self: Some[int]) -> bool: ...
@overload
def method(self: Some[str]) -> float: ...
def method(self): pass
class SomeSubtype(Some[Any]):
pass
s3: Some[Any]
reveal_type(s3.method()) # N: Revealed type is "Any"
s4: SomeSubtype
reveal_type(s4.method()) # N: Revealed type is "builtins.bool"
# Should also be: Revealed type is "Any" |
|
@BvB93 I think that this is unrelated. Because it would require a change in how |
That's fair; will do. |
|
Out of curiosity, is there a particular reason why this has PR stalled? |
|
Thanks for re-opening, but since I nuked my fork, I cannot edit or rebase this PR. |
@sobolevn just wanted to hint that it's quite quickly to get hold the contents here in order to e.g. rebase. Should only be a few lines: e.g. Make sure to just swap out to your correct remote name and what branch name you'd like Taken from: Modifying an inactive pull request locally |
|
@flaeppe feel free to take over this PR. I lost context of it :) |
Closes #11347