Open kbauer opened 3 years ago
Hi @kbauer, thanks for the suggestions, however, all the Spyder completion machinery is delegated to the python-lsp-server and any suggestion would be welcome there, as they would affect other editors or programs that depend on it.
@andfoy, perhaps we should move this one to pyls-spyder?
Issue Report Checklist
Enhancement request, so only a subset applies.
conda update spyder
(orpip
, if not using Anaconda)Problem Description
The python ecosystem discourages in many way the use of star imports. In Spyder this is most visible through "basic linting" complaining, that pyflakes can't analyze undefined names when star-imports are used.
However, the alternative is to constantly manually update import lists, which is undesirable, especially during data analysis tasks.
At this point it would be extremely useful to have a utility, that manages imports; For instance, I'd like to be able to write
x = linspace(0, 1, 101)
and, after pressing some hotkey, be offered to addfrom numpy import linspace
. Not having to worry about the manual imports would put python usage closer in convenience aspects to dedicated data analysis tools like Matlab, where imports are basically automated.Desirable subfeature: Automatic execution of the imports
After an import statement has been added, the user would still have to go back to the top of the file and execute the
#%%
-cell, containing the import statements. This is likewise undesirable; After updating the import statements, they should therefore also be evaluated in the associated console, if any.Desirable subfeature: Cleanup of unused imports
In order to reduce the number of distracting linter warnings, cleaning up imports would also be desirable. For instance, by reducing
from numpy import array, linspace
tofrom numpy import linspace
, ifarray
is never used, or droppingimport os
, ifos
is never referenced.Available infrastructure libraries
The desired functionality is provided by some libraries. Personally, I have experience only with
importmagic
throughimportmagic.el
, from which I know that edge-cases may be an issue. In this case, it failed to provide an autoimport forpprint
, getting confused by the duplicity ofpprint
the module andpprint.pprint
the function.Versions
Python 3.9.4 64-bit | Qt 5.9.7 | PyQt5 5.9.2 | Linux 4.12.14-lp151.28.91-default
Dependencies