Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mypy/test/testtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,15 @@ def callable(self, vars: list[str], *a: Type) -> CallableType:
variables=tv,
)

def test_is_type_obj_with_any_return(self) -> None:
# https://github.com/python/mypy/issues/20585
c = CallableType([], [], [], self.fx.anyt, self.fx.type_type)
assert not c.is_type_obj()

def test_is_type_obj_with_instance_return(self) -> None:
c = CallableType([], [], [], self.fx.a, self.fx.type_type)
assert c.is_type_obj()


class JoinSuite(Suite):
def setUp(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ def is_kw_arg(self) -> bool:

def is_type_obj(self) -> bool:
return self.fallback.type.is_metaclass() and not isinstance(
get_proper_type(self.ret_type), UninhabitedType
get_proper_type(self.ret_type), (UninhabitedType, AnyType)
)

def type_object(self) -> mypy.nodes.TypeInfo:
Expand Down