Skip to content

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

Draft
auvipy wants to merge 4 commits intomainfrom
revert-2225-revert-2098-bugfix/type-error-version-checking
Draft

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

Conversation

@auvipy
Copy link
Copy Markdown
Member

@auvipy auvipy commented Jul 16, 2025

Reverts #2225

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

This comment was marked as outdated.

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 16, 2025

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.41%. Comparing base (9022fcc) to head (94b7c94).
✅ 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.44%   82.41%   -0.04%     
==========================================
  Files          79       79              
  Lines       10142    10151       +9     
  Branches     1165     1164       -1     
==========================================
+ Hits         8362     8366       +4     
- Misses       1579     1584       +5     
  Partials      201      201              

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

@auvipy auvipy requested a review from Copilot July 16, 2025 06:06
Copy link
Copy Markdown
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 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]
Copy link

Copilot AI Jul 16, 2025

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(
Copy link

Copilot AI Jul 16, 2025

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
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