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

None should be a subtype of an empty protocol #3906

Closed
ilevkivskyi opened this issue Sep 1, 2017 · 4 comments
Closed

None should be a subtype of an empty protocol #3906

ilevkivskyi opened this issue Sep 1, 2017 · 4 comments
Assignees
Labels

Comments

@ilevkivskyi
Copy link
Member

Currently this gives an incompatible type error with --strict-optional, although it works with plain object:

class Empty(Protocol):
    pass

e: Empty
e = None  # Error

o: object
o = None # This is OK
@ilevkivskyi ilevkivskyi self-assigned this Sep 1, 2017
@ilevkivskyi ilevkivskyi added bug mypy got something wrong priority-2-low labels Sep 1, 2017
@gvanrossum
Copy link
Member

Should we have a topic-protocols label?

@JukkaL
Copy link
Collaborator

JukkaL commented Sep 1, 2017

Yes. Do you want to add one?

@gvanrossum
Copy link
Member

Created the label and added some issues. Ivan may want to double-check, there may be more issues to be categorized this way.

@ilevkivskyi
Copy link
Member Author

Thanks! I added the label to few other issues.

gvanrossum pushed a commit that referenced this issue Sep 29, 2017
This updates protocol semantic according to the discussion in python/typing#464:

    None should be considered a subtype of an empty protocol
    method = None rule should apply only to callable protocol members
    issublcass() is prohibited for protocols with non-method members.

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

No branches or pull requests

3 participants