Skip to content

Commit

Permalink
Fix alias for superclass with identical name (#1981)
Browse files Browse the repository at this point in the history
If an externally imported model is renamed because it has the same name
as the current model, the alias was incorrectly suffixed with the original name.
  • Loading branch information
kmichel-aiven authored Jun 5, 2024
1 parent d875f85 commit ee11cef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datamodel_code_generator/parser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def __change_from_import(
if from_ and import_ and alias != name:
data_type.alias = (
alias
if from_ == '.' and data_type.full_name == import_
if data_type.reference.short_name == import_
else f'{alias}.{name}'
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
from .referenced import Model as Model_1


class Model(Model_1.Model):
class Model(Model_1):
some_optional_property: str
some_optional_typed_property: datetime
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
from .referenced import Model as Model_1


class Model(Model_1.Model):
class Model(Model_1):
some_optional_property: str
some_optional_typed_property: AwareDatetime

0 comments on commit ee11cef

Please sign in to comment.