Skip to content

Commit 0cb5f13

Browse files
committed
Remove defaults and instead use BaseConfig-inherited values
1 parent 15a4cbc commit 0cb5f13

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

exasol/toolbox/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class BaseConfig(BaseModel):
5353

5454
@computed_field # type: ignore[misc]
5555
@property
56-
def min_py_version(self) -> str:
56+
def minimum_python_version(self) -> str:
5757
"""
5858
Minimum Python version declared from the `python_versions` list
5959

exasol/toolbox/nox/_artifacts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import nox
1313
from nox import Session
1414

15-
from exasol.toolbox.nox._shared import MINIMUM_PYTHON_VERSION
15+
from exasol.toolbox.nox._shared import check_for_config_attribute
1616
from noxconfig import (
1717
PROJECT_CONFIG,
1818
Config,
@@ -159,8 +159,8 @@ def copy_artifacts(session: Session) -> None:
159159

160160

161161
def _python_version_suffix() -> str:
162-
versions = getattr(PROJECT_CONFIG, "python_versions", None)
163-
pivot = versions[0] if versions else MINIMUM_PYTHON_VERSION
162+
check_for_config_attribute(PROJECT_CONFIG, "minimum_python_version")
163+
pivot = PROJECT_CONFIG.minimum_python_version
164164
return f"-python{pivot}"
165165

166166

exasol/toolbox/nox/_ci.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import nox
55
from nox import Session
66

7+
from exasol.toolbox.nox._shared import check_for_config_attribute
78
from noxconfig import (
89
PROJECT_CONFIG,
910
Config,
@@ -12,17 +13,6 @@
1213
_log = logging.getLogger(__name__)
1314

1415

15-
def check_for_config_attribute(config: Config, attribute: str):
16-
if not hasattr(config, attribute):
17-
raise AttributeError(
18-
"in the noxconfig.py file, the class Config should inherit "
19-
"from `exasol.toolbox.config.BaseConfig`. This is used to "
20-
f"set the default `{attribute}`. If the allowed "
21-
f"`{attribute} needs to differ in your project, you can "
22-
"set it in the PROJECT_CONFIG statement."
23-
)
24-
25-
2616
def _python_matrix(config: Config):
2717
check_for_config_attribute(config=config, attribute="python_versions")
2818
return {"python-version": config.python_versions}

exasol/toolbox/nox/_shared.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,24 @@
1515

1616
from nox import Session
1717

18-
from noxconfig import PROJECT_CONFIG
18+
from noxconfig import (
19+
PROJECT_CONFIG,
20+
Config,
21+
)
1922

2023
DEFAULT_PATH_FILTERS = {"dist", ".eggs", "venv", ".poetry"}
2124
DOCS_OUTPUT_DIR = ".html-documentation"
2225

23-
MINIMUM_PYTHON_VERSION = "3.9"
26+
27+
def check_for_config_attribute(config: Config, attribute: str):
28+
if not hasattr(config, attribute):
29+
raise AttributeError(
30+
"in the noxconfig.py file, the class Config should inherit "
31+
"from `exasol.toolbox.config.BaseConfig`. This is used to "
32+
f"set the default `{attribute}`. If the allowed "
33+
f"`{attribute} needs to differ in your project and is an "
34+
"input parameter (not property), you can set it in the PROJECT_CONFIG statement."
35+
)
2436

2537

2638
class Mode(Enum):

test/unit/config_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ def test_expansion_validation_fails_for_invalid_version():
5959

6060
def test_min_py_version():
6161
conf = BaseConfig(python_versions=("5.5.5", "1.1.1", "9.9.9"))
62-
assert conf.min_py_version == "1.1.1"
62+
assert conf.minimum_python_version == "1.1.1"

0 commit comments

Comments
 (0)