lyz-code / autoimport

Autoimport automatically fixes wrong import statements.
https://lyz-code.github.io/autoimport
GNU General Public License v3.0
96 stars 24 forks source link

Pre-generate module symbol list #217

Closed char101 closed 2 years ago

char101 commented 2 years ago

Description

One of the most useful use case for auto import is when using PyQt/PySide classes. This poses several problems

  1. ambiguity, the same class exists in both PyQt and PySide and also qtpy
  2. performance, these modules contains a lot of symbols and thus importing it at runtime will add to the execution time

Possible Solution

Pre-generate the symbol list in the modules. This should be manually run by the user. Since python modules can have side effect, importing any/all modules in the PYTHONPATH could be dangerous. Module priority could be defined by using configuration file in the project directory.

lyz-code commented 2 years ago

Hi @char101 thanks for taking the time to open yet another issue :).

Right now we don't analyze all the objects of the packages of the environment, because as you say, it will make the program really slow. There has been some work in progress in this idea, you can see it in #39.

Until that is implemented, you can use common statements both at project level or as a global configuration.

Closing as a duplicate of #39.

If you feel it's not the case we can reopen it