Skip to content

D417 Argument descriptions only required if there is an "Args" section #2310

@jackdesert

Description

@jackdesert

Expected the code snippet below to show D417. That is, expected it to tell me that the "name" argument does not have a description in the docstring. If I change the word "Parameters" to "Args", then it will raise D417 as desired. Not sure if this is expected behavior, but it has been challenging to figure out.

Version: ruff 0.0.237

Code:


def hello(name):
    """
    Do something.

    Parameters:
        other (str): what to call it

    Returns:
        bool: True if len(name) > 0
    """
    return len(name) > 0

Command:

ruff *.py

Output:

run.py:1:1: D100 Missing docstring in public module
Found 1 error.

pyproject.toml:

[tool.black]
skip-string-normalization = 1

[tool.ruff]
# Enable Pyflakes `E` and `F` codes by default.
select = ["ALL"]

# It appears that a single "Q" ignores all codes that start with Q
# but you could also disable single errors instead of classes of errors
ignore = ["INP001", # implicit-namespace-package
          "ANN",    # type annotations
          "T20",    # flake8-print (warns when there are print statements)

          # One of these is to be disabled..
          # (I prefer disabling D212 (Multi-line docstring summary should start at the first line)
          #  because I like text inside a docstring
          #  to start the line below the three """)
          #"D213", # See https://github.com/charliermarsh/ruff/issues/2281
          "D212", # See https://github.com/charliermarsh/ruff/issues/2281

          # One of these is to be disabled.
          # No strong preference here.
          # One expects a blank line before a class docstring
          #"D203", # See https://github.com/charliermarsh/ruff/issues/2281
          "D211", # See https://github.com/charliermarsh/ruff/issues/2281

]


# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
]
per-file-ignores = {}

# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

# This is how you tell Q000 errors to prefer single quotes
[tool.ruff.flake8-quotes]
inline-quotes = "single"

# I like the google docstyle
# See https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
# and http://google.github.io/styleguide/pyguide.html
# https://gist.github.com/redlotus/3bc387c2591e3e908c9b63b97b11d24e
# If it complains that you do not have an argument description,
# make sure you have a section called "Args:", not "Arguments" or "Parameters"
[tool.ruff.pydocstyle]
convention = "google"  # Or "numpy", or "pep257"
#convention = "pep257"  # Or "numpy", or "pep257"

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstringRelated to docstring linting or formatting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions