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
Can't get return in assignments #96
Comments
Hello, The support regarding formatting modification isn't very well integrated into RedBaron yet but it's accessible. The way to go to find this kind of information is to use Which gives this in your case: In [2]: RedBaron("a = 1").help(with_formatting=True)
0 -----------------------------------------------------
AssignmentNode()
# identifiers: assign, assignment, assignment_, assignmentnode
operator=''
target ->
NameNode()
# identifiers: name, name_, namenode
value='a'
value ->
IntNode()
# identifiers: int, int_, intnode
value='1'
first_formatting ->
* SpaceNode()
# identifiers: space, space_, spacenode
value=' '
second_formatting ->
* SpaceNode()
# identifiers: space, space_, spacenode
value=' ' Therefor: In [7]: RedBaron("a =\\\n 2")[0].second_formatting
Out[7]: 0 '\\\n ' Hope that helps, |
Hello, Sorry for late answer. Your example can't be used in my project. I will explain why. When I compare '\n ' with body_line.second_formatting[0].value, it always gives False result. Even if I copy value from debugging console and past it to Watches window in PyCharm (print screen is attached). Here is input test. And my code:
Print screen of debugging process: I found another solution for my problem - getting position by absolute_bounding_box and comparing lines, but I want to know how to get comparison by returns. It still doesn't work like standard strings in Python. |
If you only want to see if a "\n" is present in the string you can do it this way: In [6]: "\n" in RedBaron("a =\\\n 2")[0].second_formatting.dumps()
Out[6]: True And this other way works too but is less general:
|
Yes, it is what I want, but it doesn't work in this test case:
Sorry for tediousness - I am implementing Python analyzer and need to check all test cases. absolute_bounding_box is still the only solution. |
Here is code"
It is impossible to get return. Here is what I am doing:
It doesn't print True. Is it bug or I am wrong? How can I detect that assignment is defined in a separated lines?
The text was updated successfully, but these errors were encountered: