Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pragma comment to line length ignores #463

Merged
merged 4 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def gen_line_based_checks(self):

The following simple checks are based on the raw lines, not the AST.
"""
noqa_type_ignore_regex = re.compile(r"#\s*(noqa|type:\s*ignore)[^#\r\n]*$")
noqa_type_ignore_regex = re.compile(
r"#\s*(noqa|type:\s*ignore|pragma:)[^#\r\n]*$"
)
for lineno, line in enumerate(self.lines, start=1):
# Special case: ignore long shebang (following pycodestyle).
if lineno == 1 and line.startswith("#!"):
Expand Down
1 change: 1 addition & 0 deletions tests/b950.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # noqa"
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore"
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # noqa: F401"
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # pragma: no cover"
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com#noqa:F401, B950"
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore[some-code]"
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore[some-code]"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,8 @@ def test_b950(self):
B950(12, 103, vars=(103, 79)),
B950(14, 103, vars=(103, 79)),
B950(21, 97, vars=(97, 79)),
B950(35, 104, vars=(104, 79)),
B950(36, 104, vars=(104, 79)),
B950(37, 104, vars=(104, 79)),
),
)

Expand All @@ -912,8 +912,8 @@ def test_b9_select(self):
B950(12, 103, vars=(103, 79)),
B950(14, 103, vars=(103, 79)),
B950(21, 97, vars=(97, 79)),
B950(35, 104, vars=(104, 79)),
B950(36, 104, vars=(104, 79)),
B950(37, 104, vars=(104, 79)),
),
)

Expand All @@ -932,8 +932,8 @@ def test_b9_extend_select(self):
B950(12, 103, vars=(103, 79)),
B950(14, 103, vars=(103, 79)),
B950(21, 97, vars=(97, 79)),
B950(35, 104, vars=(104, 79)),
B950(36, 104, vars=(104, 79)),
B950(37, 104, vars=(104, 79)),
),
)

Expand Down