Skip to content

Commit b851fab

Browse files
committed
fix typing
1 parent 0925b89 commit b851fab

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

mypy/stubtest.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,7 @@ def anytype() -> mypy.types.AnyType:
16591659
if type_context:
16601660
# Don't attempt to account for context if the context is generic
16611661
# This is related to issue #3737
1662+
type_context = mypy.types.get_proper_type(type_context)
16621663
if isinstance(type_context, mypy.types.CallableType):
16631664
if isinstance(type_context.ret_type, mypy.types.TypeVarType):
16641665
type_context = None
@@ -1671,17 +1672,12 @@ def anytype() -> mypy.types.AnyType:
16711672
def _named_type(name: str) -> mypy.types.Instance:
16721673
parts = name.rsplit(".", maxsplit=1)
16731674
stub = get_stub(parts[0])
1674-
if stub is not None:
1675-
if parts[1] in stub.names:
1676-
node = stub.names[parts[1]]
1677-
assert isinstance(node.node, nodes.TypeInfo)
1678-
any_type = mypy.types.AnyType(mypy.types.TypeOfAny.special_form)
1679-
return mypy.types.Instance(
1680-
node.node, [any_type] * len(node.node.defn.type_vars)
1681-
)
1682-
1683-
any_type = mypy.types.AnyType(mypy.types.TypeOfAny.from_error)
1684-
return mypy.types.Instance(node.node, [])
1675+
assert stub is not None
1676+
assert parts[1] in stub.names
1677+
node = stub.names[parts[1]]
1678+
assert isinstance(node.node, nodes.TypeInfo)
1679+
any_type = mypy.types.AnyType(mypy.types.TypeOfAny.special_form)
1680+
return mypy.types.Instance(node.node, [any_type] * len(node.node.defn.type_vars))
16851681

16861682
if isinstance(runtime, type):
16871683
# Try and look up a stub for the runtime object itself
@@ -1691,6 +1687,7 @@ def _named_type(name: str) -> mypy.types.Instance:
16911687
if runtime.__name__ in stub.names:
16921688
type_info = stub.names[runtime.__name__].node
16931689
if isinstance(type_info, nodes.TypeInfo):
1690+
result: mypy.types.Type | None = None
16941691
result = mypy.checkmember.type_object_type(type_info, _named_type)
16951692
if mypy.checkexpr.is_type_type_context(type_context):
16961693
# This is the type in a type[] expression, so substitute type

0 commit comments

Comments
 (0)