Skip to content

dextrace -V reports stale hardcoded version #13

Description

@haeter525

Summary

The version string is duplicated in two places that can drift apart: pyproject.toml (package metadata) and src/dextrace/version.py (hardcoded, used by the CLI's --version). In the 26.6.1 release these disagree — pip show dextrace reports 26.6.1 while dextrace -V prints DexTrace 25.10.1. A single source of truth avoids this class of bug.

If you want to read the version of a package, the recommended way is importlib.metadata.version("name").
https://docs.python.org/3/library/importlib.metadata.html#distribution-versions

Root cause

# src/dextrace/version.py
__version__ = "25.10.1"

The bump to 26.6.1 was applied to pyproject.toml but not to this hardcoded literal, so dextrace -V (which reads __version__) shipped the old number.

Fix

# src/dextrace/version.py
from importlib.metadata import version, PackageNotFoundError

try:
    __version__ = version("dextrace")
except PackageNotFoundError:  # running from source tree without an install
    __version__ = "0.0.0+dev"

pyproject.toml becomes the only place a version is declared; the CLI always matches the installed package metadata.

Affected locations

File Line(s) Context
src/dextrace/version.py 5 Hardcoded __version__ literal
src/dextrace/cli/main.py 8, 26 Imports __version__, uses it for --version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions