dss-extensions / dss-extensions/AltDSS-Schema

Problem with "before" model_validators

Open
#8 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Functions like [this one](https://github.com/dss-extensions/AltDSS-Schema/blob/main/python/altdss_models.py#L4041) are causing us an issue. We are constructing `Line` from an already-constructed `Line_Common` instance. The code fails because it expects a dict instead.

I _think_ that the best solution is to make them `mode="after"` validators instead. I have found it to always be better to use after validators unless I really need to perform some manipulation before Pydantic has run its type conversions. If this function were an after validator then it `self` would always be a constructed model.

Would you be OK with such a change? We could submit a PR.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.