Skip to content

feat: add dict serialisation#219

Closed
jaapschoutenalliander wants to merge 4 commits intomainfrom
feature/serialize-dict
Closed

feat: add dict serialisation#219
jaapschoutenalliander wants to merge 4 commits intomainfrom
feature/serialize-dict

Conversation

@jaapschoutenalliander
Copy link
Copy Markdown
Member

Add mode parameter to serialisation with dict as an option

Signed-off-by: Jaap Schouten <jaap.schouten@alliander.com>
Signed-off-by: Jaap Schouten <jaap.schouten@alliander.com>
Signed-off-by: Jaap Schouten <jaap.schouten@alliander.com>
Comment on lines +504 to +505
@overload
def deserialize(cls: type[Self], path: dict, mode: Literal["dict"]) -> Self: ...
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't looked at the full code yet, but I think having path as the object you need to provide the dict is a bit odd.
My personal preference would be either:

  • Add a data argument that we use if filled (and error if both path and data is filled)
  • Add a separate method like: deserialize_object. Which is used to deserialize from a python object. So we have two methods; one file based, one object based. Both of them can later be extended with additional modes if needed.
    This somewhat follows the json setup for example. Which has json.load from a file and json.loads from a string

Signed-off-by: Jaap Schouten <jaap.schouten@alliander.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants