Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect typing for autoretry_for #107

Closed
sk- opened this issue Mar 19, 2023 · 0 comments · Fixed by #108
Closed

Incorrect typing for autoretry_for #107

sk- opened this issue Mar 19, 2023 · 0 comments · Fixed by #108

Comments

@sk-
Copy link
Contributor

sk- commented Mar 19, 2023

We have the following code

@shared_task(
    autoretry_for=(PoolTimeout, CancelledError),
    max_retries=10,
    retry_backoff=True,
    retry_backoff_max=100,
    retry_jitter=False,
)
def my_task(...):
  ...

But unfortunately mypy it's throwing the following error:

error: Argument "autoretry_for" to "shared_task" has incompatible type "Tuple[Type[PoolTimeout], Type[CancelledError]]"; expected "Tuple[Type[Exception], ...]"  [arg-type]

The reason for this is that CancelledError extends from BaseException instead of Exception. This is the issue where they changed the base class.

sk- added a commit to sk-/celery-types that referenced this issue Mar 19, 2023
There are some exceptions like `CancelledError` that extend from `BaseException` instead of `Exception`, and that makes it impossible to correctly pass them as arguments to `autoretry_for`.

This fixes sbdchd#107.

I'm not sure if we should to a similar change to the `throws` argument.
@kodiakhq kodiakhq bot closed this as completed in #108 Mar 19, 2023
kodiakhq bot pushed a commit that referenced this issue Mar 19, 2023
There are some exceptions like `CancelledError` that extend from `BaseException` instead of `Exception`, and that makes it impossible to correctly pass them as arguments to `autoretry_for`.

This fixes #107.

I'm not sure if we should to a similar change to the `throws` argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant