Skip to content

Commit

Permalink
Allow returning Literals in __new__
Browse files Browse the repository at this point in the history
  • Loading branch information
Gobot1234 authored Jul 15, 2023
1 parent 3240da4 commit 396e8ee
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,8 @@ def check___new___signature(self, fdef: FuncDef, typ: CallableType) -> None:
"but must return a subtype of",
)
elif not isinstance(
get_proper_type(bound_type.ret_type), (AnyType, Instance, TupleType, UninhabitedType)
get_proper_type(bound_type.ret_type),
(AnyType, Instance, TupleType, UninhabitedType, LiteralType),
):
self.fail(
message_registry.NON_INSTANCE_NEW_TYPE.format(
Expand Down

0 comments on commit 396e8ee

Please sign in to comment.