You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VSCode中启用flake8-docstring插件的代码检查提示?

解决VSCode中flake8-docstring规则不生效的问题

检查VSCode基础代码检查配置

  • 打开VSCode设置,搜索python.linting.flake8Enabled,确保勾选为true
  • 搜索python.linting.enabled,确认全局代码检查功能已开启

验证flake8-docstring插件加载状态

在PowerShell中执行flake8 --version,输出内容里需包含flake8-docstring的版本信息,示例如下:

3.9.2 (flake8-docstring: 1.6.0, mccabe: 0.6.1, pycodestyle: 2.7.0, pyflakes: 2.3.1) CPython 3.9.7 on Windows

若未显示该插件信息,重新执行pip install flake8-docstring完成安装

配置flake8启用docstring规则

在项目根目录创建.flake8配置文件,添加以下内容:

[flake8]
select = D100,D101,D102,D103,D104,D105,D106,D107

其中select字段指定了需要启用的所有docstring相关规则,D100就是你遇到的模块缺失文档字符串的规则

重启VSCode加载配置

按Ctrl+Shift+P(Windows/Linux)或Cmd+Shift+P(Mac),选择Reload Window选项,让新配置生效

确认Python解释器一致性

确保VSCode使用的Python解释器与PowerShell中执行python --version的解释器为同一版本:

  • 点击VSCode右下角的Python版本号,切换到对应解释器
  • 或在设置中搜索python.pythonPath,设置为你正在使用的Python路径

内容的提问来源于stack exchange,提问作者Selva

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 18:35:11