From bca4bb0738f23f79cbf21f8c36e076d12ef62468 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 24 Jan 2024 13:22:36 +0200 Subject: [PATCH] config: use `pluginmanager.unblock` instead of accessing pluggy's internals The function was added in pluggy 1.4.0. --- .pre-commit-config.yaml | 2 +- setup.cfg | 2 +- src/_pytest/config/__init__.py | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe6ed99ae..26ca339b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: additional_dependencies: - iniconfig>=1.1.0 - attrs>=19.2.0 - - pluggy + - pluggy>=1.4.0 - packaging - tomli - types-pkg_resources diff --git a/setup.cfg b/setup.cfg index 02f6031bd..9ee64a4e8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,7 +46,7 @@ py_modules = py install_requires = iniconfig packaging - pluggy>=1.3.0,<2.0 + pluggy>=1.4.0,<2.0 colorama;sys_platform=="win32" exceptiongroup>=1.0.0rc8;python_version<"3.11" tomli>=1.0.0;python_version<"3.11" diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index e4e8f700a..6c16ad0b2 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -745,13 +745,10 @@ class PytestPluginManager(PluginManager): self.set_blocked("pytest_" + name) else: name = arg - # Unblock the plugin. None indicates that it has been blocked. - # There is no interface with pluggy for this. - if self._name2plugin.get(name, -1) is None: - del self._name2plugin[name] + # Unblock the plugin. + self.unblock(name) if not name.startswith("pytest_"): - if self._name2plugin.get("pytest_" + name, -1) is None: - del self._name2plugin["pytest_" + name] + self.unblock("pytest_" + name) self.import_plugin(arg, consider_entry_points=True) def consider_conftest(