astroid crashes with RecursionError in a pytest session if schemathesis is installed
jherbel opened this issue · 6 comments
Steps to reproduce
Run pytest on the following file:
import astroid
def test_something() -> None:
astroid.parse("123")
Result without schemathesis:
$ pytest /home/joerg/tmp/test_with_astroid.py
=================================== test session starts ===================================
platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.5.0
rootdir: /home/joerg
plugins: anyio-4.3.0, hypothesis-6.100.6, subtests-0.7.0
collected 1 item
tmp/test_with_astroid.py . [100%]
==================================== 1 passed in 0.28s ====================================
Result with schemathesis:
$ pytest /home/joerg/tmp/test_with_astroid.py
=================================== test session starts ===================================
platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.5.0
rootdir: /home/joerg
plugins: anyio-4.3.0, hypothesis-6.100.6, schemathesis-3.27.1, subtests-0.7.0
collected 1 item
tmp/test_with_astroid.py F [100%]
======================================== FAILURES =========================================
_____________________________________ test_something ______________________________________
def test_something() -> None:
> astroid.parse("123")
tmp/test_with_astroid.py:4:
...
self = <Const l.0 at 0x7fe6c1531e20>, proxied = None
def __init__(self, proxied: nodes.ClassDef | None) -> None:
> super().__init__(proxied)
E RecursionError: maximum recursion depth exceeded
.pyenv/versions/3.12.3/lib/python3.12/site-packages/astroid/bases.py:342: RecursionError
==================================== warnings summary =====================================
tmp/test_with_astroid.py::test_something
/home/joerg/.pyenv/versions/3.12.3/lib/python3.12/site-packages/_pytest/python.py:1772: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: schemathesis, Hook: pytest_pyfunc_call
RecursionError: maximum recursion depth exceeded
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================= short test summary info =================================
FAILED tmp/test_with_astroid.py::test_something - RecursionError: maximum recursion depth exceeded
============================== 1 failed, 1 warning in 15.09s ==============================
Current behavior
When using astroid in pytest session with schemathesis installed, I get a RecursionError. Without schemathesis, I don't.
Expected behavior
astroid works in a pytest session if schemathesis is installed.
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output
3.2.0
I also opened an issue with schemathesis: schemathesis/schemathesis#2170
Hi @jherbel, thanks for the report. It's possible this was just fixed on main. We'll release a patch release shortly. Would you be able to retest either then (or now, with bleeding edge)? Thanks!
Oh I see from the linked issue this may be #2191 instead.
So should I test anything atm?
If you can retest with pylint 3.2.2 (which installs astroid 3.2.2) that would be a helpful data point, thanks.
Still the same crash with astroid 3.2.2.
Thanks for checking. Will handle as duplicate of #2191 then.