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

如何在VS Code中启用/禁用特定Pylint检查消息?

解决VS Code中关闭日志f-strings提示的问题

先明确为什么没装Pylint扩展仍有代码检查

VS Code官方的Python插件本身集成了Pylint支持,只要你的Python环境里安装了Pylint(可通过pip list命令确认),插件就会自动调用它做代码检查,不需要单独安装Pylint扩展。

针对性配置规则的两种方法

方法1:项目级配置(推荐,仅影响当前项目)

在项目根目录创建对应配置文件,精准调整这两个规则:

  • 若使用.pylintrc配置文件:
[MESSAGES CONTROL]
enable=logging-not-lazy
disable=logging-fstring-interpolation
  • 若使用现代Python项目常用的pyproject.toml:
[tool.pylint.messages_control]
enable = ["logging-not-lazy"]
disable = ["logging-fstring-interpolation"]

方法2:VS Code工作区设置(仅影响当前项目)

打开VS Code设置(快捷键Ctrl+,),切换到「工作区」标签(避免全局设置影响所有项目),搜索Python > Linting: Pylint Args,添加以下参数:

"python.linting.pylintArgs": [
    "--enable=logging-not-lazy",
    "--disable=logging-fstring-interpolation"
]

配置完成后,重启VS Code或重新加载当前窗口(快捷键Ctrl+Shift+P,选择「Reload Window」),对应的提示就会消失。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 13:10:36