-
Notifications
You must be signed in to change notification settings - Fork 45
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
editoast: remove 'validator' dependency #10273
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## dev #10273 +/- ##
==========================================
+ Coverage 81.58% 81.86% +0.28%
==========================================
Files 1062 763 -299
Lines 104970 76351 -28619
Branches 722 722
==========================================
- Hits 85636 62504 -23132
+ Misses 19293 13806 -5487
Partials 41 41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
fe27737
to
d1ab72f
Compare
95c908a
to
8fbe1f3
Compare
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.
So far, it looks good, most of the comments I was about to do are part of the TODO list, so waiting for the follow-up 😄
effort_curves: &EffortCurves, | ||
electrical_power_startup_time: Option<f64>, | ||
raise_pantograph_time: Option<f64>, | ||
) -> std::result::Result<(), ValidationError> { | ||
) -> Result<(), D::Error> |
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 saw that it's part of your TODO list. The errors are going to change, but in the meantime, we might want to stick to the less ideal, but coherent way of doing: using crate::error::Result
which uses InternalError
.
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 think that this function being called by Deserialize::deserialize
prevents from using InternalError
let rolling_stock: RollingStock = | ||
serde_json::from_reader(BufReader::new(rolling_stock_file))?; | ||
let rolling_stock: Changeset<RollingStockModel> = rolling_stock.into(); |
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.
In the spirit of "parse don't validate", I'd argue that the validation should occur at the deserialization of the schema and not changeset (unlike what's currently being done on dev). There is an impl From<editoast_schema::RollingStock> for RollingStockChangeset
existing in rolling_stock_model.rs
. It might also be easier to pull the remote = "Self"
trick on the schema as it's struct isn't generated.
Wdyt?
effort_curves: &EffortCurves, | ||
electrical_power_startup_time: Option<f64>, | ||
raise_pantograph_time: Option<f64>, | ||
) -> std::result::Result<(), ValidationError> { | ||
) -> Result<(), D::Error> |
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 think that this function being called by Deserialize::deserialize
prevents from using InternalError
fb63ad4
to
85ccac8
Compare
TODO: * fix tests * use Changeset<RollingStock> and #[serde(remote = "Self")] if possible * maybe change error type returned by the free function * remove any 'validator' use Signed-off-by: Pierre-Etienne Bougué <bougue.pe@proton.me>
8fbe1f3
to
090bcbc
Compare
After #10147 (comment)
TODO: