admin管理员组文章数量:1122846
I'm working with Python in an environment where there are some classes which are defined externally (as in, I don't have access to the files where these classes are defined). So I can import these classes and use them, but since VSCode can't resolve the import, there's no autocomplete for them.
What I would want: a way to tell VSCode which attributes and methods these classes have, so it can autocomplete for me whenever I use them (same as if I had these classes defined in my workspace and imported normally). Is this possible somehow?
I'm working with Python in an environment where there are some classes which are defined externally (as in, I don't have access to the files where these classes are defined). So I can import these classes and use them, but since VSCode can't resolve the import, there's no autocomplete for them.
What I would want: a way to tell VSCode which attributes and methods these classes have, so it can autocomplete for me whenever I use them (same as if I had these classes defined in my workspace and imported normally). Is this possible somehow?
Share Improve this question asked Nov 21, 2024 at 17:32 Julian LJulian L 1351 silver badge5 bronze badges 2 |1 Answer
Reset to default 2Autocomplete and IntelliSense are provided for all files within the current working folder in VSCode. They're also available for Python packages that are installed in standard locations.
To enable IntelliSense for packages that are installed in non-standard locations, add those locations to the python.autoComplete.extraPaths
collection in your settings.json
file.
Ref:https://code.visualstudio.com/docs/python/settings-reference#_autocomplete-settings
本文标签: pythonVSCode Add custom autocomplete to known external classesStack Overflow
版权声明:本文标题:python - VSCode: Add custom autocomplete to known external classes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308428a1933656.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
IntelliCode
andPylance
create the functionality you're looking for. If intellisense programs can't find or recognize the classes in your environment, they won't give you intelligent recommendations and code completion for them. If you aren't usingIntelliCode
orPylance
, try that first. If that doesn't help, you could write copies of the classes in your own local module to import (if you're able to read them). – Mason Ritchason Commented Nov 21, 2024 at 20:39Python > Auto Complete: Extra Paths
. I don't know exactly what environment you are pulling these classes from, but this setting allows you to put external sources for modules in your VSC client'ssettings.json
file. – Mason Ritchason Commented Nov 21, 2024 at 20:42