mypy plugin: accept Literals in caches

This commit is contained in:
Olivier 'reivilibre
2026-07-31 13:16:14 +01:00
parent 3713c2fa10
commit cb29412559
+5
View File
@@ -45,6 +45,7 @@ from mypy.types import (
AnyType,
CallableType,
Instance,
LiteralType,
NoneType,
Options,
TupleType,
@@ -813,6 +814,10 @@ def is_cacheable(
if isinstance(rt, AnyType):
return True, ("may be mutable" if verbose else None)
elif isinstance(rt, LiteralType):
# Literal[True] etc
return True, None
elif isinstance(rt, Instance):
if (
rt.type.fullname in IMMUTABLE_VALUE_TYPES