diff --git a/flake8_typehinting/flake8_typehinting.py b/flake8_typehinting/flake8_typehinting.py index c1b7ef1..60884cc 100644 --- a/flake8_typehinting/flake8_typehinting.py +++ b/flake8_typehinting/flake8_typehinting.py @@ -35,7 +35,7 @@ def visit_FunctionDef(self, node: ast.FunctionDef) -> None: # NOQA N802 def _check_th_100(self, node: ast.FunctionDef) -> None: """Check for TH100.""" for arg in node.args.args: - if not arg.arg == 'self' and arg.annotation is None: + if arg.arg not in ('self', 'cls') and arg.annotation is None: self.problems.append((node.lineno, node.col_offset, f'{TH100} ({arg.arg})')) def _check_th_101(self, node: ast.FunctionDef) -> None: diff --git a/tests/test_flake8_typehinting.py b/tests/test_flake8_typehinting.py index a212944..ad8e60f 100644 --- a/tests/test_flake8_typehinting.py +++ b/tests/test_flake8_typehinting.py @@ -76,3 +76,9 @@ def test_type_hinting_in_function_return_correct() -> None: """Test type hinting in function definitions.""" ret = _results('def my_func(y: int, x: str = "1") -> int:\n return 1') assert ret == set() + + +def test_type_hinting_in_function_definition_cls() -> None: + """Test type hinting in function definitions.""" + ret = _results('def my_func(cls, y: int, x="1") -> None:\n print(x)') + assert ret == {'1:0 TH100 function missing type hints for arguments (x)'}