Repository navigation
Can not auto-import local files #7631
|
Hello. I have a strange problem with my pyright. Currently im trying to make it work on LazyVim but i checked also on other vim editions and VSCode and keep getting same result. For some weird reason, pyright doesnt allow me to auto-import classes from local files, but works perfectly for builtin libraries and venv. I think the problem is in config or maybe some weird cached settings, because it stopped working in every project i have. I created a small draft project to showcase my config and structure that i use to test now. Can anyone please point me to a documentation how to properly debug my issue and where to look at? |
Replies: 1 comment 2 replies
|
The auto-import mechanism in pyright is relatively limited. It works off of its internal memory-based cache. If the type checker hasn't seen the file (either via an import or by opening the file), it will not have symbols for that file cached. Pyright is primarily focused on type checking. It has some limited language server features, but it's meant to be the foundation for more sophisticated language server features. Pylance is Microsoft's premium Python language server, and it includes many additional features. One of those features is an indexing mechanism that builds and maintains an index of symbols in all files in your project and all installed packages. This allows it to provide complete auto-import suggestions. If you want this functionality, I recommend switching to Pylance. It's licensed for use in VS Code. If you want to stick with pyright, one workaround is to set the |

The auto-import mechanism in pyright is relatively limited. It works off of its internal memory-based cache. If the type checker hasn't seen the file (either via an import or by opening the file), it will not have symbols for that file cached.
Pyright is primarily focused on type checking. It has some limited language server features, but it's meant to be the foundation for more sophisticated language server features. Pylance is Microsoft's premium Python language server, and it includes many additional features. One of those features is an indexing mechanism that builds and maintains an index of symbols in all files in your project and all installed packages. This allows it to provide co…