Repository: pytest-dev/pytest-testinfra (language: python)

Issue:
Broken compatibility with pytest<7 (pytest.Parser type annotation)
The parser annotation in plugin.py introduced in 10.0 does not work with pytest 6. https://github.com/pytest-dev/pytest-testinfra/blob/dc48cd98f3b1970ecbad63f866a94f8283b79ce4/testinfra/plugin.py#L40
`pytest.Parser` is only available from pytest 7.0.0
```
>>> from testinfra import plugin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/testinfra/plugin.py", line 40, in <module>
    def pytest_addoption(parser: pytest.Parser) -> None:
AttributeError: module 'pytest' has no attribute 'Parser'
```

While specifying minimal pytest version would be a solution, I would rather recommend finding another solution, as RHEL-9/Alma Linux 9/CentOS Stream 9 are running pytest 6 (and Python 3.9).

I'd be happy to help with finding a solution, should you decide to keep pytest 6 compatibility.


Discussion / hints:
It's possible to use the future annotations features Plus and conditional TYPE_CHECKING imports to sidestep this

Since those old pytest versions are unmaintained it's best if someone affected steps up for changing this

There's need for feedback form the primary maintainers as they are well within reason to just set requires-python 
I think we should require `pytest>=7` then and maybe document how to install testinfra within a virtualenv or with pipx.
> Since those old pytest versions are unmaintained it's best if someone affected steps up for changing this

Well, pytest 6 is maintained in the enterprise linux world.

Allow me to explain the Fedora packaing as best I can:
pytest-testinfra is being packaged in Fedora, incl. EPEL(extra packagers for enterprise linux). 
CentOS Stream 8 builds will end this year in May, allowing Fedora Python projects packagers to only focus on EPEL9, which generally do not require changes from the Fedora versions.

I'm looking into refactoring the rpm packaging with the latest testinfra version in mind now, which is how I found the issue in the first place. (I'm not the maintainer, just contributing). And I believe this one line with type annotation is preventing the el9 package from being built. It would be a shame if the rpm version would have to include patches instead of using upstream sources 'as is'.

I'd be happy to step-up! :) Unless there is a fundamental incompability with pytest 6.2. Will try to run some tests later on.

> There's need for feedback form the primary maintainers as they are well within reason to just set requires-python

Required minimal python is already 3.9 here afaik.


Fix patch:
diff --git a/setup.cfg b/setup.cfg
index 07cd1b56..37e681ef 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -32,7 +32,7 @@ packages = find:
 setup_requires =
     setuptools_scm
 install_requires =
-    pytest!=3.0.2
+    pytest>=6
 extras_require =
 
 [options.extras_require]


Test patch:
diff --git a/testinfra/plugin.py b/testinfra/plugin.py
index d1371dbb..db3541b0 100644
--- a/testinfra/plugin.py
+++ b/testinfra/plugin.py
@@ -10,6 +10,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import annotations
+
 import logging
 import shutil
 import sys