mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
allow idiomatic setup.cfg comments
This commit is contained in:
parent
87198e50f1
commit
c34fd755f0
2 changed files with 12 additions and 2 deletions
|
|
@ -17,7 +17,8 @@ from typing import Sequence
|
||||||
|
|
||||||
from flake8 import exceptions
|
from flake8 import exceptions
|
||||||
|
|
||||||
COMMA_SEPARATED_LIST_RE = re.compile(r"[,\s]")
|
COMMA_SEPARATED_LIST_RE = re.compile(r"[,\s]+")
|
||||||
|
STRIP_RE = re.compile(r"^\s+|\s+$|\s*#.*$")
|
||||||
LOCAL_PLUGIN_LIST_RE = re.compile(r"[,\t\n\r\f\v]")
|
LOCAL_PLUGIN_LIST_RE = re.compile(r"[,\t\n\r\f\v]")
|
||||||
NORMALIZE_PACKAGE_NAME_RE = re.compile(r"[-_.]+")
|
NORMALIZE_PACKAGE_NAME_RE = re.compile(r"[-_.]+")
|
||||||
|
|
||||||
|
|
@ -38,7 +39,7 @@ def parse_comma_separated_list(
|
||||||
assert isinstance(value, str), value
|
assert isinstance(value, str), value
|
||||||
|
|
||||||
separated = regexp.split(value)
|
separated = regexp.split(value)
|
||||||
item_gen = (item.strip() for item in separated)
|
item_gen = (STRIP_RE.sub("", item) for item in separated)
|
||||||
return [item for item in item_gen if item]
|
return [item for item in item_gen if item]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,15 @@ def test_invalid_ignore_codes_raise_error(tmpdir, opt_manager):
|
||||||
assert msg == expected
|
assert msg == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_ignore_code_comments_dont_raise_error(tmpdir, opt_manager):
|
||||||
|
tmpdir.join("setup.cfg").write("[flake8]\nignore = E203, #comment")
|
||||||
|
with tmpdir.as_cwd():
|
||||||
|
cfg, _ = config.load_config("setup.cfg", [], isolated=False)
|
||||||
|
|
||||||
|
ret = config.parse_config(opt_manager, cfg, tmpdir)
|
||||||
|
assert ret == {"ignore": ["E203"]}
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_extend_ignore_codes_raise_error(tmpdir, opt_manager):
|
def test_invalid_extend_ignore_codes_raise_error(tmpdir, opt_manager):
|
||||||
tmpdir.join("setup.cfg").write("[flake8]\nextend-ignore = E203, //comment")
|
tmpdir.join("setup.cfg").write("[flake8]\nextend-ignore = E203, //comment")
|
||||||
with tmpdir.as_cwd():
|
with tmpdir.as_cwd():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue