Skip to content

Conversation

@sagar1343
Copy link
Contributor

Summary

This PR fixes two small bugs in the Celery codebase:

1. Bug Fix: Regex Pattern in Version Parsing

File: celery/__init__.py (line 45)

Issue: The regex pattern r'(\d+)\.(\d+).(\d+)(.+)?' had an unescaped dot (.) between the minor and micro version numbers, which matches any character instead of a literal dot.

Fix: Changed to r'(\d+)\.(\d+)\.(\d+)(.+)?' to correctly match literal dots in version strings.

Impact:

  • Prevents incorrect parsing of malformed version strings (e.g., 5.6X0b2 would incorrectly match with old pattern)
  • Makes the version parser stricter and more correct
  • Maintains backward compatibility with all valid version formats

2. Code Quality: Remove Duplicate Entry

File: celery/utils/__init__.py (line 25)

Issue: Duplicate 'gen_task_name' entry in the __all__ tuple.

Fix: Removed the duplicate entry.

Impact: Cleaner code, no functional change.

Testing

  • ✅ Verified regex fix correctly matches version strings
  • ✅ Verified duplicate removal doesn't affect functionality
  • ✅ No linter errors
  • ✅ Backward compatible with existing version formats

Pre-PR Checklist

  • Code follows existing style
  • No new imports added/changed (no isort needed)
  • Linter checks passed
  • Changes are minimal and focused
  • Bug fixes maintain backward compatibility

Note: These are simple bug fixes that don't require new unit tests as:

  1. Version parsing is already covered by existing tests
  2. The duplicate removal doesn't change behavior (just cleans up the code)

…all__

- Fix: Escape second dot in version parsing regex pattern
  The pattern r'(\d+)\.(\d+).(\d+)' incorrectly used unescaped dot
  which matches any character. Changed to r'(\d+)\.(\d+)\.(\d+)'
  to correctly match literal dots in version strings.

- Fix: Remove duplicate 'gen_task_name' entry in celery/utils/__init__.py __all__
  Removed redundant duplicate entry in the __all__ tuple.
@auvipy auvipy requested review from auvipy and Copilot November 1, 2025 05:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses two minor code quality issues:

  • Removes a duplicate export of gen_task_name from the celery/utils/__init__.py module's __all__ list
  • Fixes a regex pattern bug in celery/__init__.py where a literal dot was used instead of an escaped dot for version parsing

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
celery/utils/init.py Removes duplicate gen_task_name entry from __all__ exports list
celery/init.py Corrects regex pattern to properly escape the second dot in version string parsing

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.68%. Comparing base (f47d5be) to head (96524c9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9978   +/-   ##
=======================================
  Coverage   78.68%   78.68%           
=======================================
  Files         153      153           
  Lines       19313    19313           
  Branches     2214     2214           
=======================================
  Hits        15196    15196           
  Misses       3817     3817           
  Partials      300      300           
Flag Coverage Δ
unittests 78.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@auvipy auvipy merged commit 7aaab22 into celery:main Nov 1, 2025
107 checks passed
@auvipy auvipy added this to the 5.6.0 milestone Nov 1, 2025
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