Denise Mauldin
Denise Mauldin

Reputation: 5615

Python testing with flake8 and pytest results in AttributeError: 'Application' object has no attribute 'parse_preliminary_options_and_args'

When I run my tests today, I get the following error:

    return self._hookexec(self, self.get_hookimpls(), kwargs)
ve/lib/python2.7/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
ve/lib/python2.7/site-packages/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
ve/lib/python2.7/site-packages/_pytest/runner.py:123: in pytest_runtest_call
    item.runtest()
ve/lib/python2.7/site-packages/pytest_flake8.py:126: in runtest
    self.statistics)
ve/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
ve/lib/python2.7/site-packages/pytest_flake8.py:191: in check_file
    app.parse_preliminary_options_and_args(args)
E   AttributeError: 'Application' object has no attribute 'parse_preliminary_options_and_args'

I'm using

        'pytest',
        'pytest-cov',
        'pytest-flake8',
        'pytest-flask',
        'pytest-watch',

The versions of the libraries incremented: pytest (4.6.9 -> 4.6.10), pyflakes (2.1.1 -> 2.2.0), pycodestyle (2.5.0 -> 2.6.0), and flake8 (3.7.9 -> 3.8.0). There's nothing in the changelogs about the parse_preliminary_options_and_args attribute. I'm guessing it's something to do with flake8 deprecating the setuptools integration: python setup.py flake8 (setuptools integration) is now deprecated and will be removed in a future version (See also GitLab!330, GitLab#544)

Pinning flake8 to 3.7.9 fixes the error, but how would I figure that out without trial and error?

Why does this not give a better error?

Upvotes: 4

Views: 5346

Answers (1)

anthony sottile
anthony sottile

Reputation: 69934

pytest-flake8 is using a private api of flake8 and as such when we changed implementation details in flake8 3.8.0 it broke

there's more details here or the issue with pytest-flake8 here


disclaimer: I'm the current flake8 maintainer

Upvotes: 10

Related Questions