Skip to content

Commit 23103c3

Browse files
committed
Move path-variables to BaseConfig
1 parent 4c2f034 commit 23103c3

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

exasol/toolbox/config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pathlib import Path
12
from typing import (
23
Annotated,
34
)
@@ -46,6 +47,8 @@ class BaseConfig(BaseModel):
4647
runs.
4748
"""
4849

50+
project_name: str = Field(description="Name of the project")
51+
root_path: Path = Field(description="Root directory of the project")
4952
python_versions: tuple[ValidVersionStr, ...] = Field(
5053
default=("3.10", "3.11", "3.12", "3.13", "3.14"),
5154
description="Python versions to use in running CI workflows",
@@ -70,6 +73,14 @@ class BaseConfig(BaseModel):
7073
)
7174
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
7275

76+
@computed_field # type: ignore[misc]
77+
@property
78+
def documentation_path(self) -> Path:
79+
"""
80+
Path where the documentation for the project is stored.
81+
"""
82+
return self.root_path / "doc"
83+
7384
@computed_field # type: ignore[misc]
7485
@property
7586
def minimum_python_version(self) -> str:
@@ -114,3 +125,21 @@ def pyupgrade_argument(self) -> tuple[str, ...]:
114125
version_parts = self.minimum_python_version.split(".")[:2]
115126
version_number = "".join(version_parts)
116127
return (f"--py{version_number}-plus",)
128+
129+
@computed_field # type: ignore[misc]
130+
@property
131+
def source_code_path(self) -> Path:
132+
"""
133+
Path to the source code of the project.
134+
"""
135+
return self.root_path / "exasol" / self.project_name
136+
137+
@computed_field # type: ignore[misc]
138+
@property
139+
def version_filepath(self) -> Path:
140+
"""
141+
Path to the ``version.py`` file included in the project. This is an
142+
autogenerated file which contains the version of the code. It is maintained by
143+
the nox sessions ``version:check`` and ``release:prepare``.
144+
"""
145+
return self.source_code_path / "version.py"

noxconfig.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class Config(BaseConfig):
6060

6161

6262
PROJECT_CONFIG = Config(
63+
root_path=Path(__file__).parent,
64+
project_name="toolbox",
6365
add_to_excluded_python_paths=(
6466
# The cookiecutter placeholders do not work well with checks.
6567
# Instead, the format & linting are checked in the
@@ -72,5 +74,5 @@ class Config(BaseConfig):
7274
create_major_version_tags=True,
7375
# The PTB does not have integration tests run with an Exasol DB,
7476
# so for running in the CI, we take the first element.
75-
exasol_versions=(BaseConfig().exasol_versions[0],),
77+
exasol_versions=("7.1.30",),
7678
)

project-template/{{cookiecutter.repo_name}}/noxconfig.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77

88

99
class Config(BaseConfig):
10-
root: Path = Path(__file__).parent
11-
doc: Path = Path(__file__).parent / "doc"
12-
source: Path = Path("exasol/{{cookiecutter.package_name}}")
13-
version_file: Path = (
14-
Path(__file__).parent
15-
/ "exasol"
16-
/ "{{cookiecutter.package_name}}"
17-
/ "version.py"
18-
)
1910
plugins: Iterable[object] = ()
2011

21-
PROJECT_CONFIG = Config()
12+
PROJECT_CONFIG = Config(
13+
project_name="{{cookiecutter.package_name}}",
14+
root_path=Path(__file__).parent,
15+
)

0 commit comments

Comments
 (0)