Skip to content

Commit 684fdd9

Browse files
authored
Add support for @classmethod (#91)
1 parent 80f7276 commit 684fdd9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pybind11_stubgen/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,14 @@ def to_lines(self): # type: () -> List[str]
585585
)
586586
for sig in self.signatures:
587587
args = sig.args
588-
if not args.strip().startswith("self"):
589-
result.append("@staticmethod")
588+
sargs = args.strip()
589+
if not sargs.startswith("self"):
590+
if sargs.startswith("cls"):
591+
result.append("@classmethod")
592+
# remove type of cls
593+
args = ",".join(["cls"] + sig.split_arguments()[1:])
594+
else:
595+
result.append("@staticmethod")
590596
else:
591597
# remove type of self
592598
args = ",".join(["self"] + sig.split_arguments()[1:])

0 commit comments

Comments
 (0)