Repository navigation
Config IO abstraction - #140
Conversation
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
pSpitzner
left a comment
There was a problem hiding this comment.
looks good, but see my few comments
| if TYPE_CHECKING: | ||
| # Set by the typing machinery when instantiated via ``FileIO[X](...)``. | ||
| __orig_class__: ClassVar[Any] | ||
|
|
||
| def _model_type(self) -> type[M]: | ||
| """Model class carried by the generic subscription.""" | ||
| try: | ||
| return self.__orig_class__.__args__[0] | ||
| except AttributeError: | ||
| raise TypeError( | ||
| f"{type(self).__name__} must be parameterized with a model class, " | ||
| "e.g. JsonFileIO[SomeModel](path)." | ||
| ) from None |
There was a problem hiding this comment.
I like how small this ended up.
One question: this only forces us to use pydantic base models as parents for tokens (but not config classes), right?
I think being to easy-going and making "everything" a pydantic model is bad practice.
There was a problem hiding this comment.
One question: this only forces us to use pydantic base models as parents for tokens (but not config classes), right?
Currently every field we want to use in JsonFileIO should be a pydantic model. I think dataclasses might also work tho 🤔
No need to onboard every other class to pydantic too, I agree we should indeed keep it only for classes that really need the capabilities.
|
Changed the base to |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
see #134 (comment)