Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flake8_typehinting/flake8_typehinting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_flake8_typehinting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)'}