Skip to content

Commit 1aec65f

Browse files
committed
Rename to plugins_for_nox_sessions and require as BaseConfig should be used at this point
1 parent fcff13d commit 1aec65f

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

doc/changes/unreleased.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +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: Replaced `plugins` with `BaseConfig.nox_task_plugins`
13+
* #626: Replaced `plugins` with `BaseConfig.plugins_for_nox_sessions`

doc/user_guide/customization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ 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 `PROJECT_CONFIG`, you should amend the `nox_task_plugins` tuple to include the new plugin:
68+
In the Nox `PROJECT_CONFIG`, you should amend the `plugins_for_nox_sessions` tuple to include the new plugin:
6969

7070
.. code-block:: python
7171
7272
from exasol.toolbox.config import BaseConfig
7373
7474
PROJECT_CONFIG = BaseConfig(
75-
nox_task_plugins=(UpdateTemplates,), # register the plugin
75+
plugins_for_nox_sessions=(UpdateTemplates,), # register the plugin
7676
)
7777
7878
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.

exasol/toolbox/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ class BaseConfig(BaseModel):
9595
`exasol.toolbox.config.DEFAULT_EXCLUDED_PATHS`.
9696
""",
9797
)
98-
nox_task_plugins: tuple[ValidPluginHook, ...] = Field(
98+
plugins_for_nox_sessions: tuple[ValidPluginHook, ...] = Field(
9999
default=(),
100100
description="""
101-
This is used to provide hooks to extend one or more of the Nox tasks provided
101+
This is used to provide hooks to extend one or more of the Nox sessions provided
102102
by the python-toolbox. As described on the plugins pages:
103103
- https://exasol.github.io/python-toolbox/main/user_guide/customization.html#plugins
104104
- https://exasol.github.io/python-toolbox/main/developer_guide/plugins.html,

exasol/toolbox/nox/plugin.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,18 @@ def post_integration_tests_hook(self, session, config, context):
108108
def plugin_manager(config) -> pluggy.PluginManager:
109109
pm = pluggy.PluginManager(_PLUGIN_MARKER)
110110
pm.add_hookspecs(NoxTasks)
111-
for plugin in getattr(config, "nox_task_plugins", []):
111+
plugin_attribute = "plugins_for_nox_sessions"
112+
113+
if not hasattr(config, plugin_attribute):
114+
raise AttributeError(
115+
"in the noxconfig.py file, the class Config should inherit "
116+
"from `exasol.toolbox.config.BaseConfig`. This is used to "
117+
f"set the default `{plugin_attribute}`. If the allowed "
118+
f"`{plugin_attribute} needs to differ in your project and is an "
119+
"input parameter (not property), you can set it in the PROJECT_CONFIG statement."
120+
)
121+
122+
for plugin in getattr(config, plugin_attribute):
112123
pm.register(plugin())
113124
return pm
114125

noxconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ class Config(BaseConfig):
7171
# The PTB does not have integration tests run with an Exasol DB,
7272
# so for running in the CI, we take the first element.
7373
exasol_versions=(BaseConfig().exasol_versions[0],),
74-
nox_task_plugins=(UpdateTemplates,),
74+
plugins_for_nox_sessions=(UpdateTemplates,),
7575
)

test/unit/config_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ def prepare_release_update_version(self, session, config, version: Version) -> N
110110
class TestPlugins:
111111
@staticmethod
112112
def test_works_when_empty():
113-
BaseConfig(nox_task_plugins=())
113+
BaseConfig(plugins_for_nox_sessions=())
114114

115115
@staticmethod
116116
def test_works_for_hook(capsys):
117-
BaseConfig(nox_task_plugins=(WithHook,))
117+
BaseConfig(plugins_for_nox_sessions=(WithHook,))
118118

119119
@staticmethod
120120
def test_raises_exception_method_with_hook_not_specified():
121121
with pytest.raises(ValidationError) as ex:
122-
BaseConfig(nox_task_plugins=(WithNotSpecifiedHook,))
122+
BaseConfig(plugins_for_nox_sessions=(WithNotSpecifiedHook,))
123123
assert "Method `not_specified_anywhere`" in str(ex.value)
124124

125125
@staticmethod
126126
def test_raises_exception_without_hook():
127127
with pytest.raises(ValidationError) as ex:
128-
BaseConfig(nox_task_plugins=(WithoutHook,))
128+
BaseConfig(plugins_for_nox_sessions=(WithoutHook,))
129129
assert "No methods in `WithoutHook`" in str(ex.value)

0 commit comments

Comments
 (0)