From 396e8ee6b95f9761cc480cb0e281675e00f6841c Mon Sep 17 00:00:00 2001 From: James Hilton-Balfe Date: Sat, 15 Jul 2023 23:04:06 +0200 Subject: [PATCH] Allow returning Literals in __new__ Unblocks https://github.com/python/typeshed/pull/10465 --- mypy/checker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/checker.py b/mypy/checker.py index f2873c7d58e4..06d770665ea9 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -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(