ruff
04afdf17 - Disambiguate argument descriptors from section headers (#9427)

Comment changes are shownComment changes are hidden
Commit
1 year ago
Disambiguate argument descriptors from section headers (#9427) ## Summary Given a docstring like: ```python def func(x: int, args: tuple[int]): """Toggle the gizmo. Args: x: Some argument. args: Some other arguments. """ ``` We were considering the `args:` descriptor to be an indented docstring section header (since `Args:`) is a valid header name. This led to very confusing diagnostics. This PR makes the parsing a bit more lax in this case, such that if we see a nested header that's more deeply indented than the preceding header, and the preceding section allows sub-items (like `Args:`), we avoid treating the nested item as a section header. Closes https://github.com/astral-sh/ruff/issues/9426.
Author
Parents
  • crates/ruff_linter
    • resources/test/fixtures/pydocstyle
      • File
        D417.py
      • File
        sections.py
    • src
      • docstrings
        • File
          sections.rs
      • rules/pydocstyle/snapshots
        • ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap
        • ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap
        • ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap
        • ruff_linter__rules__pydocstyle__tests__d417_google.snap
        • ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap