Skip to content

Commit fa48bc1

Browse files
Add pragma comment to line length ignores (#463)
* Add pragma comment to line length ignores * Update b950.py * Update bugbear.py * Update test_bugbear.py
1 parent 6bf907c commit fa48bc1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

bugbear.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def gen_line_based_checks(self):
8787
8888
The following simple checks are based on the raw lines, not the AST.
8989
"""
90-
noqa_type_ignore_regex = re.compile(r"#\s*(noqa|type:\s*ignore)[^#\r\n]*$")
90+
noqa_type_ignore_regex = re.compile(
91+
r"#\s*(noqa|type:\s*ignore|pragma:)[^#\r\n]*$"
92+
)
9193
for lineno, line in enumerate(self.lines, start=1):
9294
# Special case: ignore long shebang (following pycodestyle).
9395
if lineno == 1 and line.startswith("#!"):

tests/b950.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # noqa"
2828
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore"
2929
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # noqa: F401"
30+
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # pragma: no cover"
3031
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com#noqa:F401, B950"
3132
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore[some-code]"
3233
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore[some-code]"

tests/test_bugbear.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,8 @@ def test_b950(self):
894894
B950(12, 103, vars=(103, 79)),
895895
B950(14, 103, vars=(103, 79)),
896896
B950(21, 97, vars=(97, 79)),
897-
B950(35, 104, vars=(104, 79)),
898897
B950(36, 104, vars=(104, 79)),
898+
B950(37, 104, vars=(104, 79)),
899899
),
900900
)
901901

@@ -912,8 +912,8 @@ def test_b9_select(self):
912912
B950(12, 103, vars=(103, 79)),
913913
B950(14, 103, vars=(103, 79)),
914914
B950(21, 97, vars=(97, 79)),
915-
B950(35, 104, vars=(104, 79)),
916915
B950(36, 104, vars=(104, 79)),
916+
B950(37, 104, vars=(104, 79)),
917917
),
918918
)
919919

@@ -932,8 +932,8 @@ def test_b9_extend_select(self):
932932
B950(12, 103, vars=(103, 79)),
933933
B950(14, 103, vars=(103, 79)),
934934
B950(21, 97, vars=(97, 79)),
935-
B950(35, 104, vars=(104, 79)),
936935
B950(36, 104, vars=(104, 79)),
936+
B950(37, 104, vars=(104, 79)),
937937
),
938938
)
939939

0 commit comments

Comments
 (0)