-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
reveal_type(type(None))
is object
#11550
Labels
bug
mypy got something wrong
Comments
sobolevn
changed the title
Nov 14, 2021
reveal_type(type(None))
is objectreveal_type(type(None))
is object
Fun thing: none = type(None)
reveal_type(none) # N: Revealed type is "builtins.object"
# VS:
reveal_type(type(None)) # N: Revealed type is "Type[None]" |
This difference happens because the inner mypy AST is different:
For some reason >>> NoneType = type(None)
>>> NoneType()
>>> None()
<stdin>:1: SyntaxWarning: 'NoneType' object is not callable; perhaps you missed a comma?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
>>> NoneType.__bool__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: descriptor '__bool__' of 'NoneType' object needs an argument
>>> None.__bool__()
False |
Here's what we need to change: Lines 2246 to 2260 in f9bf649
|
This can be a breaking change, but I am going to try this anyway. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be
type
, or even betterNoneType
.Code sample:
Output:
Refs #11539
I will fix this. Not sure where yet: in typeshed or here.
The text was updated successfully, but these errors were encountered: