From bad2d7ba851286ff638bd2a449d1fc31e9b90187 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 27 Oct 2022 12:58:52 -0400 Subject: [PATCH] Add example of per-file ignores to the README (#488) --- README.md | 4 ++++ resources/test/fixtures/__init__.py | 2 ++ resources/test/fixtures/pyproject.toml | 3 +++ src/pyproject.rs | 5 ++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5ac09e67b..60ed26a86b 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,10 @@ select = [ "F401", "F403", ] +per-file-ignores = [ + "__init__.py:F401", + "path/to/file.py:F401" +] ``` Alternatively, on the command-line: diff --git a/resources/test/fixtures/__init__.py b/resources/test/fixtures/__init__.py index f9e64b3061..6a0a884ae0 100644 --- a/resources/test/fixtures/__init__.py +++ b/resources/test/fixtures/__init__.py @@ -1,3 +1,5 @@ +import os + print(__path__) __all__ = ["a", "b", "c"] diff --git a/resources/test/fixtures/pyproject.toml b/resources/test/fixtures/pyproject.toml index be686c5767..5d61c76a19 100644 --- a/resources/test/fixtures/pyproject.toml +++ b/resources/test/fixtures/pyproject.toml @@ -5,3 +5,6 @@ extend-exclude = [ "migrations", "directory/also_excluded.py", ] +per-file-ignores = [ + "__init__.py:F401", +] diff --git a/src/pyproject.rs b/src/pyproject.rs index 98de2ed3b4..f952e7b430 100644 --- a/src/pyproject.rs +++ b/src/pyproject.rs @@ -362,7 +362,10 @@ other-attribute = 1 extend_select: vec![], ignore: vec![], extend_ignore: vec![], - per_file_ignores: vec![], + per_file_ignores: vec![StrCheckCodePair { + pattern: "__init__.py".to_string(), + code: CheckCode::F401 + }], dummy_variable_rgx: None, target_version: None, }