Skip to content

Now overloads with ambiguous self are handled properly #11366

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from
Closed

Now overloads with ambiguous self are handled properly #11366

wants to merge 1 commit into from

Conversation

sobolevn
Copy link
Member

Closes #11347

@github-actions
Copy link
Contributor

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"

@BvB93
Copy link
Contributor

BvB93 commented Oct 20, 2021

Nice! It seems this PR fixes most of the issues.
One case that does still seem to fail is when Foo[Any] subclasses are involved:

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"

@sobolevn
Copy link
Member Author

@BvB93 I think that this is unrelated. Because it would require a change in how has_any_type works. And it can backfire in lots of places. But, please open a new issue for it! 👍

@BvB93
Copy link
Contributor

BvB93 commented Oct 20, 2021

@BvB93 I think that this is unrelated. Because it would require a change in how has_any_type works. And it can backfire in lots of places. But, please open a new issue for it! 👍

That's fair; will do.

@BvB93
Copy link
Contributor

BvB93 commented Jul 1, 2022

Out of curiosity, is there a particular reason why this has PR stalled?

@hauntsaninja hauntsaninja reopened this Jul 28, 2022
@sobolevn
Copy link
Member Author

Thanks for re-opening, but since I nuked my fork, I cannot edit or rebase this PR.
I need to do it by hand via CLI. I will at some point!

@flaeppe
Copy link

flaeppe commented Apr 15, 2024

Thanks for re-opening, but since I nuked my fork, I cannot edit or rebase this PR.
I need to do it by hand via CLI. I will at some point!

@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.

git fetch origin pull/11366/head:issue-11347
git switch issue-11347
git rebase --onto origin/master 4d0ab445514e0f9795306c0bc88a202be209df6b issue-11347
...

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

@sobolevn
Copy link
Member Author

@flaeppe feel free to take over this PR. I lost context of it :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overload ambiguity is ignored in self-annotated methods
4 participants