Skip to content

Commit 51a589d

Browse files
authored
bug - Fix ignore pattern bug (#8)
* 🐛 - Fix ignore pattern bug * 🔖 - Bump up version to 1.0.1
1 parent f654275 commit 51a589d

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
poetry install --remove-untracked
2727
- name: Lint with flake8
2828
run: |
29-
poetry run flake8 . --kwargs-inspect-module-extend functools,itertools --kwargs-ignore-function-pattern-extend ^pytest.mark.parametrize$
29+
poetry run flake8 .
3030
- name: Type check with mypy
3131
run: |
3232
poetry run mypy -p flake8_force_keyword_arguments

flake8_force_keyword_arguments/checker.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@
2323
from re import Pattern
2424

2525
DEFAULT_MAX_POS_ARGS: Final[int] = 2
26-
DEFAULT_IGNORE_PATTERNS: Final[Tuple[str, ...]] = (
27-
r'^logger.(:?log|debug|info|warning|error|exception|critical)$',
28-
r'__setattr__$',
29-
r'__delattr__$',
30-
r'__getattr__$',
31-
)
26+
DEFAULT_IGNORE_PATTERNS: Final[
27+
str
28+
] = r'(:?^logger.(:?log|debug|info|warning|error|exception|critical)$|__setattr__$|__delattr__$|__getattr__$)'
3229
DEFAULT_INSPECT_MODULES: Final[Tuple[str, ...]] = ('builtins',)
3330
DEFAULT_QUALIFIER_OPTION: Final[util.QualifierOption] = util.QualifierOption.BOTH
3431

@@ -61,19 +58,17 @@ def add_options(cls, parser: OptionManager) -> None:
6158
)
6259
parser.add_option( # pragma: no cover
6360
'--kwargs-ignore-function-pattern',
64-
nargs='*',
61+
type=str,
6562
dest='ignore_function_pattern',
66-
comma_separated_list=True,
6763
default=DEFAULT_IGNORE_PATTERNS,
6864
parse_from_config=True,
6965
help='Ignore pattern list (default: %(default)s)',
7066
)
7167
parser.add_option( # pragma: no cover
7268
'--kwargs-ignore-function-pattern-extend',
73-
nargs='*',
69+
type=str,
7470
dest='ignore_function_pattern_extend',
75-
comma_separated_list=True,
76-
default=(),
71+
default=None,
7772
parse_from_config=True,
7873
help='Extend ignore pattern list.',
7974
)
@@ -116,12 +111,8 @@ def add_options(cls, parser: OptionManager) -> None:
116111
def parse_options(cls, options: Namespace) -> None:
117112
cls._max_pos_args = options.max_positional_arguments
118113

119-
ignore_pattern_extend = chain.from_iterable(options.ignore_function_pattern_extend)
120-
if options.ignore_function_pattern == DEFAULT_IGNORE_PATTERNS:
121-
ignore_function_patterns = options.ignore_function_pattern
122-
else:
123-
ignore_function_patterns = chain.from_iterable(options.ignore_function_pattern)
124-
cls._ignore_patterns = tuple(map(re.compile, chain(ignore_function_patterns, ignore_pattern_extend)))
114+
ignore_patterns = (options.ignore_function_pattern, options.ignore_function_pattern_extend)
115+
cls._ignore_patterns = tuple(map(re.compile, filter(None, ignore_patterns)))
125116

126117
qualifier_option = options.inspect_qualifier_option
127118

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "flake8-force-keyword-arguments"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
description = "A flake8 extension that is looking for function calls and forces to use keyword arguments if there are more than X arguments"
55
authors = ["Viktor Chaptsev <viktor@chaptsev.ru>", "Byeonghoon Yoo <bh322yoo@gmail.com>"]
66
maintainers = ["Byeonghoon Yoo <bh322yoo@gmail.com>"]

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ max-annotations-complexity = 4
1818
pytest-parametrize-values-type = tuple
1919
eradicate-whitelist = mypy:#noqa:
2020
max-returns-amount = 6
21+
22+
kwargs-inspect-module-extend = functools,itertools
23+
kwargs-ignore-function-pattern-extend = ^pytest.mark.parametrize$

tests/test_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ def test_ignore_function_pattern_extended_multiple(flake8_path):
5656
),
5757
)
5858
result = flake8_path.run_flake8(
59-
['--kwargs-max-positional-arguments', '2', '--kwargs-ignore-function-pattern-extend', '^tt$,test_function$']
59+
['--kwargs-max-positional-arguments', '2', '--kwargs-ignore-function-pattern-extend', '(:?^tt$|test_function$)']
6060
)
6161
assert result.out_lines == []

0 commit comments

Comments
 (0)