Repository: businho/pytest-ruff (language: python)

Issue:
pluggy._manager.PluginValidationError: Plugin 'ruff' for hook 'pytest_collect_file'
Hi All,

We have found that new version `0.3` doesn't work with pytest `8.1.0`, we are getting the following stack trace with that combination.

```python
Traceback (most recent call last):
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 19[5](), in console_main
    code = main()
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x[6]()4/lib/python3.8/site-packages/_pytest/config/__init__.py", line 153, in main
    config = _prepareconfig(args, plugins)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 335, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 121, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/helpconfig.py", line 105, in pytest_cmdline_parse
    config = yield
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1141, in pytest_cmdline_parse
    self.parse(args)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1490, in parse
    self._preparse(args, addopts=addopts)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 13[7]()7, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/runner/actions-runner/_work/_tool/Python/3.[8]().18/x64/lib/python3.8/site-packages/pluggy/_manager.py", line 415, in load_setuptools_entrypoints
    self.register(plugin, name=ep.name)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/_pytest/config/__init__.py", line 4[9]()7, in register
    plugin_name = super().register(plugin, name)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.18/x64/lib/python3.8/site-packages/pluggy/_manager.py", line [16](7)7, in register
    self._verify_hook(hook, hookimpl)
  File "/home/runner/actions-runner/_work/_tool/Python/3.8.[18](9)/x64/lib/python3.8/site-packages/pluggy/_manager.py", line [34](5)2, in _verify_hook
    raise PluginValidationError(
pluggy._manager.PluginValidationError: Plugin 'ruff' for hook 'pytest_collect_file'
hookimpl definition: pytest_collect_file(path, parent, fspath=None)
Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec
```

For the moment we have fallback to pytest-ruff `0.2.1` and pytest `8.0.2`, we also found out that `8.1.0` pytest doesn't play either with `0.2.1` different stack trace.

Happy to get more information if you guys need any help, 


Discussion / hints:
Reference : https://github.com/pytest-dev/pytest/issues/11779

Fix patch:
diff --git a/tox.ini b/tox.ini
index fcbc6d6..6c5de3c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 isolated_build = true
-envlist = py{38,39,310,311,312}-pytest{5,6,7,8},lint
+envlist = py{38,39,310,311,312}-pytest{5,6,7,8,810,81},lint
 
 [testenv]
 allowlist_externals = poetry
@@ -9,7 +9,10 @@ commands =
     pytest5: pip install "pytest<6"
     pytest6: pip install "pytest>=6,<7"
     pytest7: pip install "pytest>=7,<8"
-    pytest8: pip install "pytest>=8,<9"
+    pytest8: pip install "pytest>=8,<8.1"
+    # pytest 8.1.0 was yanked, but their "broken behaviour" will comeback soon
+    pytest810: pip install "pytest==8.1.0"
+    pytest81: pip install "pytest>=8.1,<9"
     # Disable ruff plugin to generate better coverage results
     poetry run pytest -p no:ruff -vvv --cov --cov-append --cov-report term --cov-report xml {posargs}
 


Test patch:
diff --git a/pytest_ruff/__init__.py b/pytest_ruff/__init__.py
index dea76a7..eade02c 100644
--- a/pytest_ruff/__init__.py
+++ b/pytest_ruff/__init__.py
@@ -4,7 +4,12 @@
 
 from ruff.__main__ import find_ruff_bin
 
-from pytest_ruff._pytest_compat import get_stash, make_path_kwargs, set_stash
+from pytest_ruff._pytest_compat import (
+    get_stash,
+    make_path_kwargs,
+    set_stash,
+    PYTEST_VER,
+)
 
 HISTKEY = "ruff/mtimes"
 
@@ -26,15 +31,29 @@ def pytest_configure(config):
     set_stash(config, config.cache.get(HISTKEY, {}))
 
 
-def pytest_collect_file(path, parent, fspath=None):
-    config = parent.config
-    if not config.option.ruff:
-        return
+if PYTEST_VER >= (7, 0):
 
-    if path.ext != ".py":
-        return
+    def pytest_collect_file(file_path, parent, fspath=None):
+        config = parent.config
+        if not config.option.ruff:
+            return
+
+        if file_path.suffix != ".py":
+            return
+
+        return RuffFile.from_parent(parent, **make_path_kwargs(file_path))
+
+else:
+
+    def pytest_collect_file(path, parent, fspath=None):
+        config = parent.config
+        if not config.option.ruff:
+            return
+
+        if path.ext != ".py":
+            return
 
-    return RuffFile.from_parent(parent, **make_path_kwargs(path))
+        return RuffFile.from_parent(parent, **make_path_kwargs(path))
 
 
 def pytest_sessionfinish(session, exitstatus):