You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A followup to the issue presented in #6953, I'm running into mypy errors when implementing a cache using the mechanism as defined in the cachetools documentation.
Argument "timer" to "TLRUCache" has incompatible type "Callable[[Optional[tzinfo]], datetime]"; expected "Callable[[], float]"
Workaround:
We can use time.monotonic instead of datetime.now, but:
- the example in the docs use datetime.now
- datetime.now is arguably more familiar to most developers
Versions
cachetools: 5.2.0
types-cachetools: 5.2.1
The text was updated successfully, but these errors were encountered:
I've have a similar problem with the ttl variable. Maybe my own incompetance but I couldn't get my tests with freezegun working with time.monotonic. Made the switch and can write the tests no problem but currently haven't to supress lint warnings for using timedelta instead of float.
A followup to the issue presented in #6953, I'm running into mypy errors when implementing a cache using the mechanism as defined in the cachetools documentation.
Cachetools documentation for TRLUCache with example that matches the implementation below.
My implementation
The mypy error:
Workaround:
We can use
time.monotonic
instead ofdatetime.now
, but:- the example in the docs use datetime.now
- datetime.now is arguably more familiar to most developers
Versions
The text was updated successfully, but these errors were encountered: