mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
6051897a91
commit
eb4cb35368
3 changed files with 81 additions and 24 deletions
|
|
@ -423,10 +423,9 @@ class StyleGuide:
|
|||
error_is_selected = (
|
||||
self.should_report_error(error.code) is Decision.Selected
|
||||
)
|
||||
is_ignored = (
|
||||
error.is_block_ignored(disable_noqa)
|
||||
or error.is_inline_ignored(disable_noqa)
|
||||
)
|
||||
is_ignored = error.is_block_ignored(
|
||||
disable_noqa
|
||||
) or error.is_inline_ignored(disable_noqa)
|
||||
is_not_ignored = is_ignored is False
|
||||
|
||||
if error_is_selected and is_not_ignored:
|
||||
|
|
|
|||
|
|
@ -48,9 +48,12 @@ def _noqa_block_ranges(filename: str) -> Match[str] | None:
|
|||
current_block_start = line_no
|
||||
current_block_codes = codes
|
||||
elif state == "off":
|
||||
noqa_block_ranges.append((
|
||||
range(current_block_start, line_no), current_block_codes,
|
||||
))
|
||||
noqa_block_ranges.append(
|
||||
(
|
||||
range(current_block_start, line_no),
|
||||
current_block_codes,
|
||||
)
|
||||
)
|
||||
next_expected_state = "on"
|
||||
current_block_start = None
|
||||
current_block_codes = None
|
||||
|
|
@ -99,7 +102,10 @@ class Violation(NamedTuple):
|
|||
return False
|
||||
|
||||
if codes_str is None:
|
||||
LOG.debug("%r is ignored by a blanket ``# noqa: on ... # noqa: off`` block", self)
|
||||
LOG.debug(
|
||||
"%r is ignored by a blanket ``# noqa: on ... # noqa: off`` block",
|
||||
self,
|
||||
)
|
||||
return True
|
||||
|
||||
codes = set(utils.parse_comma_separated_list(codes_str))
|
||||
|
|
@ -112,7 +118,9 @@ class Violation(NamedTuple):
|
|||
return True
|
||||
|
||||
LOG.debug(
|
||||
"%r is not ignored within ``# noqa: on %s ... # noqa: off`` block", self, codes_str
|
||||
"%r is not ignored within ``# noqa: on %s ... # noqa: off`` block",
|
||||
self,
|
||||
codes_str,
|
||||
)
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -70,24 +70,74 @@ def _bi_tc(error_code, physical_line, block_start, filename, expected_result):
|
|||
[
|
||||
_bi_tc("E111", "a = 1", None, "filename-1.py", False),
|
||||
_bi_tc("E121", "a = 1", "# noqa: on E111", "filename-2.py", False),
|
||||
_bi_tc("E121", "a = 1", "# noqa: on E111,W123,F821", "filename-3.py", False),
|
||||
_bi_tc("E111", "a = 1", "# noqa: on E111,W123,F821", "filename-4.py", True),
|
||||
_bi_tc("W123", "a = 1", "# noqa: on E111,W123,F821", "filename-5.py", True),
|
||||
_bi_tc("W123", "a = 1", "# noqa: on E111, W123,F821", "filename-6.py", True),
|
||||
_bi_tc("E111", "a = 1", "# noqa: on E11,W123,F821", "filename-7.py", True),
|
||||
_bi_tc("E121", "a = 1", "# noqa:on E111,W123,F821", "filename-8.py", False),
|
||||
_bi_tc("E111", "a = 1", "# noqa:on E111,W123,F821", "filename-9.py", True),
|
||||
_bi_tc("W123", "a = 1", "# noqa:on E111,W123,F821", "filename-10.py", True),
|
||||
_bi_tc("W123", "a = 1", "# noqa:on E111, W123,F821", "filename-11.py", True),
|
||||
_bi_tc("E111", "a = 1", "# noqa:on E11,W123,F821", "filename-12.py", True),
|
||||
_bi_tc("E111", "a = 1", "# noqa: on - We do not care", "filename-13.py", True),
|
||||
_bi_tc("E111", "a = 1", "# noqa: on We do not care", "filename-14.py", True),
|
||||
_bi_tc("E111", "a = 1", "# noqa:On We do not care", "filename-15.py", True),
|
||||
_bi_tc(
|
||||
"E121",
|
||||
"a = 1",
|
||||
"# noqa: on E111,W123,F821",
|
||||
"filename-3.py",
|
||||
False,
|
||||
),
|
||||
_bi_tc(
|
||||
"E111", "a = 1", "# noqa: on E111,W123,F821", "filename-4.py", True
|
||||
),
|
||||
_bi_tc(
|
||||
"W123", "a = 1", "# noqa: on E111,W123,F821", "filename-5.py", True
|
||||
),
|
||||
_bi_tc(
|
||||
"W123",
|
||||
"a = 1",
|
||||
"# noqa: on E111, W123,F821",
|
||||
"filename-6.py",
|
||||
True,
|
||||
),
|
||||
_bi_tc(
|
||||
"E111", "a = 1", "# noqa: on E11,W123,F821", "filename-7.py", True
|
||||
),
|
||||
_bi_tc(
|
||||
"E121", "a = 1", "# noqa:on E111,W123,F821", "filename-8.py", False
|
||||
),
|
||||
_bi_tc(
|
||||
"E111", "a = 1", "# noqa:on E111,W123,F821", "filename-9.py", True
|
||||
),
|
||||
_bi_tc(
|
||||
"W123", "a = 1", "# noqa:on E111,W123,F821", "filename-10.py", True
|
||||
),
|
||||
_bi_tc(
|
||||
"W123",
|
||||
"a = 1",
|
||||
"# noqa:on E111, W123,F821",
|
||||
"filename-11.py",
|
||||
True,
|
||||
),
|
||||
_bi_tc(
|
||||
"E111", "a = 1", "# noqa:on E11,W123,F821", "filename-12.py", True
|
||||
),
|
||||
_bi_tc(
|
||||
"E111",
|
||||
"a = 1",
|
||||
"# noqa: on - We do not care",
|
||||
"filename-13.py",
|
||||
True,
|
||||
),
|
||||
_bi_tc(
|
||||
"E111",
|
||||
"a = 1",
|
||||
"# noqa: on We do not care",
|
||||
"filename-14.py",
|
||||
True,
|
||||
),
|
||||
_bi_tc(
|
||||
"E111", "a = 1", "# noqa:On We do not care", "filename-15.py", True
|
||||
),
|
||||
_bi_tc("ABC123", "a = 1", "# noqa: on ABC123", "filename-16.py", True),
|
||||
_bi_tc("E111", "a = 1", "# noqa: on ABC123", "filename-17.py", False),
|
||||
_bi_tc("ABC123", "a = 1", "# noqa: on ABC124", "filename-18.py", False),
|
||||
_bi_tc(
|
||||
"ABC123", "a = 1", "# noqa: on ABC124", "filename-18.py", False
|
||||
),
|
||||
_bi_tc("ABC123", "a = 1", "# noqa: ABC124", "filename-19.py", False),
|
||||
_bi_tc("ABC123", "a = 1", "# noqa: off ABC124", "filename-19.py", False),
|
||||
_bi_tc(
|
||||
"ABC123", "a = 1", "# noqa: off ABC124", "filename-19.py", False
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_is_block_ignored(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue