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 1/3] 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 e7591e74..97ef88fb 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 ================================ From aa51e6662bdbcfbe164e671e7a8e782f68701832 Mon Sep 17 00:00:00 2001 From: Paciupa <65620103+Paciupa@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:51:46 +0300 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Ian Stapleton Cordasco --- docs/source/user/violations.rst | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/source/user/violations.rst b/docs/source/user/violations.rst index 97ef88fb..7e0075f3 100644 --- a/docs/source/user/violations.rst +++ b/docs/source/user/violations.rst @@ -136,25 +136,31 @@ 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 ------------------------ +Ignoring Violations in Specific 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: +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 setup.py:E121' + 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 + tests/*:F841,D setup.py:E121 other_project/*:W9 From 8ace3157bdb0726c5020fc23ccef65a03672ecc4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:51:56 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/source/user/violations.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/user/violations.rst b/docs/source/user/violations.rst index 7e0075f3..590d4501 100644 --- a/docs/source/user/violations.rst +++ b/docs/source/user/violations.rst @@ -139,7 +139,7 @@ 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 +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. @@ -153,7 +153,7 @@ or in your configuration file. 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