Search code examples
pythondocstringruff

How do I disable D100 and or C0111 with ruff?


I use sphinx and at the top of my py files I have this:

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

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

These warning are incorrect in the this context:

  • 1 blank line required between summary line and descriptionFlake8(D205)
  • First line should end with a periodFlake8(D400)

I can't put a blank line above ======= because that breaks the headings and I also don't want to put a period after my heading. How can I ignore in just these cases?

This two posts seem relevant:

In my project.toml this did nothing:

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

I can't even find out how to disable

I also opened a GitHub issue: https://github.com/astral-sh/ruff/issues/9583

Edit

Maybe I'm not understanding how D100 works? It looks like it's been officially implemented as I see a check next to it: https://github.com/astral-sh/ruff/issues/970

Shouldn't ignoring D100 prevent docstring linting at the top of the files?


Solution

  • I should have paid more attention to my tooltips, the ruff extension gave me a solution. It's a pain to do it in all files, but it's good enough, I guess a multiline string is considered one line because this works:

    """
    my_module
    =========
    This is a heading I want sphinx to process
    """  # noqa: D205, D400