Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested autocompletion #667

Open
carstenbauer opened this issue Mar 18, 2019 · 4 comments
Open

Nested autocompletion #667

carstenbauer opened this issue Mar 18, 2019 · 4 comments

Comments

@carstenbauer
Copy link
Contributor

Autocompletion (tab) does work here

@pyimport numpy as np
np.linalg.<tab>

but doesn't here

np = pyimport("numpy")
np.linalg.<tab>
@stevengj
Copy link
Member

stevengj commented Mar 18, 2019

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.

@carstenbauer
Copy link
Contributor Author

carstenbauer commented Mar 18, 2019

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.)

@stevengj stevengj changed the title Autocompletion bug Nested autocompletion Mar 18, 2019
@stevengj
Copy link
Member

stevengj commented Mar 18, 2019

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.

@antoine-levitt
Copy link

Does JuliaLang/julia#49206 have any impact on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants