Skip to content

Commit fef6065

Browse files
authored
fix: Remove unnecessary pass statements in nested classes (#2704)
1 parent a31749d commit fef6065

4 files changed

Lines changed: 2 additions & 6 deletions

File tree

src/datamodel_code_generator/model/template/pydantic/BaseModel.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class {{ class_name }}({{ base_class }}):{% if comment is defined %} # {{ comme
77
{{ description | indent(4) }}
88
"""
99
{%- endif %}
10-
{%- if not fields and not description %}
10+
{%- if not fields and not description and not config %}
1111
pass
1212
{%- endif %}
1313
{%- if config %}

src/datamodel_code_generator/model/template/pydantic_v2/BaseModel.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class {{ class_name }}({{ base_class }}):{% if comment is defined %} # {{ comme
1515
{{ description | indent(4) }}
1616
"""
1717
{%- endif %}
18-
{%- if not fields and not description %}
18+
{%- if not fields and not description and not config %}
1919
pass
2020
{%- endif %}
2121
{%- if config %}

tests/data/expected/main/jsonschema/same_name_objects.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class Model(BaseModel):
1414

1515

1616
class Friends(BaseModel):
17-
pass
18-
1917
class Config:
2018
extra = Extra.forbid
2119

tests/data/expected/main/openapi/same_name_objects.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111

1212
class Pets(BaseModel):
13-
pass
14-
1513
class Config:
1614
extra = Extra.forbid
1715

0 commit comments

Comments
 (0)