Skip to content

single source of truth for version management#231

Merged
ParticularlyPythonicBS merged 1 commit intounstablefrom
maintainance/version_info
Dec 2, 2025
Merged

single source of truth for version management#231
ParticularlyPythonicBS merged 1 commit intounstablefrom
maintainance/version_info

Conversation

@ParticularlyPythonicBS
Copy link
Member

@ParticularlyPythonicBS ParticularlyPythonicBS commented Dec 1, 2025

uses the standardized __about__ to store metadata instead of version_data and uses it as a single source of versioning info throughout the codebase

Summary by CodeRabbit

  • Chores
    • Switched to dynamic, centralized versioning so the project derives its version at runtime.
    • Consolidated version/constants into a single canonical source used across the package and CLI.
  • Documentation
    • Docs now use the unified runtime version for release and version displays.

✏️ Tip: You can customize this high-level summary in your review settings.

@ParticularlyPythonicBS ParticularlyPythonicBS added the Maintenance Code quality fixes and deprecation management label Dec 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 1, 2025

Walkthrough

Centralizes runtime version metadata in temoa/__about__.py, moves consumers to import from that module, removes version constants from temoa/version_information.py, and enables Hatch dynamic versioning in pyproject.toml to read the version from temoa/__about__.py.

Changes

Cohort / File(s) Summary
Version source & runtime parsing
temoa/__about__.py
Adds __version__ string, runtime parsing to derive TEMOA_MAJOR and TEMOA_MINOR, introduces MIN_PYTHON_MAJOR, MIN_PYTHON_MINOR, DB_MAJOR_VERSION, MIN_DB_MINOR_VERSION, and raises on malformed version.
Build configuration
pyproject.toml
Removes static version entry, adds dynamic = ["version"] under [project], and adds [tool.hatch.version] with path = "temoa/__about__.py" to enable Hatch-based dynamic version resolution.
Import updates / consumers
temoa/__init__.py, temoa/_internal/temoa_sequencer.py, temoa/cli.py, docs/source/conf.py
Redirects imports to temoa.__about__ for __version__, TEMOA_MAJOR, TEMOA_MINOR, and other version/minimum constants; CLI and Sphinx conf now use __version__ for display/version fields.
Removed legacy constants
temoa/version_information.py
Removes previously exported constants (TEMOA_MAJOR, TEMOA_MINOR, MIN_PYTHON_MAJOR, MIN_PYTHON_MINOR, DB_MAJOR_VERSION, MIN_DB_MINOR_VERSION).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the version parsing regex covers expected Hatch-generated formats and raises clearly on unexpected values.
  • Confirm all import sites updated to temoa.__about__ resolve (CLI, docs, sequencer) and no residual imports of temoa.version_information remain.
  • Validate Sphinx build and Hatch dynamic version resolution work in CI/build environments.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'single source of truth for version management' accurately and clearly describes the main change—consolidating version information into a single about module.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch maintainance/version_info

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6979ca5 and 6401ee6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • docs/source/conf.py (2 hunks)
  • pyproject.toml (2 hunks)
  • temoa/__about__.py (1 hunks)
  • temoa/__init__.py (1 hunks)
  • temoa/_internal/temoa_sequencer.py (1 hunks)
  • temoa/cli.py (2 hunks)
  • temoa/version_information.py (0 hunks)
💤 Files with no reviewable changes (1)
  • temoa/version_information.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-03T22:55:02.519Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 186
File: temoa/_internal/temoa_sequencer.py:60-63
Timestamp: 2025-11-03T22:55:02.519Z
Learning: In `TemoaSequencer.__init__`, when a `mode_override` is provided, it must be written back to `self.config.scenario_mode` (not just stored in `self.temoa_mode`) because `HybridLoader.create_data_dict()` has strict consistency checks that validate `config.scenario_mode` matches the presence/absence of `myopic_index`. Without this synchronization, MYOPIC mode would fail with a RuntimeError when the loader is instantiated.

Applied to files:

  • temoa/__init__.py
📚 Learning: 2025-10-27T15:53:41.829Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 177
File: temoa/model_checking/commodity_network.py:26-33
Timestamp: 2025-10-27T15:53:41.829Z
Learning: The Temoa project requires Python 3.12 or above as the minimum supported version, so PEP 695 `type` syntax for type aliases is appropriate and preferred over `TypeAlias`.

Applied to files:

  • temoa/__about__.py
🪛 Ruff (0.14.6)
temoa/__about__.py

9-12: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: setup and test (windows-latest, 3.13)
  • GitHub Check: setup and test (macos-latest, 3.12)
  • GitHub Check: setup and test (windows-latest, 3.12)
  • GitHub Check: setup and test (macos-latest, 3.13)
🔇 Additional comments (6)
pyproject.toml (1)

3-3: Dynamic versioning configuration looks consistent with __about__

