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

use a more modern package #1355

Merged
merged 2 commits into from
Nov 18, 2024
Merged

use a more modern package #1355

merged 2 commits into from
Nov 18, 2024

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Nov 12, 2024

PR Type

enhancement


Description

  • Replaced the deprecated LooseVersion from distutils.version with parse_version from packaging.version for version parsing.
  • Updated the logic for comparing Bitbucket API versions to ensure compatibility with newer versions.

Changes walkthrough 📝

Relevant files
Enhancement
bitbucket_server_provider.py
Update version parsing and comparison logic                           

pr_agent/git_providers/bitbucket_server_provider.py

  • Replaced LooseVersion with parse_version from packaging.version.
  • Updated version comparison logic for Bitbucket API.
  • +4/-4     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🏅 Score: 95
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling
    The error handling for version parsing could be more specific - currently catches all exceptions which may mask specific issues

    Version Comparison
    Verify that parse_version comparison behavior matches the previous LooseVersion implementation for all version string formats used by Bitbucket

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add validation for empty or invalid version string before parsing to prevent potential runtime errors

    Add error handling for the case when version string from API is invalid or
    malformed. The parse_version() function could raise a ValueError if the version
    string is not in a valid format.

    pr_agent/git_providers/bitbucket_server_provider.py [39-41]

     try:
    -    self.bitbucket_api_version = parse_version(self.bitbucket_client.get("rest/api/1.0/application-properties").get('version'))
    +    version_str = self.bitbucket_client.get("rest/api/1.0/application-properties").get('version')
    +    if not version_str:
    +        raise ValueError("Empty version string")
    +    self.bitbucket_api_version = parse_version(version_str)
     except Exception:
         self.bitbucket_api_version = None
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The suggestion adds important defensive programming by validating the version string before parsing, which can prevent cryptic errors and improve error handling. This is particularly relevant as the version information is critical for determining API behavior.

    7
    • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

    💡 Need additional feedback ? start a PR chat

    @mrT23 mrT23 changed the title use a more modern version use a more modern package Nov 12, 2024
    @mrT23 mrT23 merged commit b1336e7 into main Nov 18, 2024
    2 checks passed
    @mrT23 mrT23 deleted the tr/3-way-prs branch November 18, 2024 15:02
    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Nov 18, 2024

    /improve

    Copy link
    Contributor

    codiumai-pr-agent-pro bot commented Nov 18, 2024

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @mrT23
    Copy link
    Collaborator Author

    mrT23 commented Nov 18, 2024

    /help "Hello, its posible to change the langouge of the comments that the PR Agent Pro creates?"

    Copy link
    Contributor

    Question:

    Hello, its posible to change the langouge of the comments that the PR Agent Pro creates?

    Answer:

    Yes, you can change the language of the comments that Qodo Merge creates by using the extra_instructions configuration parameter. For example:

    [pr_reviewer]
    extra_instructions = "Answer in japanese"

    You can add this configuration either:

    • In a comment when invoking a tool (e.g. /review --pr_reviewer.extra_instructions="Answer in japanese")
    • In a configuration file (.pr_agent.toml)
    • In the wiki configuration page (for Pro users)

    This will work for all the main tools (review, describe, improve).

    Relevant Sources:

    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.

    2 participants