Skip to content

Commit

Permalink
stubgen.py: "@staticmethod" was used instead of "@classmethod"
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Sep 18, 2024
1 parent 90844bd commit d05718b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/py_stub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def static_method(x):
pass

@classmethod
def class_method(x):
def class_method(cls, x):
pass

@typing.overload
Expand Down
4 changes: 2 additions & 2 deletions tests/py_stub_test.pyi.ref
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d05718b

Please sign in to comment.