diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 4e038cfd75d1..a55be41d1a5d 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -668,7 +668,7 @@ def _verify_arg_default_value( def maybe_strip_cls(name: str, args: list[nodes.Argument]) -> list[nodes.Argument]: - if name in ("__init_subclass__", "__class_getitem__"): + if args and name in ("__init_subclass__", "__class_getitem__"): # These are implicitly classmethods. If the stub chooses not to have @classmethod, we # should remove the cls argument if args[0].variable.name == "cls":