Skip to content

Conversation

@armicron
Copy link
Contributor

When a list of classes (not instances) is assigned to RedisSettings.retry_on_error, mypy finds an error:

$ make mypy
mypy arq
arq/poc_annotations.py:5: error: List item 0 has incompatible type "type[ConnectionError]"; expected "Exception"  [list-item]
Found 1 error in 1 file (checked 13 source files)
make: *** [Makefile:46: mypy] Error 1

Redis library for the similar parameter has the type annotation Optional[List[Type[Exception]]] (source)

How to reproduce:
create a file arq/poc_annotations.py

from arq.connections import RedisSettings
from redis.exceptions import ConnectionError


settings = RedisSettings(retry_on_error=[ConnectionError])

@codecov
Copy link

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.47%. Comparing base (94cd878) to head (ae148a0).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
+ Coverage   96.27%   96.47%   +0.19%     
==========================================
  Files          11       11              
  Lines        1074     1078       +4     
  Branches      209      190      -19     
==========================================
+ Hits         1034     1040       +6     
  Misses         19       19              
+ Partials       21       19       -2     
Files Coverage Δ
arq/connections.py 89.93% <100.00%> (-0.13%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1315583...ae148a0. Read the comment docs.

@ivorpeles
Copy link

Ran into this as well, would really like to see this merged. Can further confirm that if you pass in instances mypy is satisfied but my code breaks.

Even in the test code for arq the correct types are passed, even though this isn't detected by CI:
https://github.com/samuelcolvin/arq/blob/1315583f170512fc63622af0200a2855e057a58d/tests/conftest.py#L58

@Viicos Viicos changed the title Fix "retry_on_error" type annotation Fix retry_on_error type annotation Jan 29, 2026
Copy link
Collaborator

@Viicos Viicos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @armicron

@Viicos Viicos merged commit 1ceb435 into python-arq:main Jan 29, 2026
11 checks passed
@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
- Coverage   96.27%   96.02%   -0.26%     
==========================================
  Files          11       11              
  Lines        1074     1081       +7     
  Branches      209      144      -65     
==========================================
+ Hits         1034     1038       +4     
- Misses         19       21       +2     
- Partials       21       22       +1     
Files with missing lines Coverage Δ
arq/connections.py 87.42% <100.00%> (-2.65%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2354d8f...ad27150. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 this pull request may close these issues.

4 participants