Comments (5)
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.
These the values returned:
140309596494816
[]
List(elts=[], ctx=Load())
from pyan.
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.
It works without the index, thanks
from pyan.
Thanks for testing! I'll push a fix.
from pyan.
Related Issues (20)
- __init__() got multiple values for argument 'root' HOT 8
- Integrate modvis.py to main pyan executable
- BrokenPipeError
- Call graph from file contents
- Different order for edges between different calls when several source files are provided
- got multiple values for argument 'root' after upgrade 1.1.1 -> 1.20 HOT 5
- Feature Suggestion: Customize depth (level) of generated graph
- Sphinx integration HOT 1
- FileNotFoundError: [Errno 2] No such file or directory: '' HOT 2
- Tutorial or document
- Is the project still maintained? HOT 4
- Would like to generate call graph for a very basic file HOT 2
- What is "dot"? HOT 1
- Call graphs are wrong -- don't respect namespaces
- [question] What is the intended purpose of white module nodes?
- cannot have a file called โGraph.pyโ that has module level call to a known function HOT 1
- Unable to use Pyan HOT 2
- issue with list comprehension in python 3.12 HOT 5
- Help wanted - sign up here! HOT 5
- CallGraphVisitor wrong parameters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyan.