diff --git a/src/stubgen.py b/src/stubgen.py index a79e1471..b7843768 100755 --- a/src/stubgen.py +++ b/src/stubgen.py @@ -399,7 +399,7 @@ def put_function(self, fn: Callable[..., Any], name: Optional[str] = None, paren self.write_ln("@staticmethod") fn = fn.__func__ elif isinstance(fn, classmethod): - self.write_ln("@staticmethod") + self.write_ln("@classmethod") fn = fn.__func__ # Special handling for nanobind functions with overloads diff --git a/tests/py_stub_test.py b/tests/py_stub_test.py index 6053376a..c0251bac 100644 --- a/tests/py_stub_test.py +++ b/tests/py_stub_test.py @@ -44,7 +44,7 @@ def static_method(x): pass @classmethod - def class_method(x): + def class_method(cls, x): pass @typing.overload diff --git a/tests/py_stub_test.pyi.ref b/tests/py_stub_test.pyi.ref index f9256f1f..9e6822d0 100644 --- a/tests/py_stub_test.pyi.ref +++ b/tests/py_stub_test.pyi.ref @@ -15,8 +15,8 @@ class AClass: @staticmethod def static_method(x): ... - @staticmethod - def class_method(x): ... + @classmethod + def class_method(cls, x): ... @overload def overloaded(self, x: int) -> None: