Closed ryancausey closed 10 months ago
Not great but calling re.compile
on a re.Pattern
works.
Oh, I didn't realize that would work. I'll close this then.
I guess we should update the parameter type to capture this non-obvious flexibility?
- match: typing.Optional[str] = None,
+ match: typing.Optional[str | re.Pattern] = None,
Currently, the implementation of
retry_if_exception_message
accepts a regular expression pattern in thematch
argument. This gets passed tore.compile
and used to perform a match against the exception message.However, since the argument is a regular expression pattern and not a
re.Pattern
object, users are unable to specify any of the regular expression flags. For example, one cannot passre.IGNORECASE
to specify case-insensitive matching.A proposed solution is to allow someone to pass an already compiled regular expression, a
re.Pattern
object, into thematch
argument so the caller has full control of the regular expression used, including flags.Relates to:
125
127