dandi / dandisets-healthstatus

Healthchecks of dandisets and support libraries (pynwb and matnwb)
0 stars 1 forks source link

Strip linenos from `versions` dicts when loading #48

Closed jwodder closed 1 year ago

jwodder commented 1 year ago

Closes #46.

yarikoptic commented 1 year ago

so we will be storing those line numbers (what for?) but stripping when loading from a file? or am I misreading the subject?

jwodder commented 1 year ago

@yarikoptic The _lineno fields were present when you ran the code because our custom YAML loader adds those fields next to every key in every mapping when loading from a file, and those fields remained in the structure as it was updated and then serialized back to a file. Normally, unrecognized fields like these are discarded by pydantic when processing loaded YAML into classes, but the version fields are dicts instead of classes, so we need to use a validator to process the dicts when instantiating the containing classes in order to prevent the _lineno fields in versions from ending up in the structure.