Skip to content

[Bug]: lru_cache annotations broken on Python 3.14 #188

@dotlambda

Description

@dotlambda

What happened?

________________________ test_wrapper_attributes[None] _________________________

size = None

    @pytest.mark.parametrize("size", [None, 0, 10, 128])
    def test_wrapper_attributes(size: "int | None"):
        class Bar:
            @a.lru_cache
            async def method(self, int_arg: int):
                """Method docstring"""
    
            @a.lru_cache
            async def other_method(self):
                """Method docstring"""
    
        assert Bar.method.__doc__ == """Method docstring"""
        for name in ("method", "other_method"):
            for cache in (getattr(Bar, name), getattr(Bar(), name)):
                assert cache.__doc__ == """Method docstring"""
                assert cache.__name__ == name
                assert cache.__qualname__.endswith(f"Bar.{name}")
                if name != "method":
                    continue
                # test direct and literal annotation styles
>               assert Bar.method.__annotations__["int_arg"] in {int, "int"}
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E               KeyError: 'int_arg'

unittests/test_functools_lru.py:178: KeyError

Minimal Reproducible Example

Request Assignment [Optional]

  • I already understand the cause and want to submit a bugfix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions