如何通过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
相关产品推荐
相关产品推荐

