Skip to content

type safety vs ease of use

it would be nice if i could just drop different datatypes on crud_client and the client would figure out by itself how to handle this data.

e.g.

crud_nonpublic.create_resource(sid, project_id, data, metadata)

data and metadata could be of type

  • file (binary)
  • file (text)
  • string
  • databinding (the metadata)

the crud client could check incoming data & metadata and choose the matching data handling. but how to reflect this in the API?

  1. just remove the types
  2. union of possible types (see aggregator)
  3. overload combined with union (as in https://gitlab.gwdg.de/dariah-de/textgridrep/textgrid-python-clients/-/blob/v0.10.1/src/tgclients/aggregator.py?ref_type=tags#L25)
  4. dispatch: https://martinheinz.dev/blog/50
  5. fastcore typedispatch https://www.kdnuggets.com/2020/10/fastcore-underrated-python-library.html
Edited by Ubbo Veentjer