Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make caches Generic #608

Open
Dreamsorcerer opened this issue Dec 31, 2022 · 0 comments
Open

Make caches Generic #608

Dreamsorcerer opened this issue Dec 31, 2022 · 0 comments
Milestone

Comments

@Dreamsorcerer
Copy link
Member

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].

@Dreamsorcerer Dreamsorcerer added this to the 1.0 milestone Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant