Skip to content

Commit 42ada91

Browse files
authored
Fix parsing issues (#165)
Closes #163
1 parent 151b8c4 commit 42ada91

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

news/+18f6c191.fix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed an issue causing configuration parsing issues with multiple patterns when `setup.cfg`
2+
or `.pylintrc` is used

news/+bcdb07a6.fix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed an issue causing configuration parsing issues if trailing commas are used when `setup.cfg`
2+
or `.pylintrc` is used

pylint_per_file_ignores/_plugin.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ def register(linter: PyLinter) -> None:
7373

7474

7575
def _parse_string(input_string: str) -> list[str]:
76+
if "\n" in input_string:
77+
result = []
78+
for line in input_string.split("\n"):
79+
if line.strip():
80+
result.extend(_parse_string(line))
81+
return result
82+
7683
parts = input_string.split(",")
7784

7885
result = []
@@ -105,5 +112,5 @@ def load_configuration(linter: PyLinter) -> None:
105112
if pattern.startswith("\n"):
106113
pattern = pattern[1:]
107114
files = [Path(file).absolute() for file in glob.glob(pattern, recursive=True)]
108-
rules = [rule.strip() for rule in rules_str.split(",")]
115+
rules = [rule.strip() for rule in rules_str.split(",") if rule.strip()]
109116
_augment_add_message(linter, rules=rules, files=files)

0 commit comments

Comments
 (0)