-
Notifications
You must be signed in to change notification settings - Fork 51
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
Support trailing commas in ion.dump[s]()
#370
Comments
Some notes:
|
It ... does do pretty printing for me? I'm calling it as:
I assume the I was thinking it could take another optional argument such as Is there a concern about maintaining feature parity with ion libraries for other languages? I agree that it would be relatively easy to implement in pure Python, but potentially a little more tricky in C, though perhaps not horrendously so. |
oh. you are correct. corrected comment.
That sounds good to me.
I'd say no. But I will check with the other maintainers. |
API feature parity with other libraries is not a concern. The only real cross-library "parity" concern is that they can all read data written by other implementations. Since trailing commas are allowed by the spec, if any libraries cannot read data with trailing commas, it is a defect in that library and should not block the proposed change here. TLDR; No concerns—do it! |
I discovered that there is already not feature parity between pure Python and the ion C module. Pretty printing (which trailing commas only makes sense in the context of) is already unsupported. So I'm going to publish a PR without C module support. I've been trying for some time to run the tests and running into errors no matter how I try. Is there a way to run the tests as they are? With Python 3.12, my default Python, it doesn't find distutils, which I guess is gone from Python 3.12, and when I use
and when I run
|
New PR: #372 |
The above errors were solved by:
|
Sorry for your troubles, we need to prioritize getting off of our legacy build setup: |
No worries, Rob. :) |
There are 3 unit tests still failing, with all of my changes in #372 ... but they appear to be entirely unrelated to my changes. I'm wondering if a Python / library version difference changed the limit for string parsing of integer values. The 3 test failures are all because of extremely long integer strings in I've elided some of the enormous integer string in this:
|
Those tests are pulled in through a submodule: https://github.com/amazon-ion/ion-tests/commits/master/ While fixing it would be good, there should be some skip lists in that test_vectors that you could add that test to for now. |
Issue #229 ("CI/CD failed due to large int<->str conversions") looks like it's still open (since December 2022!) and might be talking about the same issue (i.e. issue is preexisting?). Or perhaps not, since it's PYPY-specific, which isn't applicable. |
It is in various skip lists, but not in the global one (that applies to the pure Python implementation). I found the problem! My Python version is likely a newer update of 3.10 than other devs are using (I'm on 3.10.15). Python 3.10.7 introduced a breaking change for type conversion, in order to prevent DOS attacks. So the tests won't fail for Python 3.10 before 3.10.7, and I assume probably won't fail for 3.9.5 or 3.8.10 that are called out in https://github.com/amazon-ion/ion-python/blob/master/README.md. Verified I verified with a build/test on Python 3.9.5 that all tests now pass with flying colours. TL;DR: The tests failing for me shouldn't actually cause test failures in validation analyzers, if they're not using a newer Python than called for in the README. |
I created a separate PR to update the README about setuptools version needs. #373 |
I have code that I want to read in ion data from a file, make a modification, and then write it back out to a file. The file will be source controlled in a version control system.
I want to include trailing commas, e.g.:
That is, a comma after the last item in a list, a comma after the last item in a map, etc.
Ion supports this, which is a huge plus in my book (kudos, Ion!).
This results in diffs that are minimized (if you add or remove a line, there aren't additional lines of diff which only contain addition or removal of a comma), version conflicts are cleaner, and it reduces the likelihood of errors when humans may also edit the files.
I don't think there is any support for asking
dump
ordumps
to include trailing commas (I spent a little time looking for one), so I would love if we could add one. I'm most interested inion.dumps()
, but a flag could be added to any other methods that make sense (dump()
? Others?).- Stephen
P.S. For more on why trailing commas are a good idea, please see On the virtues of the trailing comma.
The text was updated successfully, but these errors were encountered: