Skip to content

Commit 396e8ee

Browse files
authored
Allow returning Literals in __new__
Unblocks python/typeshed#10465
1 parent 3240da4 commit 396e8ee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mypy/checker.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,8 @@ def check___new___signature(self, fdef: FuncDef, typ: CallableType) -> None:
14751475
"but must return a subtype of",
14761476
)
14771477
elif not isinstance(
1478-
get_proper_type(bound_type.ret_type), (AnyType, Instance, TupleType, UninhabitedType)
1478+
get_proper_type(bound_type.ret_type),
1479+
(AnyType, Instance, TupleType, UninhabitedType, LiteralType),
14791480
):
14801481
self.fail(
14811482
message_registry.NON_INSTANCE_NEW_TYPE.format(

0 commit comments

Comments
 (0)