|
11 | 11 |
|
12 | 12 | _log = logging.getLogger(__name__) |
13 | 13 |
|
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 | + ) |
16 | 24 |
|
17 | 25 |
|
18 | 26 | 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} |
28 | 29 |
|
29 | 30 |
|
30 | 31 | 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} |
40 | 34 |
|
41 | 35 |
|
42 | 36 | @nox.session(name="matrix:python", python=False) |
|
0 commit comments