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

PluginManager.get_plugins no longer returns None for blocked plugins #481

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/481.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``PluginManager.get_plugins()`` no longer returns ``None`` for blocked plugins.
2 changes: 1 addition & 1 deletion src/pluggy/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def parse_hookspec_opts(

def get_plugins(self) -> set[Any]:
"""Return a set of all registered plugin objects."""
return set(self._name2plugin.values())
return {x for x in self._name2plugin.values() if x is not None}

def is_registered(self, plugin: _Plugin) -> bool:
"""Return whether the plugin is already registered."""
Expand Down
4 changes: 4 additions & 0 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,19 @@ class A:
assert name is not None
assert pm.is_registered(a1)
assert not pm.is_blocked(name)
assert pm.get_plugins() == {a1}

pm.set_blocked(name)
assert pm.is_blocked(name)
assert not pm.is_registered(a1)
assert pm.get_plugins() == set()

pm.set_blocked("somename")
assert pm.is_blocked("somename")
assert not pm.register(A(), "somename")
pm.unregister(name="somename")
assert pm.is_blocked("somename")
assert pm.get_plugins() == set()

# Unblock.
assert not pm.unblock("someothername")
Expand Down
Loading