From ed70a8020200e1b61eb6b99d08b4fb13acb32c63 Mon Sep 17 00:00:00 2001 From: Robert Schweizer Date: Tue, 24 Sep 2024 18:19:53 +0200 Subject: [PATCH] Add re.Pattern to allowed match types Suggested in https://github.com/jd/tenacity/issues/436#issuecomment-1933445424 --- tenacity/retry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tenacity/retry.py b/tenacity/retry.py index 9211631..af3d45a 100644 --- a/tenacity/retry.py +++ b/tenacity/retry.py @@ -207,7 +207,7 @@ class retry_if_exception_message(retry_if_exception): def __init__( self, message: typing.Optional[str] = None, - match: typing.Optional[str] = None, + match: typing.Union[None, str, re.Pattern] = None, ) -> None: if message and match: raise TypeError( @@ -242,7 +242,7 @@ class retry_if_not_exception_message(retry_if_exception_message): def __init__( self, message: typing.Optional[str] = None, - match: typing.Optional[str] = None, + match: typing.Union[None, str, re.Pattern] = None, ) -> None: super().__init__(message, match) # invert predicate