-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Generic(De)Serializer
stub classes for generic formats
#178
Conversation
|
||
@classmethod | ||
@abstractmethod | ||
def from_file(cls, p: Path, *_) -> Self: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer, *_
effectively means that subclasses that add arguments must make them keyword only / optional. The goal is improve uniformity of implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add that note in the extended section of the doc string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can do that if you are adamant about it. I didn't add a comment b.c. the syntax and meaning are self evident (which I kind of like). Its not a super esoteric pattern, but to be fair, it is a newish pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too worried. I probably would literally have written it as "Note to self:" because I would forget in the future haha.
ffc7f99
to
777bc32
Compare
777bc32
to
46bc2c4
Compare
Add
GenericSerializer
,GenericDeserializer
, andGenericSerializerDeserializer
abstract marker classes.ngen.init_config
cannot support all formats under the sun, but with other tools likengen.config_gen
being aware of the abstractions present inngen.init_config
, these classes provide a common interface for generic data formats to interoperate. Beyond interfaces, thetype
's work as markers for other tools (e.g.isinstance
check and change behavior).ngen.init_config
--0.0.7
Additions
GenericSerializer
,GenericDeserializer
, andGenericSerializerDeserializer
abstract marker classes. Serializers and Deserializer must impliement the following methods respectively:to_file(self, f: pathlib.Path, *_) -> None
,to_str(self, *_) -> str
andfrom_file(cls, f: pathlib.Path, *_)
,from_str(cls, s: str, *_)
.