dgilland / pydash

The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.

Home Page:http://pydash.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improper verifying of param: "exceptions" in retry

gryznar opened this issue · comments

In function retry there is auto conversion to tuple if parametr exceptions is instance of Exception:

if isinstance(exceptions, Exception):  # pragma: no cover
    exceptions = (exceptions,) 

But this is improper from at least 2 reasons:

  1. Documentation of this param says:
    """
    exceptions (tuple, optional): Tuple of exceptions that trigger a retry attempt. Exceptions
    not in the tuple will be ignored. Defaults to (Exception,) (all exceptions).
    """ <- single Exception is not mentioned here
  2. Check itself. Should be:
if issubclass(exceptions, Exception):  # pragma: no cover
    exceptions = (exceptions,) 

How it could be fixed:

  1. Fix check and update documentation to mention single exception class in possible values
    OR
  2. Remove this check and conversion

Thanks for reporting!

I opted to just remove the check/conversion since it wasn't working and not documented to work anyway.