Repository navigation
Conversation
sobolevn
commented
Nov 14, 2021
| if self.is_none_alias(rvalue): | ||
| # This is really `Type[None]`, not just `None`, but we use | ||
| # this as a backwards compatible solution. See #11550 | ||
| res = NoneType() |
Member
Author
There was a problem hiding this comment.
This can still cause issues, for example:
none = type(None)
print(none()) # E: error: Cannot instantiate type "Type[None]"But, I've decided to keep this as-is (and do not change this to res = TypeType(NoneType())), because I'm affraid this can cause issues to our old users, who use type(None) for annotations.
Member
Author
There was a problem hiding this comment.
If we decide to change this, we can try to make Type[None] and None compatible. So, this will work:
n = type(None)
var: n = None # will still be ok!
Member
There was a problem hiding this comment.
I think types that are none should be annotated None. If someone tries to annotate something that is none as type(None) we should give an error and tell them to annotate it as : None (though I also expect this to be rather rare).
Member
Author
|
Related #11551 |
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11550
This might fail in some unexpected cases.