diff --git a/docs/source/user/violations.rst b/docs/source/user/violations.rst index e7591e74..590d4501 100644 --- a/docs/source/user/violations.rst +++ b/docs/source/user/violations.rst @@ -136,6 +136,38 @@ the errors in that file will show up without having to modify our configuration. Both exist so we can choose which is better for us. +Ignoring Violations in Specific Files +------------------------------------- + +If we want to ignore one or more violation codes for certain files, you can +use the :option:`flake8 --per-file-ignores` on either the command-line +or in your configuration file. + +.. prompt:: bash + + flake8 --per-file-ignores='project/test.py:F841 setup.py:E121' + flake8 --per-file-ignores='tests/*:F841,D setup.py:E121' + +.. note:: + + While most options in Flake8 use commas to separate values, this option allows + multiple violation codes to be specified per file with commas so to specify + multiple file mappings use spaces to delimit them. + +We can also specify it in config file: + +.. code-block:: ini + + per-file-ignores = + project/test.py:F841 + tests/*:F841,D + setup.py:E121 + other_project/*:W9 + +Syntax is similar with :option:`flake8 --exclude` for files +and :option:`flake8 --ignore` for errors. + + Selecting Violations with Flake8 ================================