Skip to content
8 changes: 7 additions & 1 deletion src/sqlacodegen/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,9 @@ def render_models(self, models: list[Model]) -> str:

def render_class(self, model: ModelClass) -> str:
sections: list[str] = []

comments = self.render_table_comment(model)
if comments:
sections.append(comments)
# Render class variables / special declarations
Comment on lines +1132 to 1133
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line after a control block ends.

Suggested change
sections.append(comments)
# Render class variables / special declarations
sections.append(comments)
# Render class variables / special declarations

class_vars: str = self.render_class_variables(model)
if class_vars:
Expand Down Expand Up @@ -1166,6 +1168,10 @@ def render_class_declaration(self, model: ModelClass) -> str:
)
return f"class {model.name}({parent_class_name}):"

def render_table_comment(self, model: ModelClass) -> str:
if model.table.comment:
return f'"""{model.table.comment}"""'
Copy link
Owner

@agronholm agronholm Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No wrapping for long docstrings then...?


def render_class_variables(self, model: ModelClass) -> str:
variables = [f"__tablename__ = {model.table.name!r}"]

Expand Down
Loading