webknossos-libs icon indicating copy to clipboard operation
webknossos-libs copied to clipboard

Use newer version of `cattrs`

Open rschwanhold opened this issue 4 years ago • 0 comments

  • Update to 1.8.0 (or newer)
  • There might be an error such as cattr.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[int, wkcuber.mag.Mag]. Register a structure hook for it
  • The hooks might be simplified:
    • Instead of this loop, you could register (un-)structuring factories:
    def snake_to_camel_case_overrides(attrs_type):
      return {
          a.name: override(omit_if_default=True, rename=_snake_to_camel_case(a.name))
          for a in attr.fields(attrs_type)
      }
    
    register_unstructure_hook_factory(attrs.has, lambda attrs_type: make_dict_unstructure_fn(cls, dataset_converter,  **snake_to_camel_case_overrides(attrs_type)))
    # same for structuring
    

rschwanhold avatar Aug 26 '21 13:08 rschwanhold