Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dispatcher when no plugins are given #332

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Wanimatrix
Copy link

When any plugin is using the dispatcher for nested actions it should
pass all plugins again to avoid that any plugin as subtask would be
handled.
Currently this means a lot of plugins are broken because they don't pass
plugins to the dispatcher.

To fix this, take all Plugin subclasses when no plugin is given (we
should at least have the default plugins).

When any plugin is using the dispatcher for nested actions it should
pass all plugins again to avoid that any plugin as subtask would be
handled.
Currently this means a lot of plugins are broken because they don't pass
plugins to the dispatcher.

To fix this, take all Plugin subclasses when no plugin is given (we
should at least have the default plugins).
Add test to verify that a plugin can run dispatch to handle subtasks of
external plugins.
Copy link
Contributor

@kurtmckee kurtmckee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this design will respect the --disable-built-in-plugins option.

@@ -0,0 +1,17 @@
"""Test that a plugin can call dispatcher for subtasks.

The plugin calls dispatch with his data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The plugin calls dispatch with his data.
The plugin calls dispatch with its data.

@@ -18,7 +18,10 @@ def __init__(
):
self._log = Messenger()
self._setup_context(base_directory, options)
plugins = plugins or []
if plugins == None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use identity, not equality, comparisons with None:

Suggested change
if plugins == None:
if plugins is None:

@@ -18,7 +18,10 @@ def __init__(
):
self._log = Messenger()
self._setup_context(base_directory, options)
plugins = plugins or []
if plugins == None:
plugins = Plugin.__subclasses__()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will circumvent the configuration option --disable-built-in-plugins. It will re-enable plugins that the user may have requested be disabled.

@kurtmckee
Copy link
Contributor

I've submitted #343 to address this, but I think that it will respect the --disable-built-in-plugins option by simply returning the same Dispatcher instance after it is first instantiated.

As a side effect, #343 introduces a cached Dispatcher instance that plugins can begin leveraging -- they can simply access dotbot.dispatcher.current_dispatcher directly instead of re-instantiating the Dispatcher class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants