From 74dba5b965b776aae102c632654ae7256cdbcba3 Mon Sep 17 00:00:00 2001 From: Paciupa <65620103+Paciupa@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:31:22 +0300 Subject: [PATCH] Add per-file-ignores mention in violations.rst There is no mention of "per-file-ignores" option in "Selecting and Ignoring Violations" section documentation, only in "Full Listing of Options and Their Descriptions". --- docs/source/user/violations.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/source/user/violations.rst b/docs/source/user/violations.rst index e7591e7..97ef88f 100644 --- a/docs/source/user/violations.rst +++ b/docs/source/user/violations.rst @@ -136,6 +136,32 @@ 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 for some Files +----------------------- + +Sometimes, we might want to ignore some error codes (or class of error codes) for +some part of our project (tests for example). +We can do this using :option:`flake8 --per-file-ignores` from CLI: + +.. prompt:: bash + + flake8 --per-file-ignores='project/test.py:F841 setup.py:E121' + flake8 --per-file-ignores='tests/*:F841 setup.py:E121' + +We can also specify it in config file: + +.. code-block:: ini + + per-file-ignores = + project/test.py:F841 + tests/*:F841 + 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 ================================