Open niloc132 opened 3 months ago
It feels like this is definitely a bug, _merge_name_docs
should not be called like this I guess. There are other cases where RecursionErrors could be caused by legitimate cases, but this is not inference.
If you want to help, it would really be awesome to have a smaller reproducer for this. This is probably reproducible with a few lines of Python code.
I got annoyed by my editor lagging out whenever I typed np.
, so I trimmed it down a simple reproducer: https://github.com/yut23/jedi/commit/99e811ae152e9de7262211bd0942efd2660aadbb
The important part appears to be that the inner stub imports matrix
from the outer module with an alias. Changing that line to from repro2020 import matrix
makes the RecursionError go away.
Thank you for working on this - I managed to break it down so that I could add the bug to numpy 1.26, or remove it from 2.0.x, but was not able to reproduce it in a small, simple project. Your example has the highlights: either replace the matrix as matrix
with just matrix
in inner/__init__.pyi
or change the import in __init__.py
to use a wildcard - either change and the bug will go away.
Also, and I'm not sure if this is a bug, but omitting the inner/__init__.pyi
file will result in repro2020.matrix
being described by jedi as having a "module" type rather than a "class" type.
That sounds really strange. But I guess if that reproduces it, I'm very happy you made it work @yut23.
Does the traceback still look the same? With a lot of _merge_name_docs
in there?
I'm not surprised that there is a RecursionError, but I'm surprised that that case comes from _merge_name_docs
.
Steps to reproduce:
Install latest jedi (currently 0.19.1) and numpy (verified with 2.0.0 and 2.0.1)
Verify versions
Try to read the type of
numpy.finfo
:Workaround
If you have already imported the
numpy
module, this will not happen, as long as you don't hit cached results (i.e.import numpy
above before theInterpreter
is created). This suggests to me at least that this is an edge case in reading types from not-yet-imported modules, rather than a general issue.On the other hand, a call to
jedi.preload_module("numpy")
does not resolve this by itself resolve this.