Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D417] Missing argument descriptions in the docstring for **kwargs and *args should be allowed #8605

Closed
mikeweltevrede opened this issue Nov 10, 2023 · 2 comments
Labels
docstring Related to docstring linting or formatting question Asking for support or clarification

Comments

@mikeweltevrede
Copy link

I would expect D417 to not require *args and **kwargs to be put in the descriptions. Maybe this is not good practice, in which case please let me know.

  • A minimal code snippet that reproduces the bug.
def f(*args, **kwargs):
    """Description"""
  • The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.
    pre-commit install with the following config:
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.1.4
    hooks:
      - id: ruff
      - id: ruff-format
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: check-ast
      - id: check-case-conflict
      - id: check-json
      - id: check-toml
      - id: check-yaml
      - id: end-of-file-fixer
      - id: name-tests-test
        exclude: ^tests/utils/
      - id: no-commit-to-branch
      - id: trailing-whitespace

  • The current Ruff settings (any relevant sections from your pyproject.toml).
[tool.poetry.group.dev.dependencies]
pre-commit = "3.5.0"
ruff = "0.1.4"
pre-commit-hooks = "4.5.0"

[tool.ruff.lint]
extend-select = [
    "D",  # pydocstyle
]
ignore = ["B026", "D100", "D415", "ANN101", "ANN102", "ANN002", "ANN003"]

[tool.ruff.lint.pydocstyle]
convention = "google"
  • The current Ruff version (ruff --version).
    • 0.1.4
@charliermarsh
Copy link
Member

Ah yeah, I think this is correct, though it should only be triggering if you include an Args: section in your docstring. If you do document the arguments, I believe it's intended that you also document the *args and **kwargs, and this matches pydocstyle behavior.

If your signature is just *args and **kwargs as above, then it probably makes sense to omit the Args: section altogether -- if I run ruff check --select D417 on the example you provided above, we don't raise an error, which makes sense to me, but are you seeing differently? Here's an example from the playground with that rule selected.

@charliermarsh charliermarsh added question Asking for support or clarification docstring Related to docstring linting or formatting labels Nov 10, 2023
@mikeweltevrede
Copy link
Author

That is a fair comment. I had something like the following:

def f(path, *args, **kwargs):
    """
    Description

    Args:
        path: xxx
    """

I guess then I would have to provide documentation for args and kwargs, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Related to docstring linting or formatting question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

2 participants