如何禁用带有 ruff 的 D100 和/或 C0111?

问题描述 投票:0回答:1

我使用 sphinx,在我的 py 文件顶部有这个:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
my-module
=========
Some notes about my module
"""

这些警告在此上下文中是不正确的:

  • 摘要行和描述之间需要 1 个空行Flake8(D205)
  • 第一行应以句点Flake8(D400)结束

我不能在 ======= 上面放一个空行,因为这会破坏标题,而且我也不想在标题后面放一个句点。我怎么能忽视这些情况呢?

这两篇文章似乎相关:

在我的project.toml中这什么也没做:

[tool.ruff.lint]
ignore = ["D100"]

我什至不知道如何禁用

我还开了一个github问题:https://github.com/astral-sh/ruff/issues/9583

编辑

也许我不明白D100的工作原理?看起来它已经正式实施了,因为我看到旁边有一个检查:https://github.com/astral-sh/ruff/issues/970

不应该忽略 D100 来防止文件顶部的文档字符串 linting 吗?

python docstring ruff
1个回答
0
投票

我应该更加注意我的工具提示,ruff 扩展给了我一个解决方案,在所有文件中执行此操作很痛苦,但它已经足够好了,我想多行字符串被视为一行,因为这有效:

"""
my_module
=========
This is a heading I want sphinx to process
"""  # noqa: D205, D400
© www.soinside.com 2019 - 2024. All rights reserved.