diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/checkers/typecheck.py | 7 | ||||
-rw-r--r-- | tests/functional/m/missing_kwoa_py3.py | 39 | ||||
-rw-r--r-- | tests/functional/m/missing_kwoa_py3.txt | 6 |
4 files changed, 51 insertions, 5 deletions
@@ -14,6 +14,10 @@ Release date: TBA Close #1368 +* ``missing-kwoa`` is no longer emitted when dealing with overload functions + + Close #3655 + * mixed-indentation has been removed, it is no longer useful since TabError is included directly in python3 Close #2984 #3573 diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 70fa58289..c311ce947 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -1413,7 +1413,12 @@ accessed. Python regular expressions are accepted.", for name in kwparams: defval, assigned = kwparams[name] - if defval is None and not assigned and not has_no_context_keywords_variadic: + if ( + defval is None + and not assigned + and not has_no_context_keywords_variadic + and not overload_function + ): self.add_message("missing-kwoa", node=node, args=(name, callable_name)) def _check_invalid_sequence_index(self, subscript: astroid.Subscript): diff --git a/tests/functional/m/missing_kwoa_py3.py b/tests/functional/m/missing_kwoa_py3.py index 3b6e1c0d8..b4dc604cd 100644 --- a/tests/functional/m/missing_kwoa_py3.py +++ b/tests/functional/m/missing_kwoa_py3.py @@ -1,4 +1,6 @@ -# pylint: disable=missing-docstring,unused-argument +# pylint: disable=missing-docstring,unused-argument,too-few-public-methods +import typing + def target(pos, *, keyword): return pos + keyword @@ -34,3 +36,38 @@ def other_function(**kwargs): other_function(param=2) + + +class Parent: + + @typing.overload + def __init__( self, *, first, second, third): + pass + + @typing.overload + def __init__(self, *, first, second): + pass + + @typing.overload + def __init__(self, *, first): + pass + + def __init__( + self, + *, + first, + second: typing.Optional[str] = None, + third: typing.Optional[str] = None): + self._first = first + self._second = second + self._third = third + + +class Child(Parent): + def __init__( + self, + *, + first, + second): + super().__init__(first=first, second=second) + self._first = first + second diff --git a/tests/functional/m/missing_kwoa_py3.txt b/tests/functional/m/missing_kwoa_py3.txt index b9d6baac5..e65581f25 100644 --- a/tests/functional/m/missing_kwoa_py3.txt +++ b/tests/functional/m/missing_kwoa_py3.txt @@ -1,3 +1,3 @@ -missing-kwoa:19:not_forwarding_kwargs:Missing mandatory keyword argument 'keyword' in function call -missing-kwoa:25::Missing mandatory keyword argument 'keyword' in function call -too-many-function-args:25::Too many positional arguments for function call +missing-kwoa:21:not_forwarding_kwargs:Missing mandatory keyword argument 'keyword' in function call +missing-kwoa:27::Missing mandatory keyword argument 'keyword' in function call +too-many-function-args:27::Too many positional arguments for function call |