-
-
Notifications
You must be signed in to change notification settings - Fork 774
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
Autoupdate roundtrips. Resolves #210 #211
Conversation
This also doesn't seem to roundtrip lists / indentation. Just comments. So it's an improvement, but not a fix :/ |
f243e93
to
176371b
Compare
I've rebased this, it's still not ready to ship -- I need to work out some bugs with upstream first |
TODO: this doesn't roundtrip for some reason: (it drops the comment) - repo: https://github.com/pre-commit/pre-commit-hooks.git
sha: cf550fcab3f12015f8676b8278b30e1a5bc10e70
# foo
hooks:
- id: trailing-whitespace |
I cannot reproduce the dropping of the comment in you indicate in your post starting with TODO: I wrote a first version of a brute force determination of indent and ran that on that snippet and the YAML files in your repo. Only the travis file doesn't roundtrip and that needs investigating, but its semantics do not change.
|
The only way I get a comment to drop is when it is before a If you want to use ruamel.yaml to rewrite a file and be sure that it doesn't:
the best thing to do IMO is
and don't rewrite/throw a warning that ruamel.yaml couldn't handle the file. |
@AvdN I can probably handle that -- while we're on the subject of |
There RoundTripLoader is the Safe version. The relevant part, its constructor, derives from the SafeConstructor used in safe_load, not from the Constructor used by load. I have a todo item to add functionality to just make a CommentedMap out of mappings with unrecognised tags and preserve the tag value as an attribute ready to write it out. So far nobody asked for this (and I didn't need it myself), because the non-safe loading (and using object tags) is shunted by everyone. |
176371b
to
b2c9ca9
Compare
@AvdN ah, the main reason I ask is this: >>> from ruamel.yaml.compat import ordereddict
>>> import ruamel.yaml
>>> ruamel.yaml.dump(ordereddict(), Dumper=ruamel.yaml.RoundTripDumper)
'!!omap []\n'
>>> ruamel.yaml.load(ruamel.yaml.dump(ordereddict(), Dumper=ruamel.yaml.RoundTripDumper))
ordereddict([]) Is there a different type I should use in my tests other than ordereddict for making yaml structures? |
Yes ordereddict is the superclass of the one actually used to hang the attributes (and above all methods) on, needed for roundtripping:
|
655333b
to
14de344
Compare
14de344
to
08b1b3b
Compare
08b1b3b
to
de33fad
Compare
We'll continue to explore options in #414. |
…ave-shebangs Add a checker for executables without shebangs
No description provided.