Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add types.GenericAlias.__mro_entries__ #13284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Dec 23, 2024

I used Iterable[object] because it matches the call signature of resolve_bases, but it could just as easily be Any because the specific implementation here doesn't look at the argument and always returns a 1-tuple of the __origin__ attribute.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/trade.py:189: error: Argument 1 of "__mro_entries__" is incompatible with supertype "GenericAlias"; supertype defines the argument type as "Iterable[object]"  [override]
+ steam/trade.py:189: note: This violates the Liskov substitution principle
+ steam/trade.py:189: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

@tungol tungol marked this pull request as draft December 23, 2024 20:10
@tungol tungol marked this pull request as ready for review December 23, 2024 20:11
@tungol
Copy link
Contributor Author

tungol commented Dec 23, 2024

steam.py has a custom subclass of GenericAlias which defines a __mro_entries__ as def __mro_entries__(self, bases: tuple[type, ...]) -> tuple[type]:. That's what I probably would have gone with here myself if I hadn't seen the discussion for types.resolve_bases.

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

Successfully merging this pull request may close these issues.

1 participant