Skip to content

Fix isinstance() for Protocols #330

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

Merged
merged 1 commit into from
Nov 19, 2016
Merged

Conversation

ilevkivskyi
Copy link
Member

Fixes #297

This allows to use isinstance() with classes that inherit from protocols in typing.py such as SupportsInt etc.

@gvanrossum I was thinking about how protocols should work (including runtime), and now I think that the "quick-fix" that you proposed is actually the right fix for this issue. (Main motivation is that a class that inherits from a protocol should not be considered a protocol itself, unless it lists Protocol in bases.)

Please, take a look.

@gvanrossum gvanrossum merged commit 1881ffd into python:master Nov 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isinstance + class indirectly deriving from SupportsInt results in "TypeError: Protocols cannot be used with isinstance()"
3 participants