Nested autocompletion
Autocompletion (tab) does work here
@pyimport numpy as np
np.linalg.<tab>
but doesn't here
np = pyimport("numpy")
np.linalg.<tab>
This might be a REPL limitation. It would need to evaluate numpy.linalg in order to call propertynames for tab completion, but I don’t think it will evaluate expressions bigger than a single symbol unless they are struct fields.
If you assign linalg to a variable it should work.
That's a bummer. In particular because we deprecated @pyimport in favor of pyimport,
julia> @pyimport numpy as np
┌ Warning: `@pyimport foo` is deprecated in favor of `foo = pyimport("foo")`.
│ caller = _pywrap_pyimport(::PyObject) at PyCall.jl:400
└ @ PyCall C:\Users\carsten\.julia\packages\PyCall\RQjD7\src\PyCall.jl:400
(I can confirm that it works when assigning np.linalg to a variable.)
In particular, we reach this line of REPLCompletions: numpy.linalg is an "advanced expression" that it doesn't want to evaluate.
This is reasonable — I don't think anyone wants REPL tab-completion to just execute arbitrary code, which is what would happen if it automatically called getproperty.
Sorry, @pyimport is not coming back. It's just not a good long-term approach to pre-emptively evaluate every symbol in a Python module and stick them all into a Julia module, and it doesn't work for doubly nested modules or any other Python object. @pyimport was a hack to temporarily work around the lack of dot overloading (which lasted a lot longer than I hoped).
The only way to improve this going forward would be to design an API for the REPL stdlib that tells it when we want it to evaluate getproperty dot expressions during tab completion.
Does https://github.com/JuliaLang/julia/pull/49206 have any impact on this?