On Thursday, November 27, 2025 at 5:20:15 AM UTC-6 Edward K. Ream wrote:

> Aha!  *g.funcToMethod* (a thin wrapper for setattr) can be applied to 
*classes*, not just class *instances!* 

A milestone. The new ATTRIBUTE visitor checks for the attributes of the 
Commands, Position, and leoGlobals modules as follows, where leoC, leoG, 
and leoP are the live c, g, and p objects passed to my @button test script:

def ATTRIBUTE(self, node) -> None:
    if isinstance(node.value, ast.Name):
        base = node.value.id
        attr = node.attr
        table = (
            (leoC, ('c', 'c1', 'c2')),
            (leoG, ('g', 'leoGlobals')),
            (leoP, ('p', 'p1', 'p2')),
        )
        for obj, bases in table:
            if base in bases and not hasattr(obj, attr):
                self.report(messages.UndefinedName, node, f"{base}.{attr}")
                return  # Otherwise pyflakes reports both base and attr as 
changed.

    self.handleChildren(node)

g.funcToMethod(ATTRIBUTE, Checker)

A check of the entire leoApp.py file shows that this no code makes no 
noticeable difference to pyflakes's speed. The patched pyflakes takes 0.05 
sec.

This hack does about 90% of what I've ever wanted an enhanced pylint to do!

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/ed564d73-188e-422f-91d3-fd2787697ff9n%40googlegroups.com.

Reply via email to