Skip to content

Improve the way users can override decoding and encoding for custom types #20

@clintval

Description

@clintval

Right now custom type encoding and decoding is only possible to achieve with inheriting from the reader/writer classes and overriding the specific private functions. It would be ideal to have hooks (enc_hook and dec_hook) for full and easy user control. Challengingly we might have two use cases to support which are (1) the pre-processing of the single CSV field data into something ready to be converted to builtins and (2) actual encoding/decoding hooks over specific types including those that may be recursively found. It would also be ideal if the definition of these hooks could exist at class use time instead of class definition time. Such as:

with (
    open("/mypath/file.tsv", "w") as handle,
    TsvWriter(handle, MyMetric).with_encoder(???) as writer
):
    pass

Similarly for the reader:

with (
    open("/mypath/file.tsv", "r") as handle,
    TsvReader(handle, MyMetric).with_decoder(???) as reader
):
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions