Skip to content

Commit

Permalink
Fixes the type signature of retry_exception_types.
Browse files Browse the repository at this point in the history
code was failing previously when passed in a list of Exception types for
`retry_exception_types`. the type `list[Exception]` indicates a list of
Exception *objects*, while `list[type[Exception]]` indicates a list of
Exception types.

https://docs.python.org/3/library/typing.html#the-type-of-class-objects

PiperOrigin-RevId: 590455167
  • Loading branch information
dusenberrymw authored and edward-bot committed Dec 13, 2023
1 parent b24a97d commit 7a11c97
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion edward2/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def robust_map(
max_retries: int | None = ...,
max_workers: int | None = ...,
raise_error: Literal[False] = ...,
retry_exception_types: list[type[Exception]] | None = ...,
) -> Sequence[U | V]:
...

Expand All @@ -52,6 +53,7 @@ def robust_map(
max_retries: int | None = ...,
max_workers: int | None = ...,
raise_error: Literal[True] = ...,
retry_exception_types: list[type[Exception]] | None = ...,
) -> Sequence[U]:
...

Expand All @@ -66,7 +68,7 @@ def robust_map(
max_retries: int | None = None,
max_workers: int | None = None,
raise_error: bool = False,
retry_exception_types: list[Exception] | None = None,
retry_exception_types: list[type[Exception]] | None = None,
) -> Sequence[U | V]:
"""Maps a function to inputs using a threadpool.
Expand Down

0 comments on commit 7a11c97

Please sign in to comment.