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

Fix blank-line docstring rules for module-level docstrings #9878

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Feb 7, 2024

Summary

Given:

"""Make a summary line.

Note:
----
  Per the code comment the next two lines are blank. "// The first blank line is the line containing the closing
      triple quotes, so we need at least two."

"""

It turns out we excluded the line ending in """, because it's empty (unlike for functions, where it consists of the indent). This PR changes the following_lines iterator to always include the trailing newline, which gives us correct and consistent handling between function and module-level docstrings.

Closes #9877.

@charliermarsh charliermarsh added bug Something isn't working docstring Related to docstring linting or formatting labels Feb 7, 2024
@charliermarsh charliermarsh force-pushed the charlie/doc branch 2 times, most recently from 6493eb8 to 140ba33 Compare February 7, 2024 21:06
Copy link
Contributor

github-actions bot commented Feb 7, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -63 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

bokeh/bokeh (+0 -63 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- src/bokeh/driving.py:7:1: D413 [*] Missing blank line after last section ("Example")
- src/bokeh/plotting/glyph_api.py:1004:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:110:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:130:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:146:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:163:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:180:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:197:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:214:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:231:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:248:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:265:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:282:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:299:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:315:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:332:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:349:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:365:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:381:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:397:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:414:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:430:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:447:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:490:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:506:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:522:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:543:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:564:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:580:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:601:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:617:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:638:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:655:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:677:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:693:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:69:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:711:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:727:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:744:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:761:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:778:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:795:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:812:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:838:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:855:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:872:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:889:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:906:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:90:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:923:9: D413 [*] Missing blank line after last section ("Examples")
... 13 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
D413 63 0 63 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -63 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

bokeh/bokeh (+0 -63 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- src/bokeh/driving.py:7:1: D413 [*] Missing blank line after last section ("Example")
- src/bokeh/plotting/glyph_api.py:1004:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:110:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:130:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:146:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:163:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:180:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:197:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:214:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:231:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:248:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:265:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:282:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:299:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:315:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:332:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:349:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:365:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:381:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:397:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:414:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:430:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:447:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:490:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:506:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:522:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:543:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:564:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:580:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:601:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:617:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:638:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:655:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:677:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:693:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:69:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:711:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:727:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:744:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:761:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:778:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:795:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:812:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:838:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:855:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:872:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:889:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:906:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:90:9: D413 [*] Missing blank line after last section ("Examples")
- src/bokeh/plotting/glyph_api.py:923:9: D413 [*] Missing blank line after last section ("Examples")
... 13 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
D413 63 0 63 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@charliermarsh charliermarsh merged commit 4593742 into main Feb 7, 2024
17 checks passed
@charliermarsh charliermarsh deleted the charlie/doc branch February 7, 2024 21:48
@charliermarsh
Copy link
Member Author

Ecosystem changes are 👍

@BrentWilkins
Copy link

Thanks!

nkxxll pushed a commit to nkxxll/ruff that referenced this pull request Mar 10, 2024
…#9878)

## Summary

Given:

```python
"""Make a summary line.

Note:
----
  Per the code comment the next two lines are blank. "// The first blank line is the line containing the closing
      triple quotes, so we need at least two."

"""
```

It turns out we excluded the line ending in `"""`, because it's empty
(unlike for functions, where it consists of the indent). This PR changes
the `following_lines` iterator to always include the trailing newline,
which gives us correct and consistent handling between function and
module-level docstrings.

Closes astral-sh#9877.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docstring Related to docstring linting or formatting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

D413 is enforcing excessive whitespace
2 participants