Skip to content

Conversation

@misrasaurabh1
Copy link
Contributor

@misrasaurabh1 misrasaurabh1 commented Jul 1, 2025

User description

update the release scripts


PR Type

Enhancement


Description

  • Bump package version to 0.14.7, remove tuple

  • Simplify telemetry: drop cli_version_tuple

  • Refactor license script to use string version

  • Migrate build config to Hatch version hook


Changes diagram

flowchart LR
  A["codeflash/version.py"]
  B["codeflash/telemetry/posthog_cf.py"]
  C["codeflash/update_license_version.py"]
  D["pyproject.toml"]
  A -- "import __version__" --> B
  A -- "import __version__" --> C
  D -- "hatch build hook" --> A
Loading

Changes walkthrough 📝

Relevant files
Enhancement
posthog_cf.py
Simplify telemetry version properties                                       

codeflash/telemetry/posthog_cf.py

  • Removed __version_tuple__ import
  • Dropped cli_version_tuple from telemetry properties
  • +2/-2     
    update_license_version.py
    Refactor license version parsing                                                 

    codeflash/update_license_version.py

  • Switched from __version_tuple__ to __version__
  • Updated major_minor_version to split string
  • +3/-3     
    Configuration changes
    version.py
    Update package version placeholder                                             

    codeflash/version.py

  • Bumped __version__ to "0.14.7"
  • Removed obsolete __version_tuple__
  • +1/-2     
    pyproject.toml
    Migrate build hook configuration                                                 

    pyproject.toml

  • Replaced uv-dynamic-versioning with hatch.build.hooks.version
  • Updated version template in build config
  • +9/-9     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • update the release scripts
    @misrasaurabh1 misrasaurabh1 requested a review from KRRT7 July 1, 2025 00:56
    @github-actions
    Copy link

    github-actions bot commented Jul 1, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Telemetry Payload

    The removal of cli_version_tuple and change to only include cli_version may break downstream analytics or dashboards expecting a numeric tuple; verify compatibility with existing metrics consumers.

    from codeflash.version import __version__
    
    _posthog = None
    
    
    def initialize_posthog(enabled: bool = True) -> None:  # noqa: FBT001, FBT002
        """Enable or disable PostHog.
    
        :param enabled: Whether to enable PostHog.
        """
        if not enabled:
            return
    
        global _posthog  # noqa: PLW0603
        _posthog = Posthog(project_api_key="phc_aUO790jHd7z1SXwsYCz8dRApxueplZlZWeDSpKc5hol", host="https://us.posthog.com")  # type: ignore  # noqa: PGH003
        _posthog.log.setLevel(logging.CRITICAL)  # Suppress PostHog logging
        ph("cli-telemetry-enabled")
    
    
    def ph(event: str, properties: dict[str, Any] | None = None) -> None:
        """Log an event to PostHog.
    
        :param event: The name of the event.
        :param properties: A dictionary of properties to attach to the event.
        """
        if _posthog is None:
            return
    
        properties = properties or {}
        properties.update({"cli_version": __version__})
    Version Parsing

    Using __version__.split('.') assumes a three-component numeric format; ensure this handles pre-release or unexpected version strings correctly and won’t crash on different formats.

    version = __version__
    
    # Use the major and minor version components from the version tuple
    major_minor_version = ".".join(map(str, version.split(".")[:2]))
    Build Hook

    The custom hook for update_license_version.py is commented out; confirm that license updates are still applied in the build pipeline or re-enable the hook.

    #[tool.hatch.build.hooks.custom]
    #path = "codeflash/update_license_version.py"

    @github-actions
    Copy link

    github-actions bot commented Jul 1, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Broaden version regex

    Broaden the regular expression to match any major version number instead of only
    0.x, ensuring it works correctly for versions beyond 0.

    codeflash/update_license_version.py [16]

    -version_pattern = re.compile(r"(Licensed Work:\s+Codeflash Client version\s+)(0\.\d+)(\.x)")
    +version_pattern = re.compile(r"(Licensed Work:\s+Codeflash Client version\s+)(\d+\.\d+)(\.x)")
    Suggestion importance[1-10]: 7

    __

    Why: Expanding the regex to (\d+\.\d+) future-proofs the version_pattern beyond 0.x, which is a useful enhancement as the project version evolves.

    Medium
    Enable license update hook

    Uncomment and enable this custom build hook so that the update_license_version.py
    script runs automatically during the build process.

    pyproject.toml [278-279]

    -#[tool.hatch.build.hooks.custom]
    -#path = "codeflash/update_license_version.py"
    +[tool.hatch.build.hooks.custom]
    +path = "codeflash/update_license_version.py"
    Suggestion importance[1-10]: 5

    __

    Why: Re-enabling the [tool.hatch.build.hooks.custom] section automates the license update script execution, but it may be intentionally disabled so it’s a moderate suggestion.

    Low
    Possible issue
    Validate version format

    Add validation for the version string format before splitting to prevent runtime
    errors if the version deviates from the expected numeric pattern.

    codeflash/update_license_version.py [10-13]

     version = __version__
    -major_minor_version = ".".join(map(str, version.split(".")[:2]))
    +if not re.match(r"^\d+(\.\d+)*$", version):
    +    raise ValueError(f"Invalid version format: {version}")
    +major_minor_version = ".".join(version.split(".")[:2])
    Suggestion importance[1-10]: 6

    __

    Why: Adding a regex check before splitting the version string __version__ avoids potential runtime errors if the format changes, improving robustness modestly.

    Low
    Use absolute version import

    Use absolute imports to avoid relative import issues when running the script
    directly, ensuring the module is always found in the package context.

    codeflash/update_license_version.py [5]

    -from .version import __version__
    +from codeflash.version import __version__
    Suggestion importance[1-10]: 5

    __

    Why: The absolute import from codeflash.version import __version__ prevents relative import issues when running as a script, but it’s a minor change affecting only module resolution.

    Low

    @misrasaurabh1 misrasaurabh1 enabled auto-merge July 1, 2025 00:59
    @misrasaurabh1 misrasaurabh1 merged commit fd9781d into main Jul 1, 2025
    17 checks passed
    @KRRT7 KRRT7 deleted the release/v0.14.7 branch July 1, 2025 03:18
    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