dextrace -V reports stale hardcoded version
- Dominant language
- Python
- Stars
- 4
- Forks
- 3
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 2
Description
## 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
```python
# 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
```python
# 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` |
Contributor guide
Assessment
This issue has not been assessed yet.