ruff/crates/ruff_linter/src/docstrings
Charlie Marsh 04afdf177b
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.
2024-01-07 22:41:00 -05:00
..
extraction.rs Split Constant to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
google.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
mod.rs Split Constant to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
numpy.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
sections.rs Disambiguate argument descriptors from section headers (#9427) 2024-01-07 22:41:00 -05:00
styles.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00