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

如何通过pyproject.toml为指定文件禁用Pylint的too-many-instance-attributes消息

如何在pyproject.toml中仅为特定文件禁用Pylint的too-many-instance-attributes错误

完全可以通过Poetry的pyproject.toml文件实现仅对my_project/runner/runner.py禁用too-many-instance-attributes(错误码R0902)的需求,具体有两种配置方式:

方式一:通过模块名指定

利用Pylint检测输出里的模块名my_project.runner.runner来配置:

[tool.pylint."messages control"]
disable = []

[tool.pylint."my_project.runner.runner"]
disable = ["too-many-instance-attributes"]

方式二:通过文件路径匹配

直接用文件路径精准匹配目标文件:

[tool.pylint."path-matchers"]
"my_project/runner/runner.py" = { disable = ["too-many-instance-attributes"] }

配置完成后重新运行Pylint检测,只有my_project/runner/runner.py的too-many-instance-attributes错误会被忽略,其他文件的该错误仍会正常触发。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 06:25:58