Skip to content

pytest broken with: assert type in (None, "pathlist", "args", "linelist", "bool") #1028

@saper

Description

@saper

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

AnyIO version

4.11.0

Python version

3.9

What happened?

When having anyio==4.11.0 as a dependency, running old pytest gives AssertionError.

How can we reproduce the bug?

  1. Create python 3.9 virtual environment (we are using AlmaLinux 9 or Red Hat Enterprise Linux 9)

  2. Create the following requirements file repro.txt with the following list

    anyio==4.11.0
      exceptiongroup==1.3.0
        typing_extensions==4.15.0
      idna==3.11
      sniffio==1.3.1
      typing_extensions==4.15.0
pipdeptree==2.28.0
  packaging==25.0
  pip==25.3
pytest==6.1.2
  attrs==25.4.0
  iniconfig==2.1.0
  packaging==25.0
  pluggy==0.13.1
  py==1.11.0
  toml==0.10.2
  1. Install the dependencies with

    pip install -r repro.txt

  2. Run the following command:

    pytest .

We are getting the following exception:

Traceback (most recent call last):
  File "/run/user/503/bug-1028-repro/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 187, in console_main
    code = main()
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
    config = outcome.get_result()  # type: Config
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1280, in parse
    self._preparse(args, addopts=addopts)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1172, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/manager.py", line 300, in load_setuptools_entrypoints
    self.register(plugin, name=ep.name)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/__init__.py", line 436, in register
    ret = super().register(plugin, name)  # type: Optional[str]
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/manager.py", line 127, in register
    hook._maybe_apply_history(hookimpl)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/hooks.py", line 333, in _maybe_apply_history
    res = self._hookexec(self, [method], kwargs)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/anyio/pytest_plugin.py", line 68, in pytest_addoption
    parser.addini(
  File "/run/user/503/bug-1028-repro/lib/python3.9/site-packages/_pytest/config/argparsing.py", line 176, in addini
    assert type in (None, "pathlist", "args", "linelist", "bool")
AssertionError

If we use anyio==4.9.0 with the following requirements

anyio==4.9.0
  exceptiongroup==1.3.0
    typing_extensions==4.15.0
  idna==3.11
  sniffio==1.3.1
  typing_extensions==4.15.0
pipdeptree==2.28.0
  packaging==25.0
  pip==25.3
pytest==6.1.2
  attrs==25.4.0
  iniconfig==2.1.0
  packaging==25.0
  pluggy==0.13.1
  py==1.11.0
  toml==0.10.2

I am getting pytest to run (with an expected test collecting error):

============================= test session starts ==============================
platform linux -- Python 3.9.21, pytest-6.1.2, py-1.11.0, pluggy-0.13.1
rootdir: /run/user/503
plugins: anyio-4.9.0
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/runner.py:310: in from_call
    result = func()  # type: Optional[TResult]
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/runner.py:340: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/main.py:684: in collect
    for direntry in visit(str(argpath), self._recurse):
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/pathlib.py:570: in visit
    yield from visit(entry.path, recurse)
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/pathlib.py:570: in visit
    yield from visit(entry.path, recurse)
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/pathlib.py:570: in visit
    yield from visit(entry.path, recurse)
bug-1028-repro-olderanyio/lib/python3.9/site-packages/_pytest/pathlib.py:566: in visit
    entries = sorted(os.scandir(path), key=lambda entry: entry.name)
E   PermissionError: [Errno 13] Permission denied: '/run/user/503/systemd/inaccessible/dir'
=========================== short test summary info ============================
ERROR  - PermissionError: [Errno 13] Permission denied: '/run/user/503/system...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.14s ===============================

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions