Search code examples
pythonconfigurationlintflake8

Specify per-file-ignores with pyproject.toml and flake8


I am using flake8 (with flakehell but that should not interfere) and keep its configuration in a pyproject.toml file. I want to add a per-file-ignores config but nothing works and there is no documentation on how it is supposed to be formatted in a toml file.

Flake8 docs show only the 'native' config file format:

per-file-ignores =
    project/__init__.py:F401
    setup.py:E121
    other_project/*:W9

There is no description / example for pyproject.toml.

I tried:

per-file-ignores=["file1.py:W0621", "file2.py:W0621"]

and

per-file-ignores={"file1.py" = "W0621", "file2.py" = "W0621"}

both of which silently fail and have no effect (the warning is still raised).

What is the proper syntax for per-file-ignores setting in flake8/flakehell while using pyproject.toml?


Solution

  • flake8 does not have support for pyproject.toml, only .flake8, setup.cfg, and tox.ini


    disclaimer: I am the flake8 maintainer