Using dynamic = ["version"] with [tool.hatch.version] pointing to temoa/__about__.py aligns the build metadata with the new single source of truth; please just confirm a hatch build / install works end-to-end in your environment.

Also applies to: 81-82

temoa/__about__.py (1)

1-24: Robust centralized version/requirements metadata

The regex-based parsing of __version__ into TEMOA_MAJOR/TEMOA_MINOR plus colocating MIN_PYTHON_* and DB_* here cleanly achieves the single-source-of-truth goal; the failure mode on unexpected formats is explicit and appropriate.

temoa/_internal/temoa_sequencer.py (1)

13-18: Sequencer now correctly sources requirements from temoa.__about__

Switching these imports to temoa.__about__ keeps the preflight Python/DB checks behavior the same while honoring the new single source of truth.

temoa/cli.py (1)

15-15: CLI version output now aligned with package __version__

Importing __version__ from temoa.__about__ and printing it in _version_callback makes the CLI report the exact same version as the package metadata, which is desirable with the new central version module.

Also applies to: 106-107

docs/source/conf.py (1)

20-21: Docs now derive short/full versions from canonical __version__

Importing __version__ from temoa.__about__ and using it for Sphinx version/release keeps the documentation in lockstep with the centralized runtime/package version while leaving other metadata sourced from pyproject.toml.

Also applies to: 25-25, 38-41

temoa/__init__.py (1)

11-12: Package-level version exports correctly re-pointed to __about__

