-
Notifications
You must be signed in to change notification settings - Fork 3
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
Include YAML path in validation errors #108
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #108 +/- ##
==========================================
+ Coverage 89.62% 89.65% +0.02%
==========================================
Files 23 23
Lines 1398 1402 +4
==========================================
+ Hits 1253 1257 +4
Misses 145 145 ☔ View full report in Codecov by Sentry. |
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.
OK I see what you did there.
I think this is a little tidier than my solution of printing a message and re-raising the exception.
My one comment is that it took me a full minute to find the filename in the traceback in your example.
My crude approach puts the filename just before the exception and I found it much more readable.
(I think I have code-blindness - seeing lots of similar text of a screen I can never focus in on the bit I need! - so this may just be a personal issue)
I wouldn't say that re-constructing the validation error was super tidy. So I have a slight preference for catch - print - re-raise. |
75db831
to
62609fe
Compare
Yeah I think this is just as good and less code:
|
This prints the file path with pydantic
ValidationError
s raised when trying to create aDevice
instance from a dictionary loaded from a YAML file.Fixes #99