It should be `type`, or even better `NoneType`. Code sample: ```python reveal_type(type) none = type(None) reveal_type(none) ``` Output: ``` » mypy out/ex.py --show-traceback --warn-unreachable out/ex.py:1: note: Revealed type is "Overload(def (o: builtins.object) -> builtins.type, def (name: builtins.str, bases: builtins.tuple[builtins.type], dict: builtins.dict[builtins.str, Any], **kwds: Any) -> builtins.type)" out/ex.py:3: note: Revealed type is "builtins.object" ``` Refs https://github.com/python/mypy/issues/11539 I will fix this. Not sure where yet: in typeshed or here.
Activity
[-]`reveal_type(type(None))` is object[/-][+]`reveal_type(type(None))` is `object`[/+]sobolevn commentedon Nov 14, 2021
Fun thing:
sobolevn commentedon Nov 14, 2021
This difference happens because the inner mypy AST is different:
For some reason
type(None)is turned intoTypeAliastoNone, which is not 100% correct. Here are some examples, where these two types are different:sobolevn commentedon Nov 14, 2021
Here's what we need to change:
mypy/mypy/semanal.py
Lines 2246 to 2260 in f9bf649
sobolevn commentedon Nov 14, 2021
This can be a breaking change, but I am going to try this anyway.
ilevkivskyi commentedon Feb 8, 2025
This is much better now: