Skip to content

Revert "Revert "Resolving TypeError, during version unpacking "" - #2333

Draft
auvipy wants to merge 5 commits into
mainfrom
revert-2225-revert-2098-bugfix/type-error-version-checking
Draft

Revert "Revert "Resolving TypeError, during version unpacking ""#2333
auvipy wants to merge 5 commits into
mainfrom
revert-2225-revert-2098-bugfix/type-error-version-checking

Conversation

@auvipy

@auvipy auvipy commented Jul 16, 2025

Copy link
Copy Markdown
Member

Reverts #2225

@auvipy
auvipy requested a review from Copilot July 16, 2025 06:00

This comment was marked as outdated.

@codecov

codecov Bot commented Jul 16, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.87%. Comparing base (9ee8595) to head (db00985).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
kombu/utils/text.py 90.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2333      +/-   ##
==========================================
- Coverage   82.90%   82.87%   -0.04%     
==========================================
  Files          79       79              
  Lines       10402    10411       +9     
  Branches     1197     1196       -1     
==========================================
+ Hits         8624     8628       +4     
- Misses       1577     1582       +5     
  Partials      201      201              

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

@auvipy
auvipy requested a review from Copilot July 16, 2025 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 reverts the previous revert of version unpacking logic (#2225), reintroducing an updated regex-based parsing approach and extending test coverage.

  • Added new test cases for complex version strings in test_utils.py.
  • Refactored version_string_as_tuple to use a fullmatch regex and updated _unpack_version signature.
  • Cleaned up formatting in escape_regex, fmatch_iter, and fmatch_best.

Reviewed Changes

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

File Description
t/unit/utils/test_utils.py Reformatted @pytest.mark.parametrize and added tests for additional version patterns
kombu/utils/text.py Introduced regex parsing in version_string_as_tuple, updated helper signatures, and adjusted utility formatting

Comment thread kombu/utils/text.py Outdated
Comment thread kombu/utils/text.py
Comment on lines 38 to +50
return sorted(
fmatch_iter(needle, haystack, min_ratio), reverse=True,
)[0][1]
fmatch_iter(needle, haystack, min_ratio),
reverse=True,
)[
0
][1]

Copilot AI Jul 16, 2025

Copy link

Choose a reason for hiding this comment

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

Using sorted() to find the best match sorts the entire iterable, which is inefficient if only the max is needed. Consider using max(fmatch_iter(...), key=lambda x: x[0], default=(None, None))[1] to avoid constructing a full list.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

and this @couzhei

Comment thread kombu/utils/text.py


def _splitmicro(micro: str, releaselevel: str = '', serial: str = '') -> tuple[int, str, str]:
def _splitmicro(

Copilot AI Jul 16, 2025

Copy link

Choose a reason for hiding this comment

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

The _splitmicro helper is no longer referenced by version_string_as_tuple and appears unused. Consider removing it to eliminate dead code.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@couzhei what is your take on this?

auvipy and others added 3 commits August 8, 2025 21:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@auvipy
auvipy force-pushed the revert-2225-revert-2098-bugfix/type-error-version-checking branch from 538b219 to 4ce1c95 Compare August 8, 2025 15:51
@auvipy auvipy added this to the 5.7.0 milestone Aug 10, 2025
@auvipy auvipy modified the milestones: 5.7.0, 5.8.0 Aug 25, 2026
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