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

Handle class with tuple base as TypeVar bound #7444

Merged
merged 2 commits into from Sep 2, 2019

Conversation

@ateraz
Copy link
Contributor

commented Sep 2, 2019

Fixes #7427
PR fixes using classes with tuple base as bound of TypeVar

Copy link
Collaborator

left a comment

Thanks for the PR! Looks good, I have just two comments.

@@ -261,6 +261,8 @@ def analyze_type_type_member_access(name: str,
upper_bound = get_proper_type(typ.item.upper_bound)
if isinstance(upper_bound, Instance):
item = upper_bound
elif isinstance(upper_bound, TupleType):
item = upper_bound.partial_fallback

This comment has been minimized.

Copy link
@ilevkivskyi

ilevkivskyi Sep 2, 2019

Collaborator

I think it will be safer to use tuple_fallback(upper_bound) here.


T = TypeVar('T', bound=A)
def f(x: Type[T]) -> None:
x.foo()

This comment has been minimized.

Copy link
@ilevkivskyi

ilevkivskyi Sep 2, 2019

Collaborator

Could you please use reveal_type(x.foo) to check that the type is correct?

@ateraz

This comment has been minimized.

Copy link
Contributor Author

commented Sep 2, 2019

@ilevkivskyi Thanks for your feedback, I've updated PR to incorporate it. Could you please check once again?

Copy link
Collaborator

left a comment

👍

@ilevkivskyi ilevkivskyi merged commit 14c6877 into python:master Sep 2, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.