Skip to content

Commit

Permalink
add support for annotated kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
Илья Лебедев committed Apr 29, 2019
1 parent 5b7b5e2 commit d7d83e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flake8_annotations_coverage/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.2'
__version__ = '0.0.3'
5 changes: 4 additions & 1 deletion flake8_annotations_coverage/ast_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
def has_type_annotations(func_def) -> bool:
has_return_annotation = func_def.returns is not None
has_args_annotations = any(a for a in func_def.args.args if a.annotation is not None)
has_kwargs_annotations = func_def.args and func_def.args.kwarg and func_def.args.kwarg.annotation is not None
has_kwonly_args_annotations = any(a for a in func_def.args.kwonlyargs if a.annotation is not None)
return has_return_annotation or has_args_annotations or has_kwonly_args_annotations
return any(
(has_return_annotation, has_kwargs_annotations, has_args_annotations, has_kwonly_args_annotations),
)
5 changes: 5 additions & 0 deletions tests/test_annotations_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ def test_ok_for_kwonly_annotated_file():
assert not errors
errors = run_validator_for_test_file('kwonly_arg_annotated.py', min_coverage=100)
assert len(errors) == 1


def test_ok_for_kwargs_annotated_file():
errors = run_validator_for_test_file('kwargs_annotated.py')
assert not errors
2 changes: 2 additions & 0 deletions tests/test_files/kwargs_annotated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def foo(**kwargs: str):
pass

0 comments on commit d7d83e3

Please sign in to comment.