Python VSCode 的自动导入扩展
Python auto import extension for VSCode
是否有 Python 自动导入 extension/plugin 可用于 Visual Studio 代码?
我所说的自动导入是指自动导入 python 个模块。 Eclipse 和 Intellij 具有 Java.
的此功能
没有,但它很快就会成为 vscode-python 的一部分:https://github.com/Microsoft/vscode-python/pull/636
编辑:请参阅@Eric 的回答,他构建了这样一个扩展。
编辑 2:参见@Eyal Levin 的回答,提到了这样的扩展 (Pylance)。
我建造了 an automatic import extension that supports Python。它允许您完全自定义将导入写入文件的方式,修改导入路径、名称、相对于其他导入的排序。 Python 插件甚至可以让您 "group" 与额外的换行符一起导入。
来自https://github.com/microsoft/python-language-server/issues/19#issuecomment-587303061:
For those who wonder how to trigger auto-importing as I did, here are
the steps.
- Enable Microsoft Python Language Server by removing the check of
Python: Jedi Enabled
in your settings.
- Reload the VSCode window.
- Hover your mouse over the variable that you want to import, and click
Quick
fix...
For the last step, if it shows No quick fixes available
or
Checking for quick fixes
, you may need to wait for a while until the
extension has finished code analysis. It is also possible to set a
shortcut that triggers a quick fix.
VSCode 团队最近发布 Pylance
Features
- Docstrings
- Signature help, with type information
- Parameter suggestions
- Code completion
- Auto-imports (as well as add and remove import code actions)
- As-you-type reporting of code errors and warnings (diagnostics)
- Code outline
- Code navigation
- Code lens (references/implementations)
- Type checking mode
- Native multi-root workspace support
- IntelliCode compatibility
- Jupyter Notebooks compatibility
我用这个包很好用
https://marketplace.visualstudio.com/items?itemName=codeavecjonathan.importmagic
您可以在 VSCode 扩展商店中找到它。它的名字是 IMPORTMAGIC。它工作得很好。它将包括您在脚本中使用的所有模块。
它有代码操作 ctrl + . ,它也将导入库。
是否有 Python 自动导入 extension/plugin 可用于 Visual Studio 代码?
我所说的自动导入是指自动导入 python 个模块。 Eclipse 和 Intellij 具有 Java.
的此功能没有,但它很快就会成为 vscode-python 的一部分:https://github.com/Microsoft/vscode-python/pull/636
编辑:请参阅@Eric 的回答,他构建了这样一个扩展。
编辑 2:参见@Eyal Levin 的回答,提到了这样的扩展 (Pylance)。
我建造了 an automatic import extension that supports Python。它允许您完全自定义将导入写入文件的方式,修改导入路径、名称、相对于其他导入的排序。 Python 插件甚至可以让您 "group" 与额外的换行符一起导入。
来自https://github.com/microsoft/python-language-server/issues/19#issuecomment-587303061:
For those who wonder how to trigger auto-importing as I did, here are the steps.
- Enable Microsoft Python Language Server by removing the check of
Python: Jedi Enabled
in your settings.- Reload the VSCode window.
- Hover your mouse over the variable that you want to import, and click
Quick fix...
For the last step, if it shows
No quick fixes available
orChecking for quick fixes
, you may need to wait for a while until the extension has finished code analysis. It is also possible to set a shortcut that triggers a quick fix.
VSCode 团队最近发布 Pylance
Features
- Docstrings
- Signature help, with type information
- Parameter suggestions
- Code completion
- Auto-imports (as well as add and remove import code actions)
- As-you-type reporting of code errors and warnings (diagnostics)
- Code outline
- Code navigation
- Code lens (references/implementations)
- Type checking mode
- Native multi-root workspace support
- IntelliCode compatibility
- Jupyter Notebooks compatibility
我用这个包很好用
https://marketplace.visualstudio.com/items?itemName=codeavecjonathan.importmagic
您可以在 VSCode 扩展商店中找到它。它的名字是 IMPORTMAGIC。它工作得很好。它将包括您在脚本中使用的所有模块。
它有代码操作 ctrl + . ,它也将导入库。