Repository: wemake-services/wemake-python-styleguide

Issue:
WPS612 false positive for keyword arguments with different default values
### What's wrong

I already wrote all in details for Pylint, please read: https://github.com/PyCQA/pylint/issues/7287 
```python
class Foo:
    def __init__(*, bar = 10):
         ...

class Child(Foo):
    def __init__(*, bar = 99999):
         super().__init__(bar=bar)
```

### How it should be

no warnings

### Flake8 version and plugins

not relevant

### pip information

not relevant

### OS information

not relevant

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/wemake-services/wemake-python-styleguide/pull/3191?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wemake-services) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`85f029d`)](https://app.codecov.io/gh/wemake-services/wemake-python-styleguide/commit/85f029de78f8f5047f6038bff317f884a2ee3503?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wemake-services) to head [(`9cf6bf7`)](https://app.codecov.io/gh/wemake-services/wemake-python-styleguide/commit/9cf6bf7da29a9af1763c27c1d0570d0c71cdcaa8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wemake-services).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##            master     #3191   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          372       372           
  Lines        12608     12562   -46     
  Branches       863       856    -7     
=========================================
- Hits         12608     12562   -46     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/wemake-services/wemake-python-styleguide/pull/3191?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wemake-services).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wemake-services).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c95805f3..104760bc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -117,6 +117,7 @@ Semantic versioning in our case means:
 - Fixes `WPS434` to allow reassignment in a form of `x = [y, *x]`
 - Fixes `WPS221` to ignore PEP695's `TypeAlias` from line complexity checks
 - Fixes `WPS474` to only count import collisions in the same context, #2962
+- Fixes `WPS612` to count defaults in function definitions, #2478
 
 ### Misc
 
diff --git a/wemake_python_styleguide/violations/oop.py b/wemake_python_styleguide/violations/oop.py
index fcafbad3..b9b3093f 100644
--- a/wemake_python_styleguide/violations/oop.py
+++ b/wemake_python_styleguide/violations/oop.py
@@ -549,6 +549,10 @@ class UselessOverwrittenMethodViolation(ASTViolation):
 
 
     .. versionadded:: 0.12.0
+    .. versionchanged:: 1.0.0
+       Ignores cases when ``super().method`` is called
+       when function parameters have defaults.
+       Because defaults might be different.
 
     """
 
diff --git a/wemake_python_styleguide/visitors/ast/classes.py b/wemake_python_styleguide/visitors/ast/classes.py
index 63d5b81f..2ae548b8 100644
--- a/wemake_python_styleguide/visitors/ast/classes.py
+++ b/wemake_python_styleguide/visitors/ast/classes.py
@@ -217,6 +217,12 @@ class WrongMethodVisitor(base.BaseNodeVisitor):
             # Any decorator can change logic and make this overwrite useful.
             return
 
+        if node.args.defaults or list(filter(None, node.args.kw_defaults)):
+            # It means that function / method has defaults in args,
+            # we cannot be sure that these defaults are the same
+            # as in the call def, ignoring it.
+            return
+
         call_stmt = self._get_call_stmt_of_useless_method(node)
         if call_stmt is None or not isinstance(call_stmt.func, ast.Attribute):
             return
@@ -226,10 +232,9 @@ class WrongMethodVisitor(base.BaseNodeVisitor):
         if defined_method_name != attribute.attr:
             return
 
-        if not super_args.is_ordinary_super_call(attribute.value, class_name):
-            return
-
-        if not function_args.is_call_matched_by_arguments(node, call_stmt):
+        if not super_args.is_ordinary_super_call(
+            attribute.value, class_name
+        ) or not function_args.is_call_matched_by_arguments(node, call_stmt):
             return
 
         self.add_violation(
diff --git a/wemake_python_styleguide/visitors/ast/functions.py b/wemake_python_styleguide/visitors/ast/functions.py
index 52c9781e..17b13249 100644
--- a/wemake_python_styleguide/visitors/ast/functions.py
+++ b/wemake_python_styleguide/visitors/ast/functions.py
@@ -402,7 +402,6 @@ class UselessLambdaDefinitionVisitor(base.BaseNodeVisitor):
             # It means that `lambda` has defaults in args,
             # we cannot be sure that these defaults are the same
             # as in the call def, ignoring it.
-            # `kw_defaults` can have [None, ...] items.
             return
 
         if not function_args.is_call_matched_by_arguments(node, node.body):


Test patch:
diff --git a/tests/test_visitors/test_ast/test_classes/test_methods/test_useless_overwriting_method.py b/tests/test_visitors/test_ast/test_classes/test_methods/test_useless_overwriting_method.py
index 69c58512..5bc7c856 100644
--- a/tests/test_visitors/test_ast/test_classes/test_methods/test_useless_overwriting_method.py
+++ b/tests/test_visitors/test_ast/test_classes/test_methods/test_useless_overwriting_method.py
@@ -79,6 +79,7 @@ invalid_method_args: list[_MethodArgs] = [
     _MethodArgs('a', ''),
     _MethodArgs('a', 'a, 1'),
     _MethodArgs('a, b', 'a'),
+    _MethodArgs('a, /, b', 'a=a, b=b'),
     _MethodArgs('a, b', 'a, b, 1'),
     _MethodArgs('a, b', 'a, b=1'),
     _MethodArgs('a, *, b', 'a'),
@@ -102,6 +103,11 @@ invalid_method_args: list[_MethodArgs] = [
     _MethodArgs('*, a, **kwargs', 'a=a'),
     _MethodArgs('*, a, **kwargs', '**kwargs'),
     _MethodArgs('*, a, **kwargs', 'a=a, b=1, **kwargs'),
+    # Presence of defaults allows passing the same args:
+    _MethodArgs('a=1', 'a'),
+    _MethodArgs('a=1, /', 'a'),
+    _MethodArgs('a, *, b=None', 'a, b=b'),
+    _MethodArgs('a=1, *args, b=2, **kwargs', 'a, *args, b=b, **kwargs'),
 ]
 
 invalid_statements = [