Skip to content

Commit 15a4cbc

Browse files
committed
Remove defaults and add exception so that users switch to BaseConfig where exasol_versions & python_versions controlled
This will only work in cases where these have not been set for a project & are used.
1 parent ff3c618 commit 15a4cbc

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

exasol/toolbox/nox/_ci.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,26 @@
1111

1212
_log = logging.getLogger(__name__)
1313

14-
_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
15-
_EXASOL_VERSIONS = ["7.1.9"]
14+
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+
)
1624

1725

1826
def _python_matrix(config: Config):
19-
attr = "python_versions"
20-
python_versions = getattr(config, attr, _PYTHON_VERSIONS)
21-
if not hasattr(config, attr):
22-
_log.warning(
23-
"Config does not contain '%s' setting. Using default: %s",
24-
attr,
25-
_PYTHON_VERSIONS,
26-
)
27-
return {"python-version": python_versions}
27+
check_for_config_attribute(config=config, attribute="python_versions")
28+
return {"python-version": config.python_versions}
2829

2930

3031
def _exasol_matrix(config: Config):
31-
attr = "exasol_versions"
32-
exasol_versions = getattr(config, attr, _EXASOL_VERSIONS)
33-
if not hasattr(config, attr):
34-
_log.warning(
35-
"Config does not contain '%s' setting. Using default: %s",
36-
attr,
37-
_EXASOL_VERSIONS,
38-
)
39-
return {"exasol-version": exasol_versions}
32+
check_for_config_attribute(config=config, attribute="exasol_versions")
33+
return {"exasol-version": config.exasol_versions}
4034

4135

4236
@nox.session(name="matrix:python", python=False)

0 commit comments

Comments
 (0)