Closed SheepDomination closed 5 years ago
Can you be more specific? When the language server analyzes a file, it will first read all of the imports in the file, and analyzes those. Any imported library in a file, or any file in the dependency graph imports, will be analyzed and get IntelliSense.
If you're saying that you're importing a library, and that library's completion is missing some class declared in that library, then we'd like to know about that and reproduce it.
I'm not getting any completion when attempting to work with the loaded classes. Typically if I were to type the name space, I would get prompt with the classes I want to load, although this is not occurring ?
If you have a code example, that'd be better to explain your issue. I'm not sure exactly what a "name space" in the context of python implies. If you import a module, then you can use it and get completion.
That is what I'm having problems with getting a module to load, I was directed that it's due to the Python Language Server and that once it's loaded by the Python Language Server then ctrl+space
(Intellisense) should show when my cursor is above the class then I will see suggestions ?
Screenshot please. It is unclear what do you mean in above
in connection with ctrl+space
.
Correct me if I'm wrong but you load modules with "python.autoComplete.extraPaths"
? And when those modules are loaded; then using the keyboard short-cut ctrl+space
to trigger intellisense when I have my cursor over a class which was loaded by means of python.autoComplete.extraPaths
. I should then see suggestions.
No. Modules are loaded automatically when parser discovers import statement and resolves dependency according to the Python module discovery rules (ie search paths). It is the best to show your code and point at which location you invoke completion
No. Modules are loaded automatically when parser discovers import statement and resolves dependency according to the Python module discovery rules (ie search paths). It is the best to show your code and point at which location you invoke completion
I don't follow exactly ?
Closing this issue. If you have specific scenario, please provide step by step repro with screenshot.
If I understand correctly; if the module is found within the PYTHONPATH
environment variable then it will be loaded into code and therefore I should be able to load all the classes and functions from the module; all using the Python Language Server ?
It does not necessarily need to be in that variable. If you open code which imports a module (import foo
), then that module will be analyzed and will be usable (foo.bar
). You do not need to explicitly tell the language server what to "load"; it will find dependencies as needed and analyze them. extraPaths and PYTHONPATH can help the language server figure out where some modules live in more complicated setups.
I placed the *.pyc
file location into the environment variable in Windows for the variable PYTHONPATH
. Restarted the computer and when typing the class followed by CTRL+SPACE
I don't see suggestions corresponding to the class ?
See above. "Please provide step by step repro with code screenshot." It is unclear what is that you are doing or trying to achieve.
I have a file with a pyc
extension; assuming if the information I was given is correct, this pyc
file contains a class with methods of the class. The goal is when typing the name of the class, whether in a variable or not; I should get a list of suggestions which correspond to the class.
For example, if the class has a method called sheep()
then when typing the name space of the class, in this case ro
then when typing ro
followed by CTRL+SPACE
I should get a list of classes to which I should see the sheep()
method in the list of pre-loaded modules since the setting "python.autoComplete.preloadModules":
loaded all the ro
modules.
To be clear, pyc files are compiled python code which you would not write by hand. You can't put normal python code in a pyc file.
preloadModules
does not exist; this option only ever applied to using Jedi in the VSC python extension and was never implemented in the language server; it is not needed here. It was only used in the extension as a performance hack.
If the pyc file is a library, and exists in some python path (not the file itself "in" the python path, but in "a" python path), then if you do import my_library
, you can do my_library.sheep()
. I.e., if you have C:\random\my_library.pyc
, and do:
"python.autoComplete.extraPaths": ["C:\\random"]
Or add C:\random
to a PYTHONPATH environment variable (which you should not be setting for the entire system, a .env
file would likely be better), then when the language server reads the code import my_library
, it will find my_library.pyc
, scrape, and analyze it. Then, doing my_library.
will show completion for the members we were able to find within that compiled module.
Just note that the above is a confusing setup; it wouldn't really be executable in the python code and has dubious value. Your configuration should be dependent on your project (which is the part you are still not providing).
@jakebailey
Or add C:\random to a PYTHONPATH environment variable (which you should not be setting for the entire system, a .env file would likely be better), then when the language server reads the code import my_library, it will find my_library.pyc, scrape, and analyze it. Then, doing my_library. will show completion for the members we were able to find within that compiled module.
What do you mean setting a .env file would be better; and what type of .env file ?
What is not occurring is, when selecting the method of the class, no brief documentation on the method is shown, as in what the method does ?
You're going to have to provide the a test project for us to work with.
Is it possible that Jedi would work successfully loading the brief documentation but the python language server doesn't work in this sense ?
I did get the libraries to load 👍 but all that is missing is the documentation on the methods in the class.
@jakebailey The python language server does not load up as seen in the screen shot as does Jedi.
What is Jedi doing which the python language server is not;is loading a description of the method as seen on the right of the image ?
The language server does that too. We are not aware of any issues showing that info. We cannot reproduce your issue if you do not provide the actual code that causes the issue.
This thread has moved past the original issue reported. When you have something we can test, we'd appreciate a new filed issue that we can handle, versus using an unrelated one.
@jakebailey I have attached the file; if you can get what you see in the previous screen shot to load with the python language server, I would like to know how; as I can only get it loaded with Jedi with is being phased out ?
Thanks for the file, I can look at that now. I can see those docs in the file, so maybe our scraper isn't doing the right thing. I'll file a different issue for this, given the issue was not loading, but this is a doc problem.
Jedi is still not the default, you can continue to use it if it works better for you.
@jakebailey The python language server is not loading the docs ? I can continue to use Jedi but it's slow compared to the python language server. What do you mean this is a doc problem; can it be resolved ?
@jakebailey I recently updated to Code 1.35.0; any word on when this issue will be resolved ?
I opened #1165, which you can follow. Our releases are not related to VS Code's.
As far as I can tell, Houdini python files exist somewhere on the disk, which you may want to give via extraPaths or PYTHONPATH for us to read (instead of random pyc files, which we may not be able to load, I certainly wasn't able to import that pyc file you provided), but past that, I do not have any more information.
I found an extra file which may help with the documentation, it is a *.pyd
file would that help in resolving this issue; as I have included this file within the extraPaths and PYTHONPATH
Please, comment on the other issue. #1165
extraPaths and PYTHONPATH are lists of directories (ignoring the special case of zip files, which we don't support). Putting pyc/pyd files in them will not do anything, as they are not import roots.
The Python Language Server is loading some specific python libraries; but when using Intellisense to access the libraries, there is no list of the classes which I can load ?