You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-4-0a19b019c67b> in <module>
----> 1 print(next(funcdef._infer()))
/dat/uber/prod/python/venv/py_3.7.4_prod_20200604_0/lib/python3.7/site-packages/astroid/inference.py in _cached_generator(func, instance, args, kwargs, _cache)
957 @wrapt.decorator
958 def _cached_generator(func, instance, args, kwargs, _cache={}):
--> 959 node = args[0]
960 try:
961 return iter(_cache[func, id(node)])
IndexError: tuple index out of range
This is actually a combination of two bugs:
astroid.inference._cached_generator is decorated by wrapt.decorator. And in the mean time you try to access node instance via node = args[0]. This is incorrect, you should use node = instance instead.
Steps to reproduce
Run following code:
Current behavior
This is actually a combination of two bugs:
astroid.inference._cached_generator
is decorated bywrapt.decorator
. And in the mean time you try to access node instance vianode = args[0]
. This is incorrect, you should usenode = instance
instead.NodeNG.infer
calls_infer
withcontext
as positional argument instead of keyword one. See https://github.com/PyCQA/astroid/blob/master/astroid/node_classes.py#L363 and https://github.com/PyCQA/astroid/blob/master/astroid/node_classes.py#L371. That's why this error never happens in usual workflow.Since
_cached_generator
works not as expected, this may also have some impact on inference caching, but I did not encounter any other issues here.Expected behavior
No error
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output2.4.1
The text was updated successfully, but these errors were encountered: