一个示例: 我们的存储库中有许多 SQL Alchemy
models.py
文件。从我们的目录结构中可以明显看出每个 models.py
的用途是什么。我真的很想禁用任何模块 missing-module-docstring
x.y.z.models
。文档字符串将是多余的噪音。每个文件禁用注释大致相同。
在完美的世界中,我可以编写以下配置行:
missing-module-doctring = { action="disable", glob="**/*/models.py" }
或者也许:
disable = [{ name="missing-module-docstring", glob="**/*/models.py" }, ...]
对于其他检查和其他模块/Python 文件命名约定,我还有一些类似的场景。
我查看了配置文档,但没有找到任何东西。有没有插件可以支持这个?
如果我必须采用“两遍解决方案”,我想我可以运行 pylint 一次,排除
models.py
文件。然后再次运行它,过滤掉所有内容 but models.py
?
对于上下文:我在命令行、CI 和 VS Code 中运行 pylint。我在
project.toml
中配置它,但我愿意更改它。
https://pylint.readthedocs.io/en/latest/user_guide/configuration/all-options.html#ignore
您可以通过使用 pylint 的
ignore-patterns
选项以正则表达式格式指定基本名称来忽略目录和文件(另请参阅 ignore
、ignore-paths
或 ignored-modules
)。
您还可以使用https://pylint.readthedocs.io/en/latest/user_guide/messages/message_control.html#message-control
指定的控制消息禁用特定行、函数或模块的 pylint