Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ - Ignore typing.cast #25

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions flake8_force_keyword_arguments/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
from re import Pattern

DEFAULT_MAX_POS_ARGS: Final[int] = 2
DEFAULT_IGNORE_PATTERNS: Final[
str
] = r'(:?^logger.(:?log|debug|info|warning|error|exception|critical)$|__setattr__$|__delattr__$|__getattr__$)'
DEFAULT_IGNORE_PATTERNS: Final[str] = (
r'(:?'
r'^logger.(:?log|debug|info|warning|error|exception|critical)$'
r'|__setattr__$'
r'|__delattr__$'
r'|__getattr__$'
r'|^(:?typing\.)?cast$'
r')'
)
DEFAULT_INSPECT_MODULES: Final[Tuple[str, ...]] = ('builtins',)
DEFAULT_QUALIFIER_OPTION: Final[util.QualifierOption] = util.QualifierOption.BOTH

Expand Down
11 changes: 11 additions & 0 deletions tests/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ def test_default_ignore_function_pattern(flake8_path):
assert result.out_lines == []


def test_default_ignore_function_pattern_typing_cast(flake8_path):
(flake8_path / 'example.py').write_text(
'''
typing.cast(object, \'test\')
cast(object, 1)
''',
)
result = flake8_path.run_flake8(['--kwargs-max-positional-arguments', '2'])
assert result.out_lines == []


def test_ignore_function_pattern_extended(flake8_path):
(flake8_path / 'example.py').write_text(
'tt = lambda a, b, c: None',
Expand Down