Giter Club home page Giter Club logo

Comments (5)

Technologicat avatar Technologicat commented on May 30, 2024

Hi,

Hmm. Let's see if we can figure this out just by looking at the analyzer code. Since it's running the first branch of the if, at least we know that node.value is not None. Then, value = sanitize_exprs(node.value); that's a Pyan internal function, whose result should be a tuple.

It seems that for some reason, sanitize_exprs is returning an empty tuple for this particular input.

To debug further, could you modify your copy of analyzer.py, replacing the visit_AnnAssign method with the version below (there's just one added print), and then post the last thing it printed when it crashes?

    def visit_AnnAssign(self, node):  # PEP 526, Python 3.6+
        target = sanitize_exprs(node.target)
        self.last_value = None
        if node.value is not None:
            value = sanitize_exprs(node.value)
            print(id(node), value, ast.dump(node.value))  # <--- added this print here
            self.logger.debug("AnnAssign %s %s, %s:%s" % (get_ast_node_name(target[0]),
                                                          get_ast_node_name(value[0]),
                                                          self.filename, node.lineno))
            self.analyze_binding(target, value)
        else:  # just a type declaration
            self.logger.debug("AnnAssign %s <no value>, %s:%s" % (get_ast_node_name(target[0]),
                                                                  self.filename, node.lineno))
            self.last_value = None
            self.visit(target[0])
        # TODO: use the type annotation from node.annotation?
        # http://greentreesnakes.readthedocs.io/en/latest/nodes.html#AnnAssign

from pyan.

njordr avatar njordr commented on May 30, 2024

These the values returned:

140309596494816
[]
List(elts=[], ctx=Load())

from pyan.

Technologicat avatar Technologicat commented on May 30, 2024

Thanks! Now I see the problem. node.value is an empty list, so it obviously has no elements.

Since the code triggering the error is just a debug log call, I think it's safe to change the value[0] to just value. It'll sometimes produce a bit more stuff in the debug log, but that should be fine.

Could you try that and report back if it works? If so, I'll push a fix.

from pyan.

njordr avatar njordr commented on May 30, 2024

It works without the index, thanks

from pyan.

Technologicat avatar Technologicat commented on May 30, 2024

Thanks for testing! I'll push a fix.

from pyan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.