Skip to content

Commit 0fe816c

Browse files
committed
functools plugin: Use get_proper_type before isinstance checks in lru_cache callback
Prevents mypy error about applying isinstance to unexpanded types by ensuring first_arg_type is expanded before checking for
1 parent d03a3b3 commit 0fe816c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mypy/plugins/functools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ def functools_lru_cache_callback(ctx: mypy.plugin.FunctionContext) -> Type:
410410
first_arg_type = ctx.arg_types[0][0]
411411

412412
# Explicitly check that this is NOT a literal or other non-function type
413-
from mypy.types import Instance, LiteralType
414-
415-
if isinstance(first_arg_type, (LiteralType, Instance)):
413+
from mypy.types import LiteralType, Instance
414+
proper_first_arg_type = get_proper_type(first_arg_type)
415+
if isinstance(proper_first_arg_type, (LiteralType, Instance)):
416416
# This is likely maxsize=128 or similar - let MyPy handle it
417417
return ctx.default_return_type
418418

0 commit comments

Comments
 (0)