-
Notifications
You must be signed in to change notification settings - Fork 27
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
Nit: __post_init__
vs pydantic @model_validator(mode="after")
#204
Comments
I agree. My interpretation (and I am far from a Python expert) is that However, one very valid argument for If you do consolidate everything around |
👍 fair point. Interesting point about dependencies. I would have thought though, that we actually should be trying to move away from having any pydantic dependency at all... Zarr upstream specifically chose not to have that dependency, and the main place we use it is As for pydantic v1 vs v2 I think the fact we're planning to get rid of it makes it less of an issue. We also do require relatively recently versions of packages anyway due to our Overall 🤷♂️ Maybe let's just use |
Sounds good to me! Then you'll need to make |
+1 to moving away from pydantic and just using dataclasses. I can take that on at some point this week. |
In the
ZArray
class then after #193 we now have multiple types of validation checks, which together look like this:It seems to me like having both
__post_init__
and@model_validator(mode="after")
is unnecessarily complicated. I think_check_fill_value
should just be rewritten using@field_validator
likevalidate_dtype
is.The check inside
__post_init__
can't be done usingfield_validator
as it involves comparing two correctly-instatiated fields against one another. It is not clear to me whether best practice with pydantic is to use__post_init__
or@model_validator(mode="after")
- both seem supported, and to do similar things.@ghidalgo3 is there some subtlety I've missed here or can I clean this up a bit? (I know eventually this should all be replaced by
ZarrV3Metadata
in #175.)The text was updated successfully, but these errors were encountered: