Python in Visual Studio Code 八月更新 Python 扩展的开发者容器、运行带参数的文件的调试器配置、容错 Pytest 发现 - V2EX
首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  
登录
Visual Studio Code
V2EX
Visual Studio Code
Python in Visual Studio Code 八月更新 Python 扩展的开发者容器、运行带参数的文件的调试器配置、容错 Pytest 发现
winffe
2023-08-07 17:36:05 +08:00
1482 次点击
这是一个创建于 863 天前的主题,其中的信息可能已经有所发展或是发生改变。
我们很高兴地宣布 Visual Studio Code 的 [Python](
https://marketplace.visualstudio.com/items?itemName=ms-python.python
) 和 [Jupyter](
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
) 扩展将于 2023 年 8 月发布!
此版本包括以下更新:
- Python 扩展的开发者容器
- 使用参数运行 Python 文件的调试配置
- Python 扩展 API 的 npm 包
- 容错 Pytest 发现
如果您有兴趣,可以在我们的 [Python](
https://github.com/microsoft/vscode-python/releases)、
[Jupyter](
https://github.com/microsoft/vscode-jupyter/blob/main/CHANGELOG.md
) 和 [Pylance](
https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md
) 扩展更新日志中查看完整的改进列表。
# Python 扩展的开发者容器
[Python 扩展的源存储库](
https://github.com/microsoft/vscode-python)中现在有一个
[开发容器](
https://code.visualstudio.com/docs/devcontainers/containers)。使用此自定义的开发容器,贡献者可以在
[GitHub Codespaces](
https://github.com/features/codespaces
) 中打开 Python 扩展存储库,并进行开发和测试 Python 扩展,而无需其他安装。由于我们启用了[预生成](
https://docs.github.com/en/codespaces/prebuilding-your-codespaces/about-github-codespaces-prebuilds),因此开发容器可以快速加载。
Python 版本 3.7 、3.8 、3.9 、3.10 和 3.11 已预装,因此您可以使用 pyenv 轻松地在 Python 版本之间切换。dev 容器还配置了开发所需的扩展,包括 [Pylance](
https://github.com/microsoft/pylance-release
) 和 [Black 格式化程序](
https://github.com/microsoft/vscode-black-formatter)扩展。
# 运行带参数的文件的调试器配置
新的 [Debugpy 扩展](
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy)现在提供“带参数的”
launch.json 配置,当您次运行代码或调试器配置时,可以为 Python 文件提供不同的输入值而无需重复运行代码或调试器配置,这非常有用。
若要使用此配置,请确保已安装[Debugpy 扩展](
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy)。然后使用快捷键
`Ctrl + Shift + D` 或 ` + + D` 打开**“Run and Debug”**视图,然后单击**Create a launch.json file**或齿轮图标以访问 `launch.json` 。选择**Debugpy**,然后从可用配置中选择**Python: File with Arguments**。
然后,打开要调试的 Python 文件,该文件需要命令行参数。若要开始调试,请使用快捷键 `F5`或 **Run > Start Debugging**。将出现一个提示,允许您输入应传递给 Python 文件的所需参数。
输入参数后,按 Enter ,调试器将启动,让您单步执行代码!
[点此查看演示视频!](
https://devblogs.microsoft.com/python/wp-content/uploads/sites/12/2023/08/debugpy-args-prompt.mp4?_=1
)
主题: [Catppuccin Macchiato](
https://marketplace.visualstudio.com/items?itemName=Catppuccin.catppuccin-vsc
) (preview on [
vscode.dev
](
https://vscode.dev/theme/Catppuccin.catppuccin-vsc/Catppuccin%20Macchiato
))
# Python 扩展 API 的 npm 包
[Python 扩展](
https://marketplace.visualstudio.com/items?itemName=ms-python.python)现在提供了一个
npm 包,使其他扩展作者更容易访问和跟踪 Python 扩展 API 中的更改。查看 [@vscode/python-extension](
https://www.npmjs.com/package/@vscode/python-extension
) npm 模块,以使用计算机上可用的 Python 环境。
# 容错 Pytest 发现
“测试资源管理器”面板现在支持容错 pytest 发现作为[新测试体系结构](
https://devblogs.microsoft.com/python/python-in-visual-studio-code-june-2023-release/#test-discovery-and-execution-rewrite)中包含的一项功能。如果
pytest 在发现过程中遇到可管理的错误(例如未知导入),则仍将在包含该错误的文件之外发现所有剩余的测试。此功能仅在实验功能后面的新测试重写中可用。重写目前对所有的预发布用户和 25% 的发布用户开放,但将在不久的将来普遍推出。同时,您可以继续使用该设置 `pythonTestAdapter` 选择使用或禁用。
其他更改和增强功能
我们还添加了用户请求的小增强功能和修复的问题,这些问题应该可以改善您在 Visual Studio Code 中使用 Python 和 Jupyter Notebooks 的体验。一些值得注意的变化包括:
- 导入解析错误显示有关正在使用的环境的详细信息 ([@pylance-release#4368](
https://github.com/microsoft/pylance-release/issues/4368))。
- 依赖项文件中的**Create Environment**按钮的删除将根据反馈向 100% 的用户推出 ([@vscode-python#20982](
https://github.com/microsoft/vscode-python/issues/20982))。
- **专用终端中的运行文件**重新添加为运行配置 ([@vscode-python#21282](
https://github.com/microsoft/vscode-python/issues/21282))。
我们还要特别感谢本月的贡献者:
- [@Imgarret](
https://github.com/lmgarret)帮助归档问题,并为与新测试重写(
[@vscode-python#21578](
https://github.com/microsoft/vscode-python/issues/21578
) 和 [@vscode-python#21579](
https://github.com/microsoft/vscode-python/issues/21579))相关的
pytest 测试类、错误和跳过标志创建了测试用例。
- [@Jammf](
https://github.com/Jammf
) 对 vscode-mypy 做出了第一个贡献,以修复使用 follow-imports=normal ([@vscode-mypy#76](
https://github.com/microsoft/vscode-mypy/pull/76))
时出现的错误。
- [@PeterJCLaw](
https://github.com/PeterJCLaw
) 对 VSCODE-myPY 做出了第一个贡献,以删除可能与项目冲突的后续导入参数 ([@vscode-mypy#90](
https://github.com/microsoft/vscode-mypy/pull/90))。
# 征集社区反馈
由于我们正在规划和确定未来工作的优先级,我们重视您的反馈!以下是我们希望反馈的几个问题:
- 支持通过双击 numpy 和 pickle 文件原生查看它们:[@vscode-python#21443](
https://github.com/microsoft/vscode-python/issues/21443
)
- 通过右键单击文件添加对在当前虚拟环境中安装 `requirements.txt` 的支持:[@vscode-python#21555](
https://github.com/microsoft/vscode-python/issues/21555
)
- 配置 `launch.json` 中的动态模块路径:[@vscode-python#21449](
https://github.com/microsoft/vscode-python/issues/21449
)
此外,提醒一下,[功能请求标签的问题](
https://github.com/microsoft/vscode-python/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request)需要在开放后的
60 天内获得 7 个赞成票才能发布,以衡量社区的兴趣。我们以此作为确定即将进行的工作优先级的另一种方式。
通过从 Marketplace 下载 [Python 扩展](
https://marketplace.visualstudio.com/items?itemName=ms-python.python)和
[Jupyter 扩展](
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter)来尝试这些新的改进,或者直接从
Visual Studio Code 中的扩展视图安装它们( `Ctrl + Shift + X` 或 ` + + X` )。您可以在文档中了解有关 Visual Studio Code 中[Python 支持的更多信息](
https://code.visualstudio.com/docs/python/python-tutorial)。如果您遇到任何问题或有建议,请在
[Python VS Code GitHub 页面](
https://github.com/Microsoft/vscode-python)上
[提交问题](
https://github.com/microsoft/vscode-python/issues/new/choose)。
目前尚无回复
Python
扩展
文件
pytest
关于
帮助文档
自助推广系统
博客
API
FAQ
Solana
5211 人在线
最高记录 6679
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 32ms
UTC 08:35
PVG 16:35
LAX 00:35
JFK 03:35
Do have faith in what you're doing.
ubao
msn
snddm
index
pchome
yahoo
rakuten
mypaper
meadowduck
bidyahoo
youbao
zxmzxm
asda
bnvcg
cvbfg
dfscv
mmhjk
xxddc
yybgb
zznbn
ccubao
uaitu
acv
GXCV
ET
GDG
YH
FG
BCVB
FJFH
CBRE
CBC
GDG
ET54
WRWR
RWER
WREW
WRWER
RWER
SDG
EW
SF
DSFSF
fbbs
ubao
fhd
dfg
ewr
dg
df
ewwr
ewwr
et
ruyut
utut
dfg
fgd
gdfgt
etg
dfgt
dfgd
ert4
gd
fgg
wr
235
wer3
we
vsdf
sdf
gdf
ert
xcv
sdf
rwer
hfd
dfg
cvb
rwf
afb
dfh
jgh
bmn
lgh
rty
gfds
cxv
xcv
xcs
vdas
fdf
fgd
cv
sdf
tert
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
sdf
shasha9178
shasha9178
shasha9178
shasha9178
shasha9178
liflif2
liflif2
liflif2
liflif2
liflif2
liblib3
liblib3
liblib3
liblib3
liblib3
zhazha444
zhazha444
zhazha444
zhazha444
zhazha444
dende5
dende
denden
denden2
denden21
fenfen9
fenf619
fen619
fenfe9
fe619
sdf
sdf
sdf
sdf
sdf
zhazh90
zhazh0
zhaa50
zha90
zh590
zho
zhoz
zhozh
zhozho
zhozho2
lislis
lls95
lili95
lils5
liss9
sdf0ty987
sdft876
sdft9876
sdf09876
sd0t9876
sdf0ty98
sdf0976
sdf0ty986
sdf0ty96
sdf0t76
sdf0876
df0ty98
sf0t876
sd0ty76
sdy76
sdf76
sdf0t76
sdf0ty9
sdf0ty98
sdf0ty987
sdf0ty98
sdf6676
sdf876
sd876
sd876
sdf6
sdf6
sdf9876
sdf0t
sdf06
sdf0ty9776
sdf0ty9776
sdf0ty76
sdf8876
sdf0t
sd6
sdf06
s688876
sd688
sdf86