diff --git a/flake8_annotations_coverage/__init__.py b/flake8_annotations_coverage/__init__.py index d18f409..ffcc925 100644 --- a/flake8_annotations_coverage/__init__.py +++ b/flake8_annotations_coverage/__init__.py @@ -1 +1 @@ -__version__ = '0.0.2' +__version__ = '0.0.3' diff --git a/flake8_annotations_coverage/ast_helpers.py b/flake8_annotations_coverage/ast_helpers.py index ddd1284..8654ee0 100644 --- a/flake8_annotations_coverage/ast_helpers.py +++ b/flake8_annotations_coverage/ast_helpers.py @@ -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), + ) diff --git a/tests/test_annotations_coverage.py b/tests/test_annotations_coverage.py index 02808bd..d02874e 100644 --- a/tests/test_annotations_coverage.py +++ b/tests/test_annotations_coverage.py @@ -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 diff --git a/tests/test_files/kwargs_annotated.py b/tests/test_files/kwargs_annotated.py new file mode 100644 index 0000000..d963855 --- /dev/null +++ b/tests/test_files/kwargs_annotated.py @@ -0,0 +1,2 @@ +def foo(**kwargs: str): + pass