From cb2941255990e6473ca83f1922c7c04a4c0524be Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Fri, 31 Jul 2026 13:16:14 +0100 Subject: [PATCH] mypy plugin: accept Literals in caches --- scripts-dev/mypy_synapse_plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts-dev/mypy_synapse_plugin.py b/scripts-dev/mypy_synapse_plugin.py index 7fe4d6cd86..ac1fee7f67 100644 --- a/scripts-dev/mypy_synapse_plugin.py +++ b/scripts-dev/mypy_synapse_plugin.py @@ -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