rope icon indicating copy to clipboard operation
rope copied to clipboard

investigate better approach to patchedast

Open enomado opened this issue 6 years ago • 11 comments

Just to summarize some possible alternatives:

enomado avatar Mar 19 '18 00:03 enomado

I'm familiar with these. What's the problem you are trying to resolve that makes any of these better?

soupytwist avatar Mar 19 '18 17:03 soupytwist

Current architecture of patchedast is limited and can't parse all code. It can be proved by traversing site-packages and applying it to files. Or just write some rich function call or multiline string with nested bracket to feel that the task requires full parsing approach instead of ad-hoc lookahead and manual assumptions about a next node.

enomado avatar Mar 20 '18 01:03 enomado

Current architecture of patchedast is limited and can't parse all code.

How patchedast is related to parsing? Do you understand what parsing is about? Rope uses python's native parser https://docs.python.org/3/library/parser.html

architecture of patchedast is limited

What exactly limitation on architecture level do you mean?

I understand some advantages of astroid, but they mainly are not related to parsing.

emacsway avatar Mar 20 '18 02:03 emacsway

How patchedast is related to parsing? Do you understand what parsing is about? Rope uses python's native parser

Well okay. What do you think patchedast do ? It parses python code with little help of parsed ast because python's parser (surprisingly) cant parse pythons code with column resolution.

What exactly limitation on architecture level do you mean?

I mean that its exactly not a parser, but should be. Currently it tries to assume pos of nodes ad-hoc, without any 'parsing things' like stacks, automata (sorry for such silly terms, I guess you got what I mean).

enomado avatar Mar 20 '18 18:03 enomado

It parses python code with little help of parsed ast because python's parser (surprisingly) cant parse pythons code with column resolution.

  • Can you give me any test case to reproduce any problem of python's native parser?

emacsway avatar Mar 20 '18 20:03 emacsway

Existence of https://github.com/python-rope/rope/blob/master/rope/refactor/patchedast.py is a good proof I guess. If i'm wrong and pythons parser can parse python code i'll be very happy

enomado avatar Mar 20 '18 20:03 enomado

At what line of the file do you see a good proof?

emacsway avatar Mar 20 '18 20:03 emacsway

Whole file, purpose of the file. Stop trolling please. If you are sure the problem is 100% gone since 2012 and python parser have good column resolution so okay then we can close the ticket...

enomado avatar Mar 20 '18 20:03 enomado

Can you call me with Skype to discuss this? My skypename is industrialnet.

emacsway avatar Mar 20 '18 20:03 emacsway

yes, astroid solves some issues of rope, but its implementation requires a lot of works.

emacsway avatar Mar 21 '18 15:03 emacsway

I've messed around with removing the patchedast. It provides two things:

  1. Sorted children, which afaik isn't directly used
  2. Region of code.

Since rope reads everything into a single line, using the standard ast would break region based functionality. Regardless, I am working on a solution using standard ast. If we can use parso, we'll get error recovery and port some of my autoimport code from pylsp.

bagel897 avatar Jun 02 '22 07:06 bagel897