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

Allow isinstance/issubclass with nested tuples #2995

Merged
merged 4 commits into from
Mar 18, 2017

Conversation

pkch
Copy link
Contributor

@pkch pkch commented Mar 14, 2017

Fix #2994

Useless without python/typeshed#998 (because parser will just choke on the nested tuples anyway). But since there are no tests for nested tuples, this PR is not strictly blocked by that other one.

@gvanrossum
Copy link
Member

Can you add a unit test please?

if isinstance(x, (str, (int, tuple))):
x[1] # E: Value of type "Union[int, str, tuple]" is not indexable
else:
x[1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add reveal_type(x) here.

x[1] # E: Value of type "Union[int, str, tuple]" is not indexable
else:
x[1]
if isinstance(x, (str, (list,))):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add reveal_type(x) before the if statement and within the if body.

@JukkaL
Copy link
Collaborator

JukkaL commented Mar 18, 2017

Thanks, LGTM!

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.

3 participants