-
-
Notifications
You must be signed in to change notification settings - Fork 227
fix: support json and yaml with separate decoding #509
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
Conversation
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.
Thanks for adding this, just one suggestion about JSON error handling.
Thanks for adding this! I don't love the solution long-term because YAML is supposed to be a strict superset of JSON, it just seems that
Ideally, I'll switch to a different YAML parser that supports 1.2 (maybe ruamel). If that is easy enough I might do that instead of this PR. In any event, getting some fix out is definitely a huge win, even if I end up changing it up long term. So thank you!! |
@dbanty I have tested ruaml and it does not support tab as well. I have updated the code and added a test for the error condition. good catch! sorry about this overlook. :-} |
json is not technically a subset of yaml because yaml don't support tabs while json does Signed-off-by: Pierre Tardy <[email protected]>
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.
It's a real shame that none of the YAML parsers for Python I could find properly support the 1.2 spec 😞. Thanks for putting this fix together, it's good to go once CI passes!
I would suggest to add a small "make check" makefile for new contributors, as the workflow approval requires you to approve, and auto-cancels itself at first failure. |
If you check out the CONTRIBUTING.md it tells you how to run tasks via Taskipy. In this case there's a |
json is not exactly a subset of yaml, as yaml do not support tabs there are maybe other subtleties, so we just use content-type to figure out how to parse Signed-off-by: Pierre Tardy <[email protected]>
I did look at contributing, but I missed the part about task check. |
Awesome, thanks! I definitely want it to be easier to contribute 😅. |
Blech, looks like the failing tests are due to some mocking that should probably be using tempfiles instead. I plan to do a sweep of open PRs to put together the next release this weekend, so don't fret over the failing tests if you don't have time, I'll fix them during that sprint. |
Interrestingly, thoses tests pass fine on my machine (python 3.9) this is why I did not see that. |
Codecov Report
@@ Coverage Diff @@
## main #509 +/- ##
===========================================
- Coverage 100.00% 99.87% -0.13%
===========================================
Files 48 48
Lines 1610 1628 +18
===========================================
+ Hits 1610 1626 +16
- Misses 0 2 +2
Continue to review full report at Codecov.
|
Turns out those tests only fail on Python 3.7, I was able to reproduce by setting up an environment with that. Closing this in favor of #515 (which is this plus the 3.7 test fixes). |
…509, #515]. Thanks @tardyp and @Gelbpunkt! (#515) Co-authored-by: Pierre Tardy <[email protected]>
Fix: #488
json is not exactly a subset of yaml, as yaml do not support tabs
there are maybe other subtleties, so we just use content-type to figure out how to parse
First commit actually fix the wrong part of the code 🤦 , but it might still be worth to have it behave similarly.
For a few lines of code, I am not sure it is really worth to factorize, so I didn't bother