From d05718bb3de18e3d62c520b8d9af759929f6361a Mon Sep 17 00:00:00 2001 From: Marcin Wojdyr Date: Wed, 18 Sep 2024 14:32:45 +0200 Subject: [PATCH] stubgen.py: "@staticmethod" was used instead of "@classmethod" --- src/stubgen.py | 2 +- tests/py_stub_test.py | 2 +- tests/py_stub_test.pyi.ref | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) 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: