-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend PEP440 to include (_/-) as dev/post/pre-release separator #334
Conversation
Warning Rate limit exceeded@ludeeus has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 38 minutes and 29 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent changes enhance the flexibility of the PEP440 version string matching in Changes
Sequence Diagram(s)Not applicable. Assessment against linked issues
These changes enhance the overall functionality and flexibility of the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
awesomeversion/utils/regex.py
Outdated
@@ -17,7 +17,7 @@ | |||
) | |||
RE_PEP440 = ( | |||
r"([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)" | |||
r"(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?(\.rc(0|[1-9][0-9]*))?" | |||
r"(0|[1-9][0-9]*))?([-_\.]?(post|dev|rc)(0|[1-9][0-9]*))*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Regex allows multiple consecutive separators.
The test with the input 1.1--dev1
matched, indicating that the regex currently permits multiple consecutive separators. This can lead to incorrect parsing of version strings.
- Location:
awesomeversion/utils/regex.py
, line 20.
Recommendation: Modify the regex to disallow multiple consecutive separators.
Analysis chain
Ensure regex handles edge cases correctly.
The updated regex now allows for -
, _
, and .
as optional separators between version components. Ensure this does not introduce any unintended matches, such as allowing multiple separators consecutively which could lead to incorrect version parsing.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify regex doesn't allow multiple separators consecutively.
# Test: Check regex pattern against invalid inputs. Expect: No matches for invalid inputs.
echo "1.1--dev1" | grep -P '([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?([-_\.]?(post|dev|rc)(0|[1-9][0-9]*))*'
Length of output: 153
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
awesomeversion/utils/regex.py
Outdated
r"([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*" | ||
r"?([-_\.]?(alpha|beta|c|d|dev|pre|preview|a|b|rc|post|r|rev)(0|[1-9][0-9]*))*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure regex pattern does not allow multiple consecutive separators.
The updated regex pattern now supports additional separators (-
, _
, .
). However, ensure it does not permit multiple consecutive separators as this can lead to incorrect parsing.
- r"?([-_\.]?(alpha|beta|c|d|dev|pre|preview|a|b|rc|post|r|rev)(0|[1-9][0-9]*))*"
+ r"?([-_\.]?)(alpha|beta|c|d|dev|pre|preview|a|b|rc|post|r|rev)(0|[1-9][0-9]*))"
Committable suggestion was skipped due to low confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
awesomeversion/utils/regex.py
Outdated
r"([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*" # Main segment | ||
r"([-_\.]?(alpha|beta|c|pre|preview|a|b|rc)(0|[1-9][0-9]*))?" # Pre-release segment | ||
r"([-_\.]?(post|r|rev)(0|[1-9][0-9]*))?" # Post-release segment | ||
r"([-_\.]?(d|dev)(0|[1-9][0-9]*))?" # Development release segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure regex pattern does not allow multiple consecutive separators.
The updated regex pattern supports additional separators (-
, _
, .
) between different segments of version numbers. However, the pattern seems to allow multiple consecutive separators, which can lead to incorrect parsing of version strings. For instance, 1.1--dev1
would incorrectly be considered valid.
To address this, consider modifying the regex to disallow consecutive separators by ensuring that separators can only appear once between digits and letters.
- r"([-_\.]?(alpha|beta|c|pre|preview|a|b|rc)(0|[1-9][0-9]*))?"
- r"([-_\.]?(post|r|rev)(0|[1-9][0-9]*))?"
- r"([-_\.]?(d|dev)(0|[1-9][0-9]*))?"
+ r"([-_\.]?)(alpha|beta|c|pre|preview|a|b|rc)(0|[1-9][0-9]*))"
+ r"([-_\.]?)(post|r|rev)(0|[1-9][0-9]*))"
+ r"([-_\.]?)(d|dev)(0|[1-9][0-9]*))"
Committable suggestion was skipped due to low confidence.
Proposed change
Extends the PEP440 regex to allow for
-
and_
as pre-release separators.Doc: https://peps.python.org/pep-0440/#pre-release-separators
Type of change
Additional information
Checklist
make lint
)