Re-exporting TEMOA_MAJOR, TEMOA_MINOR, and __version__ from temoa.__about__ preserves the public API while ensuring everything flows from the new single source of truth.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b539de5 and 0e6a81a.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • pyproject.toml (2 hunks)
  • temoa/__about__.py (1 hunks)
  • temoa/__init__.py (1 hunks)
  • temoa/_internal/temoa_sequencer.py (1 hunks)
  • temoa/cli.py (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-03T22:55:02.519Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 186
File: temoa/_internal/temoa_sequencer.py:60-63
Timestamp: 2025-11-03T22:55:02.519Z
Learning: In `TemoaSequencer.__init__`, when a `mode_override` is provided, it must be written back to `self.config.scenario_mode` (not just stored in `self.temoa_mode`) because `HybridLoader.create_data_dict()` has strict consistency checks that validate `config.scenario_mode` matches the presence/absence of `myopic_index`. Without this synchronization, MYOPIC mode would fail with a RuntimeError when the loader is instantiated.

Applied to files:

  • temoa/__init__.py
📚 Learning: 2025-10-27T15:53:41.829Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 177
File: temoa/model_checking/commodity_network.py:26-33
Timestamp: 2025-10-27T15:53:41.829Z
Learning: The Temoa project requires Python 3.12 or above as the minimum supported version, so PEP 695 `type` syntax for type aliases is appropriate and preferred over `TypeAlias`.

Applied to files:

  • temoa/__about__.py
🔇 Additional comments (4)
pyproject.toml (1)

3-3: Centralized dynamic version configuration looks consistent

Using dynamic = ["version"] and pointing the build backend at temoa/__about__.py cleanly centralizes version metadata and aligns with the single–source‑of‑truth goal. I don’t see issues with this configuration.

Also applies to: 81-82

temoa/cli.py (1)

15-15: Version flag now correctly reflects the centralized package version

Importing __version__ from temoa.__about__ and printing it in _version_callback ties the CLI --version output directly to the single version source, which is exactly what this PR aims for.

Also applies to: 104-108

temoa/_internal/temoa_sequencer.py (1)

13-18: Sequencer preflight checks now read from the unified version metadata

Switching DB_MAJOR_VERSION, MIN_DB_MINOR_VERSION, MIN_PYTHON_MAJOR, and MIN_PYTHON_MINOR to import from temoa.__about__ keeps all version requirements in one place without changing semantics of the checks.

temoa/__init__.py (1)

11-12: Public version exports correctly delegated to temoa.__about__

Importing TEMOA_MAJOR, TEMOA_MINOR, and __version__ from temoa.__about__ while keeping them in __all__ preserves the public API and ensures all consumers see the centralized version metadata.

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/source/conf.py (1)

10-21: Move __version__ import below sys.path setup to avoid doc build import errors

The from temoa.__about__ import __version__ at line 10 runs before the sys.path.insert(...) calls at lines 18-20 that add the repository root to the import path. A sphinx-build run from a fresh checkout without temoa installed will fail because the local temoa package cannot be found.

Reorder the import after sys.path is configured to support both workflows (installed package and in-tree builds):

-import tomlkit
-
-from temoa.__about__ import __version__
+import tomlkit
@@
-# this first import is to provide path the temoa package, which is referenced throughout
-# and must be included separately from path the source files so that it is properly recognized
-sys.path.insert(0, os.path.abspath('../../'))
-# this addition provided direct abbreviated link to the modules in the model
-sys.path.insert(1, os.path.abspath('../../temoa/temoa_model'))
+# this first import is to provide path the temoa package, which is referenced throughout
+# and must be included separately from path the source files so that it is properly recognized
+sys.path.insert(0, os.path.abspath('../../'))
+# this addition provided direct abbreviated link to the modules in the model
+sys.path.insert(1, os.path.abspath('../../temoa/temoa_model'))
+
+from temoa.__about__ import __version__
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e6a81a and 6979ca5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • docs/source/conf.py (3 hunks)
  • pyproject.toml (2 hunks)
  • temoa/__about__.py (1 hunks)
  • temoa/__init__.py (1 hunks)
  • temoa/_internal/temoa_sequencer.py (1 hunks)
  • temoa/cli.py (2 hunks)
  • temoa/version_information.py (0 hunks)
💤 Files with no reviewable changes (1)
  • temoa/version_information.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-27T15:53:41.829Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 177
File: temoa/model_checking/commodity_network.py:26-33
Timestamp: 2025-10-27T15:53:41.829Z
Learning: The Temoa project requires Python 3.12 or above as the minimum supported version, so PEP 695 `type` syntax for type aliases is appropriate and preferred over `TypeAlias`.

Applied to files:

  • temoa/__about__.py
📚 Learning: 2025-11-03T22:55:02.519Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 186
File: temoa/_internal/temoa_sequencer.py:60-63
Timestamp: 2025-11-03T22:55:02.519Z
Learning: In `TemoaSequencer.__init__`, when a `mode_override` is provided, it must be written back to `self.config.scenario_mode` (not just stored in `self.temoa_mode`) because `HybridLoader.create_data_dict()` has strict consistency checks that validate `config.scenario_mode` matches the presence/absence of `myopic_index`. Without this synchronization, MYOPIC mode would fail with a RuntimeError when the loader is instantiated.

Applied to files:

  • temoa/__init__.py
🪛 Ruff (0.14.6)
temoa/__about__.py

9-12: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: setup and test (macos-latest, 3.13)
  • GitHub Check: setup and test (windows-latest, 3.13)
  • GitHub Check: setup and test (macos-latest, 3.12)
🔇 Additional comments (5)
temoa/cli.py (1)

15-15: CLI version display correctly centralized on temoa.__about__.__version__

Importing __version__ from temoa.__about__ and using it directly in _version_callback cleanly aligns the CLI with the new single source of truth, with no functional issues beyond the intended change to show the full version string.

Also applies to: 104-108

pyproject.toml (1)

3-3: Dynamic Hatch-based versioning correctly wired to temoa/__about__.py

Switching [project] to dynamic = ["version"] and pointing [tool.hatch.version].path at temoa/__about__.py is consistent with centralizing __version__ there; this should keep the package metadata, CLI, and docs all in sync off the same value.

Please verify once by building the project with your usual tool (e.g., hatch build or uv build) and confirming that the built wheel/sdist reports the same version as python -c "import temoa; print(temoa.__version__)".

Also applies to: 81-83

temoa/_internal/temoa_sequencer.py (1)

13-18: Sequencer version checks now correctly source constants from temoa.__about__

Importing DB_MAJOR_VERSION, MIN_DB_MINOR_VERSION, MIN_PYTHON_MAJOR, and MIN_PYTHON_MINOR from temoa.__about__ keeps the existing pre-flight checks intact while aligning them with the new single source of truth for version metadata. The surrounding logic in _run_preliminary_checks and build_model remains unchanged and still enforces the same constraints. Based on learnings, the mode_overrideconfig.scenario_mode synchronization is also unaffected by this import swap.

Also applies to: 71-77, 108-110

temoa/__init__.py (1)

11-12: Public version API cleanly re-exported from temoa.__about__

Importing TEMOA_MAJOR, TEMOA_MINOR, and __version__ from temoa.__about__ and keeping them in __all__ preserves the existing temoa.__version__ / TEMOA_MAJOR / TEMOA_MINOR API while routing everything through the new shared metadata module.

Also applies to: 35-62

temoa/__about__.py (1)

1-24: Centralized version metadata and parsing logic look robust and consistent

Defining __version__ here and deriving TEMOA_MAJOR/TEMOA_MINOR via a regex anchored at the numeric X.Y prefix gives a resilient way to handle pre-release/dev suffixes while still producing integer major/minor values. The explicit ValueError on unexpected formats and the consolidated minimum Python/database version constants make this a solid single source of truth for versioning across the project.

@ParticularlyPythonicBS ParticularlyPythonicBS merged commit ec68120 into unstable Dec 2, 2025
9 checks passed
@ParticularlyPythonicBS ParticularlyPythonicBS deleted the maintainance/version_info branch December 2, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance Code quality fixes and deprecation management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant