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
Cannot modify spaces after trailing comma #39
Comments
Hello, The problem you are facing right now is that, by default, RedBaron hides from you the comma tokens using ProxyList has described here: https://redbaron.readthedocs.org/en/latest/proxy_list.html The unproxyfied list is accessible using ".node_list": https://redbaron.readthedocs.org/en/latest/proxy_list.html#access-the-unproxified-node-list You have several solutions to go to the last comma: from redbaron import RedBaron
red = RedBaron("(self, )")
red[0].value.node_list[-1].second_formatting = ""
red[0]("comma", recursive=False)[-1] Is this help? I'm wondering on how to makes this more obvious to people (this is already describe at the end of the tutorial and in the documentation :/). |
Hello Laurent,
That works, with the gotcha, that I need to consider "with_parenthesis", a, = b which is different (to me) from (a, ) = b A relatively constant theme, is that I do not always agree, where I understand for strings, that "a" "b" is legal, and that the But this leads to calls: call( 1 ) having entirely different assignment of spaces for the call node. So my code checks for string arguments, and treats them differently, as But I don't understand the difficulties of inserting items properly Yours, |
A solution for this case would be to always remove it from the last I don't know if this is an acceptable solution for you, please let me
Indeed, you are correct, the string here are greedy on getting Laurent Peuch -- Bram |
String aren't greedy anymore so this shouldn't be a problem now, don't hesitate to complain if it's still the case. |
Great, just ran it with 0.3 over my code, and it found a few extra places to correct. |
The following code:
(self, )
Note the trailing space after the comma. I was writing a modifier that removes trailing and leading spaces. And came up with this:
Note, that I find it strange, that I need to drop leading spaces from contained strings (same for
call nodes, strings seem to attract whitespace for no good reason, where I would naturally attribute it to the outside). I tried setting all four formattings to "x#", and this resulted a string containing them, plus still a space after the comma. Where is it hiding? The name typed argument doesn't indicate anything in its dict.
The text was updated successfully, but these errors were encountered: