Skip to content

Commit 8c1f2f1

Browse files
committed
Handle __init_subclass__
1 parent 34cf98e commit 8c1f2f1

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

flake8_params/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _visit_function(self, node: Union[ast.FunctionDef, ast.AsyncFunctionDef]) ->
202202
signature_args = list(get_signature_args(node))
203203
decorators = list(get_decorator_names(node))
204204

205-
if node.name == "__new__":
205+
if node.name in {"__new__", "__init_subclass__"}:
206206
# Remove 'cls' etc.
207207
signature_args.pop(0)
208208

tests/example_code.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,17 @@ def __new__(cls, a: int, b: str, c: int = 0) -> "MyTuple":
361361
"""
362362

363363
return super().__new__((a, b, c)) # type: ignore[arg-type]
364+
365+
366+
# stdlib
367+
from abc import ABC
368+
369+
370+
class MyABC(ABC):
371+
372+
def __init_subclass__(cls, swallow, **kwargs) -> None:
373+
r"""
374+
Setup something in the subclass.
375+
376+
:param \*\*kwargs:
377+
"""

tests/test_flake8_params_/test_plugin.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
292:0: PRM002 Missing parameters in docstring: *baz
1919
311:0: PRM002 Missing parameters in docstring: **baz
2020
356:1: PRM002 Missing parameters in docstring: a b c
21+
372:1: PRM002 Missing parameters in docstring: swallow

0 commit comments

Comments
 (0)