Skip to content

Commit

Permalink
Add class documentation to class docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
WesleyTheGeolien committed May 2, 2024
1 parent 0cc84ba commit eb36c40
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def generate_class_stub(self, class_name: str, cls: type, output: list[str]) ->
bases_str = "(%s)" % ", ".join(bases)
else:
bases_str = ""
if types or static_properties or rw_properties or methods or ro_properties:
if types or static_properties or rw_properties or methods or ro_properties or class_info.docstring:
output.append(f"{self._indent}class {class_name}{bases_str}:")
for line in types:
if (
Expand All @@ -845,6 +845,10 @@ def generate_class_stub(self, class_name: str, cls: type, output: list[str]) ->
):
output.append("")
output.append(line)
if class_info.docstring:
self.indent()
output.append(f'{self._indent}"""{class_info.docstring}"""')
self.dedent()
for line in static_properties:
output.append(line)
for line in rw_properties:
Expand Down

0 comments on commit eb36c40

Please sign in to comment.