Skip to content

Unable to round-trip an impact_model to_dict and from_dict again when metadata fields are None #48

@vmvl-cea

Description

@vmvl-cea

On an impact_model object where metadata: {'author': None, 'reviewer': None, 'report': None}, we can apply the to_dict method and obtain a dictionnary of the impact_model.

When trying to build an impact_model back from this dictionnary, by applying ImpactModel.from_dict(<my_dict>), we get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "...Lib\site-packages\apparun\impact_model.py", line 150, in from_dict
    metadata=ModelMetadata.from_dict(impact_model["metadata"]),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\Lib\site-packages\apparun\impact_model.py", line 68, in from_dict
    author=LcaPractitioner(**model_metadata["author"]),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: apparun.impact_model.LcaPractitioner() argument after ** must be a mapping, not NoneType

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions