Skip to content

Parameters for a call to a function wrapped in a lru_cache are not checked #16261

@andrewjw

Description

@andrewjw

Bug Report

The parameters used in a call to a function which is wrapped in a functools.lru_cache are not checked.

To Reproduce

from datetime import date
from functools import lru_cache

@lru_cache
def f(v: str, at: date) -> str:
    return v

f()
f("abc")
f("abc", date.today())
f("abc", now=date.today())
f("abc", at=date.today())
f("abc", at="wrong_type")

Expected Behavior

This should raise several errors about the arguments being wrong. Commenting out the line @lru_cache correctly generates the following errors.

lru_cache_type_test.py:8: error: Missing positional arguments "v", "at" in call to "f"  [call-arg]
lru_cache_type_test.py:9: error: Missing positional argument "at" in call to "f"  [call-arg]
lru_cache_type_test.py:11: error: Unexpected keyword argument "now" for "f"  [call-arg]
lru_cache_type_test.py:13: error: Argument "at" to "f" has incompatible type "str"; expected "date"  [arg-type]

Actual Behavior

Success: no issues found in 1 source file

Your Environment

mypy 1.6.0 running on Python 3.11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions