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
Similar issues can also arise with the same traceback, such as:
@backoff.on_exception(backoff.expo, ValueError())
which are hard to understand and debug, as there are no lines between the function call in user code and the except exception as e in the library.
I see two major different ways to improve this:
A) modify the type information. If done directly, this would change the type to Union[Type[Exception], Tuple[Type[Exception]]],
Alternatively, you could add to _typing.py:
_MaybeTuple = Union[T, Tuple[T]]
and then change the type to _MaybeTuple[Type[Exception]].
B) Do checking of exception when it is given to the function to improve error response. Essentially, just check if it is an Exception or a tuple of exception types and raise a ValueError if not.
The text was updated successfully, but these errors were encountered:
Currently,
on_exception
takes an argumentexception: _MaybeSequence[Type[Exception]]
.However, this cannot handle any
Sequence
ofType[Exception]
. For instance, if alist[Type[Exception]]
is given, as in the following code:then a hard-to-understand stack trace is generated:
Similar issues can also arise with the same traceback, such as:
which are hard to understand and debug, as there are no lines between the function call in user code and the
except exception as e
in the library.I see two major different ways to improve this:
A) modify the type information. If done directly, this would change the type to
Union[Type[Exception], Tuple[Type[Exception]]],
Alternatively, you could add to
_typing.py
:and then change the type to
_MaybeTuple[Type[Exception]]
.B) Do checking of
exception
when it is given to the function to improve error response. Essentially, just check if it is an Exception or a tuple of exception types and raise a ValueError if not.The text was updated successfully, but these errors were encountered: