Michal Špondr
Michal Špondr

Reputation: 1535

How to add Flake8 configuration file in pytest?

I would like to run pytest with Flake8 like this:

python3 -m pytest --flake8

I also would like to run Flake8 with following parameters:

max-line-length = 120
select = E,W,F,N,C

How can I do it? Creating setup.cfg with this content did not change anything:

[pytest]
flake8-max-line-length = 120
flake8-select = E,W,F,N,C

Upvotes: 1

Views: 4585

Answers (2)

Michal Špondr
Michal Špondr

Reputation: 1535

Editing pytest.ini (without setup.cfg or any other configuration file) helped my case:

[pytest]
flake8-select = E,W,F,N,C
flake8-max-line-length = 120
flake8-ignore = E201 E231

Without the flake8-ignore I didn't see any difference in output.

Upvotes: 2

anthony sottile
anthony sottile

Reputation: 69924

The pytest section for setup.cfg is [tool:pytest] as of version 4.0 (fully removed in 4.1.0 as per pytest's removal process)

disclaimer: I'm a core dev of pytest

Upvotes: -1

Related Questions