Skip to content

Commit 54faeec

Browse files
better is_classmethod
1 parent 7c0c4b4 commit 54faeec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mypy/stubgenc.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,12 @@ def is_method(self, class_info: ClassInfo, name: str, obj: object) -> bool:
553553

554554
def is_classmethod(self, class_info: ClassInfo, name: str, obj: object) -> bool:
555555
if self.is_c_module:
556-
return inspect.isbuiltin(obj) or type(obj).__name__ in (
557-
"classmethod",
558-
"classmethod_descriptor",
559-
)
556+
raw_lookup: Mapping[str, Any] = getattr(class_info.cls, "__dict__") # noqa: B009
557+
raw_value = raw_lookup.get(name, obj)
558+
classmethod_descriptor = type(int.__dict__["from_bytes"])
559+
return isinstance(raw_value, classmethod) or isinstance(raw_value, classmethod_descriptor)
560560
else:
561-
return inspect.ismethod(obj)
561+
return isinstance(inspect.getattr_static(class_info.cls, name), classmethod)
562562

563563
def is_staticmethod(self, class_info: ClassInfo | None, name: str, obj: object) -> bool:
564564
if class_info is None:

0 commit comments

Comments
 (0)