diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index b5bb4f8f727b..02feae344d52 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -553,12 +553,12 @@ def is_method(self, class_info: ClassInfo, name: str, obj: object) -> bool: def is_classmethod(self, class_info: ClassInfo, name: str, obj: object) -> bool: if self.is_c_module: - return inspect.isbuiltin(obj) or type(obj).__name__ in ( - "classmethod", - "classmethod_descriptor", - ) + raw_lookup: Mapping[str, Any] = getattr(class_info.cls, "__dict__") # noqa: B009 + raw_value = raw_lookup.get(name, obj) + classmethod_descriptor = type(int.__dict__["from_bytes"]) + return isinstance(raw_value, (classmethod, classmethod_descriptor)) else: - return inspect.ismethod(obj) + return isinstance(inspect.getattr_static(class_info.cls, name), classmethod) def is_staticmethod(self, class_info: ClassInfo | None, name: str, obj: object) -> bool: if class_info is None: