eladrich / pyrallis

Pyrallis is a framework for structured configuration parsing from both cmd and files. Simply define your desired configuration structure as a dataclass and let pyrallis do the rest!
https://eladrich.github.io/pyrallis/
MIT License
198 stars 7 forks source link

Improved Decoding Mechanism :microscope: #11

Closed eladrich closed 2 years ago

eladrich commented 2 years ago

Improved decoding mechanism to support inherited types, one can still use the existing register functionality

pyrallis.decode.register(SomeClass, lambda x: SomeClass(x))

But can also register parent classes as well

pyrallis.decode.register(BaseClass, lambda t, x: t(x), with_subclasses=True)

Also revised the dispatch mechanism from singledispatch to a new dedicated wrapper (singledispatch tries to dispatch by class instead of value which isn't suited for decoding, but worked only thanks to the default behavior)