Rebind self-types in subclass methods without Self annotation#15541
Merged
ilevkivskyi merged 3 commits intopython:masterfrom Jun 29, 2023
Merged
Rebind self-types in subclass methods without Self annotation#15541ilevkivskyi merged 3 commits intopython:masterfrom
ilevkivskyi merged 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Member
|
The mypyc TypedDict test failures are due to the latest typing_extensions release, not this PR: #15542 |
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Member
Author
|
This is quite minor, so I am going to merge this later today or tomorrow unless there are comments/objections. |
Collaborator
|
This seems to cause a regression with dataclasses. In particular from dataclasses import dataclass
from typing import Callable, assert_type
@dataclass
class Description:
name_fn: Callable[[int | None], str | None]
def f(d: Description) -> None:
assert_type(d.name_fn, Callable[[int | None], str | None]) # E: \
# Expression is of type "Callable[[int], str]", not "Callable[[int | None], str | None]" |
Member
Author
|
Yeah, this is annoying, let me do something to prevent this kind of things once and for all. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15529
The fix is straightforward, hopefully there will be no fallout. (Note that #14075 would also fix this, but I am still not sure we should do that)