diff --git a/jedi/inference/gradual/typing.py b/jedi/inference/gradual/typing.py index 50ab8e83..6b3e675b 100644 --- a/jedi/inference/gradual/typing.py +++ b/jedi/inference/gradual/typing.py @@ -413,6 +413,10 @@ class NewType(Value): self._type_value_set = type_value_set self.tree_node = tree_node + def py__class__(self): + c, = self._type_value_set.py__class__() + return c + def py__call__(self, arguments): return self._type_value_set.execute_annotation() diff --git a/test/completion/pep0484_typing.py b/test/completion/pep0484_typing.py index 8060270b..cc5dd71f 100644 --- a/test/completion/pep0484_typing.py +++ b/test/completion/pep0484_typing.py @@ -283,6 +283,18 @@ def testnewtype2(y): y #? [] y. + +# The type of a NewType is equivalent to the type of its underlying type. +MyInt = typing.NewType('MyInt', int) +x = type(MyInt) +#? type.mro +x.mro + +PlainInt = int +y = type(PlainInt) +#? type.mro +y.mro + # python > 2.7 class TestDefaultDict(typing.DefaultDict[str, int]):