Skip to content

Commit

Permalink
bugfix: no __contains__ on StrEnum until 3.12 (#4933)
Browse files Browse the repository at this point in the history
  • Loading branch information
wssheldon authored Jul 8, 2024
1 parent cb60cd4 commit b00b5b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/dispatch/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class Visibility(DispatchEnum):
RESTRICTED = "Restricted"
assert str(Visibility.OPEN) == "Open"
assert "Open" in Visibility
Note:
In `3.12` we will get `__contains__` functionality:
DeprecationWarning: in 3.12 __contains__ will no longer raise TypeError, but will return True or
False depending on whether the value is a member or the value of a member
"""

pass # No additional implementation needed
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def should_retry(exception: Exception) -> bool:
match exception:
case SlackApiError():
# Don't retry for exceptions we have defined.
return exception.response["error"] not in SlackAPIErrorCode
return exception.response["error"] not in SlackAPIErrorCode.__members__.values()
case TimeoutError() | Timeout():
# Always retry on timeout errors
return True
Expand Down

0 comments on commit b00b5b2

Please sign in to comment.