backoff
backoff copied to clipboard
Fix `on_*` handler typing
- Allow passing coroutine functions to
on_*
handlers by also acceptingCallable[[Details], Coroutine[Any, Any, None]
for_Handler
. - Make
None
explicit foron_success
,on_backoff
,on_giveup
. - Better solution for
TypedDict
fallback. Some type checkers don't like passing the TypedDict arguments from a dynamic dict. Use__init_subclass__
instead to deal with**kwargs
in the fallback case. - Expose
Details
from__init__
to simplify typing for end-users.
@bgreen-litl Would you be able to take a quick look? This issue is preventing us from upgrading to v2.
Thank you! This is merged.
For the time being I removed Details from the top level name space. I think you're right it is handy for end users, but I think there might be some other stuff in _typing which might be similarly so. I am thinking it might be better to expose a backoff.typing module which is specific to any type hint stuff. At any, I want to do a quick release (v2.2.0) and didn't want to think about that detail too hard this second.