Skip to content

Commit 252a45a

Browse files
committed
Move plugins to BaseConfig
1 parent ec1846a commit 252a45a

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

doc/changes/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ and replaces them with `format:fix` and `format:check`.
1010
## Feature
1111

1212
* #614: Replaced `path_filters` with `BaseConfig.add_to_excluded_python_paths` and `BaseConfig.excluded_python_paths`
13+
* #626: Moved `plugins` into `BaseConfig`

doc/user_guide/customization.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,15 @@ Plugin Registration
6565

6666
Once the plugin class has been defined, it must be registered in the Nox configuration. This is done by adding the class to the `plugins` list within the `Config` data class.
6767

68-
In the Nox `Config` data class, you should amend the `plugins` list to include the new plugin:
68+
In the Nox `PROJECT_CONFIG`, you should amend the `plugins` list to include the new plugin:
6969

7070
.. code-block:: python
7171
72-
@dataclass(frozen=True)
73-
class Config:
74-
"""Project-specific configuration used by Nox infrastructure."""
75-
# ... other configuration attributes ...
72+
from exasol.toolbox.config import BaseConfig
7673
77-
plugins = [UpdateTemplates] # register the plugin
74+
PROJECT_CONFIG = BaseConfig(
75+
plugins=(UpdateTemplates,), # register the plugin
76+
)
7877
7978
When Nox runs, it will instantiate `UpdateTemplates` with no arguments and integrate the hooks defined by the plugin into the execution lifecycle. All registered plugins’ hooks are called at their designated points in the Nox workflow.
8079

doc/user_guide/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ example shown below.
9191

9292
.. note::
9393

94-
For further details on plugins, see the customization section.
94+
For further details on plugins, see :ref:`plugins` in the Customization section.
9595

9696
.. collapse:: noxconfig.py
9797

exasol/toolbox/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ class BaseConfig(BaseModel):
6868
`exasol.toolbox.config.DEFAULT_EXCLUDED_PATHS`.
6969
""",
7070
)
71+
plugins: tuple[object, ...] = Field(
72+
default=(),
73+
description="""
74+
This is used to provide hooks to extend one or more of the Nox tasks provided
75+
by the python-toolbox. As described on the plugins pages:
76+
- https://exasol.github.io/python-toolbox/main/user_guide/customization.html#plugins
77+
- https://exasol.github.io/python-toolbox/main/developer_guide/plugins.html,
78+
possible plugin options are defined in the `exasol.toolbox.nox.plugins`
79+
namespace.
80+
""",
81+
)
7182
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
7283

7384
@computed_field # type: ignore[misc]

noxconfig.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Iterable
65
from pathlib import Path
76

87
from exasol.toolbox.config import BaseConfig
@@ -56,7 +55,6 @@ class Config(BaseConfig):
5655
source: Path = Path("exasol/toolbox")
5756
importlinter: Path = Path(__file__).parent / ".import_linter_config"
5857
version_file: Path = Path(__file__).parent / "exasol" / "toolbox" / "version.py"
59-
plugins: Iterable[object] = (UpdateTemplates,)
6058

6159

6260
PROJECT_CONFIG = Config(
@@ -73,4 +71,5 @@ class Config(BaseConfig):
7371
# The PTB does not have integration tests run with an Exasol DB,
7472
# so for running in the CI, we take the first element.
7573
exasol_versions=(BaseConfig().exasol_versions[0],),
74+
plugins=(UpdateTemplates,),
7675
)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ class Config(BaseConfig):
1616
/ "{{cookiecutter.package_name}}"
1717
/ "version.py"
1818
)
19-
plugins: Iterable[object] = ()
2019

2120
PROJECT_CONFIG = Config()

0 commit comments

Comments
 (0)