From 18eb1ab1b8424c484e058a260475a817fadbacf0 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Fri, 16 Aug 2024 16:06:46 -0600 Subject: [PATCH] move docstring indent to after class dedent --- mypy/stubgenc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index d07cfa35414d..1f3ce9eb278c 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -811,8 +811,6 @@ def generate_class_stub(self, class_name: str, cls: type, output: list[str]) -> class_info = ClassInfo(class_name, "", getattr(cls, "__doc__", None), cls) docstring = class_info.docstring if self._include_docstrings else None - if docstring: - docstring = self._indent_docstring(docstring) for attr, value in items: # use unevaluated descriptors when dealing with property inspection @@ -861,6 +859,9 @@ def generate_class_stub(self, class_name: str, cls: type, output: list[str]) -> self.dedent() + if docstring: + docstring = self._indent_docstring(docstring) + bases = self.get_base_types(cls) if bases: bases_str = "(%s)" % ", ".join(bases)