From 3c9116d7605f6c52b4217e9613e76e71866caabc Mon Sep 17 00:00:00 2001 From: Javier Lopez Lorente Date: Tue, 3 Nov 2026 15:01:49 +0100 Subject: [PATCH] Expose __released__ at package top level --- CHANGELOG.md | 11 +++++++++-- solarfarmer/__init__.py | 3 ++- tests/test_version.py | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 339a52f..c980bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- `__released__` now reports the release date of installed wheels instead of `"unreleased"` or the tag + date of whichever git repository the user's working directory belonged to. It is also exposed at the + package top level, like `solarfarmer.__version__`; previously `import solarfarmer as sf; sf.__released__` + raised `AttributeError`. + ## [0.8.0] - 2026-10-28 ### Added @@ -37,8 +46,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 non-ASCII characters (e.g. in module or inverter file names) instead of escaping them as `\uXXXX`. - `solarfarmer.__version__` no longer returns `"unknown"` for pip-installed packages; it now reads the metadata of the `dnv-solarfarmer` distribution. -- `__released__` now reports the release date of installed wheels instead of `"unreleased"` or the tag - date of whichever git repository the user's working directory belonged to. ### Removed diff --git a/solarfarmer/__init__.py b/solarfarmer/__init__.py index dd5df55..13c525c 100644 --- a/solarfarmer/__init__.py +++ b/solarfarmer/__init__.py @@ -1,5 +1,5 @@ from . import custom_rotations, rcl -from .__version__ import __version__ +from .__version__ import __released__, __version__ from .api import SolarFarmerAPIError from .config import ( ABOUT_ENDPOINT_URL, @@ -108,6 +108,7 @@ ) __all__ = [ + "__released__", "__version__", "custom_rotations", "custom_rotations_csv_to_protobuf", diff --git a/tests/test_version.py b/tests/test_version.py index cbc7eec..22f85d0 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -9,6 +9,15 @@ def test_version_format(self): assert re.match(r"^\d+\.\d+\.\d+", __version__) or __version__ == "unknown" +class TestTopLevelExports: + def test_version_and_released_exposed_on_package(self): + """Both attributes are reachable as ``solarfarmer.``, not only via the submodule.""" + import solarfarmer as sf + + assert sf.__version__ == __version__ + assert sf.__released__ == __released__ + + class TestReleasedDate: def test_released_format(self): """Released is either an ISO date (YYYY-MM-DD) or 'unreleased'."""