FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit d511702e authored by E. Evstafiev's avatar E. Evstafiev :bulb:
Browse files

refactor(project): move `__version__` and `_get_version` to `_version.py` to avoid circular imports

parent adb0fbfb
No related branches found
No related tags found
1 merge request!52Resolve "Ensure OpenAPI specification is generated correctly"
import functools
import tomllib
from pathlib import Path
@functools.cache
def get_version():
"""
Retrieves the project's version number from pyproject.toml.
This function is intended to ensure that the version is obtained from a
single source of truth (pyproject.toml), avoiding duplication.
Returns:
str: The version number as defined in pyproject.toml (e.g. "0.1.0").
Raises:
FileNotFoundError: If pyproject.toml cannot be found at the expected location.
"""
# Navigate to the pyproject.toml file located in the project root
pyproject_path = Path(__file__).resolve().parents[1] / "pyproject.toml"
# Open and parse the pyproject.toml file using tomllib
with pyproject_path.open("rb") as f:
pyproject_data = tomllib.load(f)
# Return the version number from the [tool.poetry] section
return pyproject_data["tool"]["poetry"]["version"]
# Define the __version__ attribute for the project
__version__ = get_version()
import functools
import os
import sys
import tomllib
from datetime import timedelta
from pathlib import Path
import externalsettings
import structlog
from api.versions import AVAILABLE_VERSIONS
@functools.cache
def get_version():
"""
Retrieves the project's version number from pyproject.toml.
This function is intended to ensure that the version is obtained from a
single source of truth (pyproject.toml), avoiding duplication.
Returns:
str: The version number as defined in pyproject.toml (e.g. "0.1.0").
Raises:
FileNotFoundError: If pyproject.toml cannot be found at the expected location.
"""
# Navigate to the pyproject.toml file located in the project root
pyproject_path = Path(__file__).resolve().parents[2] / "pyproject.toml"
# Open and parse the pyproject.toml file using tomllib
with pyproject_path.open("rb") as f:
pyproject_data = tomllib.load(f)
# Return the version number from the [tool.poetry] section
return pyproject_data["tool"]["poetry"]["version"]
# Define the __version__ attribute for the project
__version__ = get_version()
from .._version import __version__
# By default, make use of connection pooling for the default database and use the Postgres engine.
DATABASES = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment