fix: taskiq admin middleware doesn't work with python <3.11#529
Merged
s3rius merged 4 commits intotaskiq-python:masterfrom Oct 30, 2025
Merged
fix: taskiq admin middleware doesn't work with python <3.11#529s3rius merged 4 commits intotaskiq-python:masterfrom
s3rius merged 4 commits intotaskiq-python:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request upgrades the anyio dependency from version 3.x to 4.x and removes the @pytest.mark.anyio decorators from test files. The upgrade allows pytest-anyio to automatically detect and run async tests through the new anyio_mode = "auto" configuration in pyproject.toml. Additionally, the PR replaces the deprecated datetime.UTC with timezone.utc for Python 3.9+ compatibility.
Key changes:
- Upgraded
anyiofrom>=3to>=4(version 4.11.0 in lock file) - Added
anyio_mode = "auto"to pytest configuration to enable automatic async test detection - Removed
@pytest.mark.anyiodecorators from all test files (decorator no longer needed with auto mode) - Changed
datetime.UTCtotimezone.utcin the middleware for broader Python compatibility
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Updated anyio dependency constraint to >=4 and added anyio_mode configuration for automatic async test detection |
| poetry.lock | Updated lock file reflecting anyio upgrade from 4.9.0 to 4.11.0 |
| taskiq/middlewares/taskiq_admin_middleware.py | Replaced deprecated datetime.UTC import with timezone.utc for compatibility |
| tests/test_*.py (multiple files) | Removed @pytest.mark.anyio decorators and pytest imports (no longer needed with auto mode) |
| tests/middlewares/test_taskiq_admin_middleware.py | New test file with @pytest.mark.anyio decorators retained (uses pytest fixtures) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
494acf6 to
a1d38c5
Compare
a1d38c5 to
5183c9f
Compare
a874d19 to
a6894fd
Compare
s3rius
approved these changes
Oct 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
Import
from datetime import UTCis valid only with python version equal or higher 3.11 - docs.Also type hint with
str | Nonenot working in python versions lower than 3.10, because PEP-604 was implemented in python 3.10.So I fixed an import + type hint and added some basic tests to just calling code from this files and make sure that it works. I also added ruff rule FA102 to prevent this issues in future commits.
Mics
Update
anyioversion inpoetry.lockto enableanyio_mode=autoin tests and get rid ofpytest.mark.anyiodecorators. They added this ability in last version - release notes (see 4.11.0)Connected to this issue: danfimov/taskiq-dashboard#29