Skip to content

AttributeError: 'MypyStatusItem' object has no attribute 'collect' - running pytest 5.4 with looponfail #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
offbyone opened this issue Mar 8, 2021 · 1 comment · Fixed by #117

Comments

@offbyone
Copy link

offbyone commented Mar 8, 2021

I'm getting an error when running pytest 5.4 + pytest-xdist 1.22 + pytest-mypy 0.8.0:

metadata: {'Python': '3.6.13', 'Platform': '<redacted>', 'Packages': {'pytest': '5.4.3', 'py': '1.8.0', 'pluggy': '0.13.0'}, 'Plugins': {'html': '1.17.0', 'metadata': '1.7.0', 'mypy': '0.8.0', 'xdist': '1.22.2', 'forked': '0.2', 'cov': '2.4.0', 'hypothesis': '4.45.1'}}
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('.hypothesis/examples')
rootdir: <redacted>, inifile: setup.cfg, testpaths: lib, test
plugins: html-1.17.0, metadata-1.7.0, mypy-0.8.0, xdist-1.22.2, forked-0.2, cov-2.4.0, hypothesis-4.45.1

When I make a change, causing the tests to re-run, I get this error:

lib/python3.6/site-packages/_pytest/runner.py:244: in from_call
    result = func()
lib/python3.6/site-packages/_pytest/runner.py:264: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
lib/python3.6/site-packages/_pytest/main.py:498: in collect
    yield from self._collect(fspath, parts)
lib/python3.6/site-packages/_pytest/main.py:581: in _collect
    yield next(m[0].collect())
E   AttributeError: 'MypyStatusItem' object has no attribute 'collect'
@dmtucker
Copy link
Collaborator

dmtucker commented Mar 9, 2021

Thanks for the report 👍

SSCCE (pytest-5.4.3):

mkdir pkg
py="pkg/__init__.py"
echo 'foo: str = 5' > "$py"
venv/bin/pytest --mypy --looponfail "$py" &
echo > "$py"

From 6.0.0 through 6.1.2, it manifests a bit differently:

venv/lib/python3.8/site-packages/_pytest/runner.py:310: in from_call
    result = func()  # type: Optional[TResult]
venv/lib/python3.8/site-packages/_pytest/runner.py:340: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
venv/lib/python3.8/site-packages/_pytest/main.py:777: in collect
    assert isinstance(matching[0], nodes.Collector)
E   AssertionError

This appears to have been fixed in 6.2.0 by pytest-dev/pytest@66311ff#diff-689af6a98fad782f87c1473a3758c720d3e23ea0ecdc89617df250b2a093c6a8L778-R785

I also found pytest-dev/pytest#7763 which links to a plugin fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants