@@ -279,6 +279,21 @@ def desc(self):
279279 )
280280
281281
282+ class RedundantPyTestDisablePluginAutoload (results .LineResult , results .Warning ):
283+ """Redundant ``PYTEST_DISABLE_PLUGIN_AUTOLOAD``
284+
285+ The package uses ``EPYTEST_PLUGINS`` to disable plugin autoloading already,
286+ so ``PYTEST_DISABLE_PLUGIN_AUTOLOAD`` is redundant.
287+ """
288+
289+ @property
290+ def desc (self ):
291+ return (
292+ f"line { self .lineno } : PYTEST_DISABLE_PLUGIN_AUTOLOAD is redundant, "
293+ "autoloading disabled via EPYTEST_PLUGINS already"
294+ )
295+
296+
282297class PythonCheck (Check ):
283298 """Python eclass checks.
284299
@@ -302,6 +317,7 @@ class PythonCheck(Check):
302317 PythonMissingSCMDependency ,
303318 MisplacedEPyTestVar ,
304319 ShadowedEPyTestTimeout ,
320+ RedundantPyTestDisablePluginAutoload ,
305321 }
306322 )
307323
@@ -472,12 +488,34 @@ def check_epytest_vars(self, pkg):
472488 line = pkg .node_str (var_node )
473489 yield MisplacedEPyTestVar (var_name , line = line , lineno = lineno + 1 , pkg = pkg )
474490
491+ have_epytest_plugins = False
492+ have_epytest_plugin_autoload = False
493+ found_pytest_disable_plugin_autoload = []
494+
475495 for var_node in bash .var_assign_query .captures (pkg .tree .root_node ).get ("assign" , ()):
476496 var_name = pkg .node_str (var_node .child_by_field_name ("name" ))
477497 if var_name == "EPYTEST_TIMEOUT" :
478498 lineno , _ = var_node .start_point
479499 line = pkg .node_str (var_node )
480500 yield ShadowedEPyTestTimeout (line = line , lineno = lineno + 1 , pkg = pkg )
501+ elif var_name == "EPYTEST_PLUGINS" :
502+ have_epytest_plugins = True
503+ elif var_name == "EPYTEST_PLUGIN_AUTOLOAD" :
504+ if value_node := var_node .child_by_field_name ("value" ):
505+ value = pkg .node_str (value_node )
506+ if value not in ('""' , "''" ):
507+ have_epytest_plugin_autoload = True
508+ elif var_name == "PYTEST_DISABLE_PLUGIN_AUTOLOAD" :
509+ lineno , _ = var_node .start_point
510+ line = pkg .node_str (var_node )
511+ found_pytest_disable_plugin_autoload .append ((line , lineno ))
512+
513+ # EAPI 9+ defaults to disabled autoloading, in earlier EAPIs EPYTEST_PLUGINS does that.
514+ if (
515+ str (pkg .eapi ) not in ("7" , "8" ) or have_epytest_plugins
516+ ) and not have_epytest_plugin_autoload :
517+ for line , lineno in found_pytest_disable_plugin_autoload :
518+ yield RedundantPyTestDisablePluginAutoload (line = line , lineno = lineno + 1 , pkg = pkg )
481519
482520 @staticmethod
483521 def _prepare_deps (deps : str ):
0 commit comments