Skip to content

Conversation

@ludeeus
Copy link
Owner

@ludeeus ludeeus commented Jun 24, 2024

Proposed change

PEP440 allows for local versions, this is now added here as well.

Doc: https://peps.python.org/pep-0440/#local-version-identifiers

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionalit)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass.
  • There is no commented out code in this PR.
  • The code has been formatted using Black (make lint)
  • Tests have been added to verify that the new code works.

@coderabbitai
Copy link

coderabbitai bot commented Jun 24, 2024

Walkthrough

Walkthrough

The recent changes introduce enhanced functionality for parsing and handling PEP 440 compliant version strings. This includes the addition of new regex patterns for local versions, updated test cases, and new version fields to manage detailed version information. Changes also involve new classes and functions to handle these version strings more effectively and with greater granularity.

Changes

Files Change Summary
awesomeversion/utils/regex.py Introduced a new regex pattern for local version segment in version parsing logic.
tests/snapshots/PEP 440/1.0+local.1.2.3.json Added fields to the version structure for PEP 440 compliance, including major, minor, micro, patch, and modifiers.
tests/snapshots/PEP 440/1.0rc1+local.1.2.3.json Introduced logic for parsing PEP 440 version strings with new fields and functions for version extraction.
tests/test_strategy.py Added version string "1.0+local.1.2.3" to version strings list in test case.
tests/test_versions.py Introduced additional version strings with local identifiers appended to existing versions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VersionParser
    participant RegexUtils
    participant VersionInfo

    User->>VersionParser: parse_version("1.0+local.1.2.3")
    VersionParser->>RegexUtils: match_pattern("1.0+local.1.2.3")
    RegexUtils-->>VersionParser: matched_groups
    VersionParser->>VersionInfo: new VersionInfo(matched_groups)
    VersionInfo-->>VersionParser: parsed_version
    VersionParser-->>User: return parsed_version
Loading
sequenceDiagram
    participant User
    participant VersionParser
    participant PEP440Version
    participant VersionInfo

    User->>VersionParser: parse_pep440_version_string("1.0rc1+local.1.2.3")
    VersionParser->>PEP440Version: new PEP440Version("1.0rc1+local.1.2.3")
    PEP440Version-->>VersionParser: extracted_version_info
    VersionParser->>VersionInfo: new VersionInfo(extracted_version_info)
    VersionInfo-->>VersionParser: parsed_version
    VersionParser-->>User: return parsed_version
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between e01c153 and 9a562c6.

Files selected for processing (5)
  • awesomeversion/utils/regex.py (1 hunks)
  • tests/snapshots/PEP 440/1.0+local.1.2.3.json (1 hunks)
  • tests/snapshots/PEP 440/1.0rc1+local.1.2.3.json (1 hunks)
  • tests/test_strategy.py (1 hunks)
  • tests/test_versions.py (2 hunks)
Additional context used
Ruff
tests/test_strategy.py

11-11: Wrong type passed to first argument of @pytest.mark.parametrize; expected tuple (PT006)

Use a tuple for the first argument


104-104: Use of assert detected (S101)


112-112: Use of assert detected (S101)


113-113: Use of assert detected (S101)

tests/test_versions.py

200-200: Use of assert detected (S101)

Additional comments not posted (6)
tests/snapshots/PEP 440/1.0+local.1.2.3.json (1)

1-19: Snapshot file looks well-structured for PEP 440 compliance.

The JSON structure correctly represents the various components of a version string as per PEP 440 standards, including local version segments.

tests/snapshots/PEP 440/1.0rc1+local.1.2.3.json (1)

1-19: Snapshot file correctly represents PEP 440 version with release candidate and local segments.

This JSON file accurately describes a PEP 440 compliant version string that includes both a release candidate and local version segments.

awesomeversion/utils/regex.py (1)

23-23: Regex pattern for local version segments added.

The addition of the local version segment to the PEP 440 regex pattern is correctly formatted and follows the standard.

tests/test_strategy.py (1)

43-43: New PEP 440 test cases with local version segments added.

The addition of test cases for PEP 440 local version segments is a crucial part of validating the new functionality.

tests/test_versions.py (2)

Line range hint 49-62: Verify the inclusion of PEP440 local version strings in test cases.

The newly added test versions "1.0+local.1.2.3" and "1.0rc1+local.1.2.3" align with the PR's objectives to support PEP440 local versions. Ensure these versions are correctly parsed and handled in the related parsing functions.


Line range hint 200-200: Note on the use of assert in tests.

The use of assert here is appropriate for testing purposes, ensuring that there are no duplicates in the TEST_VERSIONs list. However, be cautious with the use of assert in production code, as it can be disabled with Python's optimization flags.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ludeeus
Copy link
Owner Author

ludeeus commented Jun 24, 2024

@coderabbitai review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range comments (2)
tests/test_strategy.py (2)

Line range hint 11-11: Correct the type for @pytest.mark.parametrize.

The first argument should be a tuple to match the expected type.

- @pytest.mark.parametrize(
+ @pytest.mark.parametrize((

Line range hint 104-113: Usage of assert in tests should be handled cautiously.

Although using assert directly in tests is common, consider wrapping these in a more descriptive testing framework or function for better error messaging and maintainability.

@ludeeus ludeeus merged commit 38e3246 into main Jun 24, 2024
@ludeeus ludeeus deleted the 440-local branch June 24, 2024 09:01
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