On Feb 15, 10:53 am, "Edward K. Ream" <[email protected]> wrote:

> I want to convert ast trees to trees of pylint nodes so that the
> "peepholes" will have complete freedom to munge the tree as they
> please.

I was mistaken.  This does not seem to be a big issue.  Most of the
checkers (files in the pylint-0.19.0\checkers directory) are
relatively straightforward.  The tree interface that the checkers use
isn't complex, so the checkers would not be greatly simplified with a
simpler tree design.

I have found the rabbit hole that leads to Wonderland, namely the
following two checkers:

1. VariablesChecker.visit_name (checkers/variables.py) checks that
names are defined.

2. TypeChecker.visit_callfunc (checkers/typecheck.py) checks that
function calls make sense.

I would be willing to throw away almost everything but these two
tests.

visit_name is hairy code, but it is self-contained.  See the
"_to_consume" logic.  It does not use any inference machinery.

visit_callfunc checks that the called function or method is
**inferred** to be a callable object as follows:

    called = safe_infer(node.func)
    if called is not None and not called.callable():
        self.add_message('E1102', node=node,
args=node.func.as_string())
        # The E1102 messages says <x> is not callable.

I am still mostly clueless about how the inference machinery works,
but now I have something specific to study, namely the call to
safe_infer(node.func).  This is good progress.

Edward

P.S. Although the checkers themselves are relatively simple, the
inference machinery contained in the astng classes is anything but
simple.  It may well be true that rewriting those classes to use
multiple passes would be a good thing. We shall see...

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to