Skip to content
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

Reset version and use version from metadata #48

Merged
merged 3 commits into from
May 23, 2024
Merged

Reset version and use version from metadata #48

merged 3 commits into from
May 23, 2024

Conversation

madeddie
Copy link
Owner

@madeddie madeddie commented May 23, 2024

PR Type

enhancement, configuration changes


Description

  • Imported importlib.metadata in src/tyora/__init__.py to fetch the version from pyproject.toml.
  • Added __version__ variable in src/tyora/__init__.py to store the version.
  • Updated the argument parser in src/tyora/__init__.py to include a --version argument.
  • Reset the project version to 0.0.1 in pyproject.toml.

Changes walkthrough 📝

Relevant files
Enhancement
__init__.py
Fetch version from metadata and add --version argument     

src/tyora/init.py

  • Imported importlib.metadata to fetch the version.
  • Added __version__ variable to store the version from metadata.
  • Added --version argument to the argument parser.
  • +5/-0     
    Configuration changes
    pyproject.toml
    Reset project version to 0.0.1                                                     

    pyproject.toml

    • Reset version to 0.0.1.
    +1/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Summary by CodeRabbit

    • New Features

      • Added a command-line argument to display the tool's version information.
    • Changes

      • Downgraded the project version from "0.1.0" to "0.0.1".

    Copy link
    Contributor

    coderabbitai bot commented May 23, 2024

    Walkthrough

    The recent update involves downgrading the version of the "tyora" project from "0.1.0" to "0.0.1" in pyproject.toml. The __init__.py file in the tyora module now utilizes importlib.metadata to manage the version attribute and introduces a new command-line option for displaying version information.

    Changes

    File Change Summary
    pyproject.toml Downgraded version from 0.1.0 to 0.0.1.
    src/tyora/__init__.py Imported importlib.metadata, set __version__, added version argument.

    Poem

    Amidst the code's silent hum,
    Version numbers now softly strum.
    From one-oh to naught-oh-one,
    A tale of change has just begun.
    Metadata's whisper, a subtle trace,
    Aligns version numbers in their place.
    🐇✨


    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:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>.
      • Generate unit testing code for this file.
      • Open a follow-up GitHub issue for this discussion.
    • 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.

    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 a review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @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.

    Copy link

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are straightforward and limited to a few files, involving basic functionality enhancements and version reset.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: The use of importlib.metadata.version("tyora") assumes that the package is always installed and the metadata is available, which might not be the case in a development environment or if the package name in the metadata does not match.

    🔒 Security concerns

    No

    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add error handling for the version retrieval to avoid potential runtime exceptions

    Consider adding a try-except block around the importlib.metadata.version("tyora") call to
    handle potential exceptions, such as when the package name is not found or metadata is
    missing.

    src/tyora/init.py [19]

    -__version__ = importlib.metadata.version("tyora")
    +try:
    +    __version__ = importlib.metadata.version("tyora")
    +except importlib.metadata.PackageNotFoundError:
    +    __version__ = "unknown"
     
    Suggestion importance[1-10]: 8

    Why: This suggestion is crucial as it addresses potential runtime exceptions that could occur if the package metadata is not found, improving the robustness of the code.

    8
    Maintainability
    Define the version string in a separate variable for better maintainability

    To improve maintainability, consider defining the version string in a separate variable
    before using it in the parser.add_argument call. This makes it easier to update or reuse
    the version string in the future.

    src/tyora/init.py [107-109]

    +version_string = f"%(prog)s {__version__}"
     parser.add_argument(
    -    "--version", action="version", version=f"%(prog)s {__version__}"
    +    "--version", action="version", version=version_string
     )
     
    Suggestion importance[1-10]: 6

    Why: The suggestion enhances maintainability by isolating the version string, making it easier to manage and update. However, it's a moderate improvement and not critical.

    6

    Copy link
    Contributor

    @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: 1

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between 1f9acc9 and de39f59.
    Files selected for processing (2)
    • pyproject.toml (1 hunks)
    • src/tyora/init.py (3 hunks)
    Files skipped from review due to trivial changes (1)
    • pyproject.toml
    Additional comments not posted (1)
    src/tyora/__init__.py (1)

    2-2: Import of importlib.metadata and dynamic version setting are correctly implemented.

    Also applies to: 19-19

    Verification successful

    The package name 'tyora' is correctly set in the metadata, confirming that the dynamic version setting using importlib.metadata is correctly implemented.

    • pyproject.toml: name = "tyora"
    Scripts Executed

    The following scripts were executed for the analysis:


    Script:

    #!/bin/bash
    # Description: Verify that the package name 'tyora' is correctly set in the metadata.
    
    # Test: Search for the package name in pyproject.toml. Expect: 'tyora' should be present.
    rg --type toml 'name = "tyora"' pyproject.toml
    

    Length of output: 63

    src/tyora/__init__.py Show resolved Hide resolved
    Copy link
    Contributor

    @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

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between de39f59 and 1ee4a3e.
    Files selected for processing (1)
    • src/tyora/init.py (3 hunks)
    Files skipped from review as they are similar to previous changes (1)
    • src/tyora/init.py

    @madeddie madeddie merged commit a1f79e5 into main May 23, 2024
    4 checks passed
    @madeddie madeddie deleted the reset_version branch May 23, 2024 19:15
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant