Skip to content

refactor: remove pre-Python 3.10 leftovers - #10525

Open
wittachai-as wants to merge 1 commit into
celery:mainfrom
wittachai-as:remove-pre-310-leftovers
Open

wittachai-as wants to merge 1 commit into
celery:mainfrom
wittachai-as:remove-pre-310-leftovers

Conversation

@wittachai-as

Copy link
Copy Markdown

Description

Celery's floor is python_requires=">=3.10" (setup.py). This PR removes leftovers from before that floor. Every item is provable from the project's own metadata, and there is no behavior change on any supported Python version.

celery/utils/time.py: if sys.version_info >= (3, 9) is always true on 3.10+, so the else-branch importing backports.zoneinfo is dead code. Unwrapped to a plain from zoneinfo import ZoneInfo and dropped the now-unused import sys.

celery/utils/imports.py: if sys.version_info >= (3, 10) is always true. Removed the dead fallback for older importlib.metadata APIs.

celery/concurrency/asynpool.py: performed the rewrite the TODO was waiting for ("once we drop support for Python 3.7"). The loop is now the dict comprehension with the walrus operator the comment described.

setup.cfg: removed backports.zoneinfo>=0.2.1;python_version<'3.9' from [bdist_rpm] requires. Under a 3.10 floor that environment marker can never be satisfied.

Found while auditing version-gated leftovers in popular open-source projects.

@auvipy
auvipy self-requested a review August 29, 2026 03:33
@auvipy auvipy self-assigned this Sep 30, 2026
@auvipy auvipy added this to the 5.7.x milestone Sep 30, 2026
setup.py declares python_requires=">=3.10", so these branches can never be
taken on a supported interpreter:

- celery/utils/imports.py: the `sys.version_info >= (3, 10)` gate around
  `entry_points(group=namespace)` is always true; the fallback is dead.
- celery/utils/time.py: the `backports.zoneinfo` fallback for < 3.9 is
  unreachable — `zoneinfo` has been in the stdlib since 3.9. `sys` is no
  longer used in this module, so the import goes too.
- setup.cfg: the bdist_rpm requirement on
  `backports.zoneinfo>=0.2.1;python_version<'3.9'` can never apply.

No behaviour change on any supported version.

Rebased on current main and reduced in scope: this PR previously also
rewrote the `owned_by` loop in celery/concurrency/asynpool.py, which was
handled upstream in celery#10742, so that change is dropped here.

This branch has not been deployed

No deployments
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.

2 participants