Skip to content

Commit

Permalink
Remove dummy field (#1039)
Browse files Browse the repository at this point in the history
* Remove dummy field

* Fix coverage

* Fix lint
  • Loading branch information
koxudaxi authored Jan 22, 2023
1 parent a019450 commit 7dfacd5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions datamodel_code_generator/parser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ def _find_field_and_base_classes(
for field_ in model_.fields:
if field_.original_name == original_name:
return field_, []
return None, _find_base_classes(model_)
return None, _find_base_classes(model_) # pragma: no cover

for model in models:
field, base_models = _find_field_and_base_classes(model)
if field:
return field
models.extend(base_models)
models.extend(base_models) # pragma: no cover

return None
return None # pragma: no cover


def _copy_data_types(data_types: List[DataType]) -> List[DataType]:
Expand Down Expand Up @@ -829,21 +829,22 @@ def __override_required_field(
if isinstance(model, (Enum, self.data_model_root_type)):
continue
for index, model_field in enumerate(model.fields[:]):
data_type = model_field.data_type
if (
not model_field.original_name
or not model_field.required
and (
model_field.data_type.data_types
or model_field.data_type.reference
or model_field.data_type.type
)
or data_type.data_types
or data_type.reference
or data_type.type
or data_type.literals
or data_type.dict_key
):
continue

original_field = _find_field(
model_field.original_name, _find_base_classes(model)
)
if not original_field:
if not original_field: # pragma: no cover
model.fields.remove(model_field)
continue
copied_original_field = original_field.copy()
if original_field.data_type.reference:
Expand Down

0 comments on commit 7dfacd5

Please sign in to comment.