Skip to content
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 remove spaces after called object #42

Open
kayhayen opened this issue Nov 28, 2014 · 2 comments
Open

Cannot remove spaces after called object #42

kayhayen opened this issue Nov 28, 2014 · 2 comments

Comments

@kayhayen
Copy link

I was trying to remove spaces from inbetween called object and call brace:

from redbaron import RedBaron
red = RedBaron("called (it)")

call (it)

The "call" node seems to have it:

red[0]1
red[0][1].type
'call'

The node_list doesn't have it:

red[0][1].node_list
0 it
red[0][1].node_list[0]
it

So, I was trying this:

red[0][1].first_formatting = ""
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/redbaron.py", line 1708, in setattr
super(CallNode, self).setattr(key, value)
File "/usr/local/lib/python2.7/dist-packages/redbaron.py", line 891, in setattr
value = self._convert_input_to_node_object_list(value, self, name)
File "/usr/local/lib/python2.7/dist-packages/redbaron.py", line 151, in _convert_input_to_node_object_list
return self._string_to_node_list(value, parent=parent, on_attribute=on_attribute)
File "/usr/local/lib/python2.7/dist-packages/redbaron.py", line 1705, in _string_to_node_list
raise Exception("Unhandled case")

I am assuming that this ought to work, second, and third formatting neither
work. Please consider implementing it. :-)

@Psycojoker
Copy link
Member

Confirmed (to be honest, I was more expecting people to start using RedBaron for code modification than for formatting modification, this part is a bit lacking right now, I'm going to improve it, thanks for you feedback :)).

@kayhayen
Copy link
Author

Hello Laurent,

Am 29.11.2014 um 14:23 schrieb Laurent Peuch:

Confirmed (to be honest, I was more expecting people to start using
RedBaron for code modification than for formatting modification, this
part is a bit lacking right now, I'm going to improve it, thanks for you
feedback :)).

Just as an aside. Nuitka is a Python compiler, and currently uses the
"ast" module. I am in fact evaluating redbaron for three directions:

a) Writing an "autoformat" tool that applies my favorite coding style to
Nuitka, and potentially projects at work. Some of these have large, and
very inconsistent code bases, reflecting the evolution of my idea of
proper code formatting over time, or multiple persons having an
evolution over years.

While I love having that, and it saves me time, and improves
consistency, it's not the most important thing to me.

b) For Nuitka to produce proper reports of what happened after parsing,
during optimization, and links to generated code, the bounding box of
expressions, really is very interesting. Right now, I only get the
column to my source code references, which largely is not good for any
formatting, as e.g. MicroPython does.

This is actually very important to me. Getting the bounding box of
expressions and statements right will make a visual difference there.

c) For Nuitka the "ast" tree does a pretty decent job. However, it is
tied to the executing Python version. Should you manage to be able to
parse Python3 and Python2 grammars, Nuitka would be enabled to parse
Python2 code with Python3 run time, and potentially provide a more
compatible means of execution in many instances. Kind of a "from python2
import python2syntaxmodule" and enable it to run in Python3 environment
via proxy objects, or whatever.

All of this is not happening today or even tomorrow. Right now, I found
that the completeness of RedBaron is lacking (see my other issues), and
I am now raising issues that come from running Nuitka in that environment.

This is just so you realize, that I am seriously evaluating this. And
that I appreciate RedBaron as a whole.

Yours,
Kay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants