Skip to content

Make caches Generic #608

Open
Open
@Dreamsorcerer

Description

@Dreamsorcerer

We should consider making BaseCache Generic, so we can provide better type safety when relevant.

Code could then look something like this, with mypy checking:

cache: Cache[str] = Cache(...)
await cache.get("foo")  # -> str
await cache.set("foo", "bar")  # OK
await cache.set("foo", 45)  # Error: Expected str

Existing typing behaviour can be reproduced by annotating it with Cache[Any].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions