8000 Add type annotations · Issue #70 · aio-libs/async-lru · GitHub
[go: up one dir, main page]

Skip to content
Add type annotations #70
@gjcarneiro

Description

@gjcarneiro

Test program:

import asyncio
from async_lru import alru_cache


@alru_cache(maxsize=16384)
async def my_cached_func(arg1: str, arg2: int) -> str:
    return arg1 * arg2


async def main() -> None:
    result = await my_cached_func("abc")
    print(result)


asyncio.run(main())

Now, the program has a bug, but mypy normally can't find it because of missing type annotations:

# mypy test.py --ignore-missing-imports

If I comment out the @alru_cache(maxsize=16384) line, I get the expected mypy error:

# mypy test.py --ignore-missing-imports
test.py:11: error: Too few arguments for "my_cached_func"

Relevant PEP: https://www.python.org/dev/peps/pep-0561/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0