molass package

molass package#

get_version(toml_only=False)#

Retrieve the version of the package from pyproject.toml or importlib.metadata.

This function prioritizes reading the version from pyproject.toml to ensure that the local repository version is used during development or testing. If pyproject.toml is not found, it falls back to using importlib.metadata to retrieve the version of the installed package.

Parameters:#

toml_only: bool, optional

If True, the function strictly reads the version from pyproject.toml. This is crucial to avoid confusion about the version being used, which can lead to significant time loss during testing. (confusion about the local repository versus the installed).

If False, the function attempts to read the version from pyproject.toml first. If pyproject.toml does not exist, which means you are using the installed package, it falls back to using importlib.metadata to retrieve this version.

Raises:#

AssertionError:

If toml_only is True but pyproject.toml is not found. This ensures that the function behaves predictably in cases where the local repository is not available.

This docstring was improved in collaboration with GitHub Copilot.

Submodules#