This repository was archived by the owner on Aug 8, 2025. It is now read-only.
Replies: 1 comment
-
|
I ended up using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing some code that uses
on_predicateto rate limit in an API client, roughly like this:This function will always return the return value of
fn(), since it continues trying forever - but because I'm usingNoneas the sentinel object for the predicate, mypy wants the return type to beOptional[_T]instead of_T. I end up leaking implementation details to my callers, sinceNoneisn't ever returned to them, but the type system can't understand that.Are there patterns that people use to avoid this problem? I could write a wrapper function that casts away the optional, or I could raise an exception and use the
on_exceptionhandler instead, but I'm curious what others have done.Beta Was this translation helpful? Give feedback.
All reactions