summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-06-09 22:03:05 +0200
committerGitHub <noreply@github.com>2020-06-09 22:03:05 +0200
commit2a883cbc4361603c720addae6d9420e8a156e313 (patch)
tree275786ad1d4712288276ed185698a4605b8c395b
parent1e42fd85d6ed4ccdccf9137ac2f2f2225c35306d (diff)
downloadpylint-git-2a883cbc4361603c720addae6d9420e8a156e313.tar.gz
``missing-kwoa`` is no longer emitted when dealing with overload functions (#3673)
Close #3655
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/typecheck.py7
-rw-r--r--tests/functional/m/missing_kwoa_py3.py39
-rw-r--r--tests/functional/m/missing_kwoa_py3.txt6
4 files changed, 51 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a57efeaf..703287cf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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