Add built-in validation check for bullet lists missing a preceding blank line
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 63/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Inizia dal detector scripts/validate_docstring_lists.py indicato come riferimento e segui la pipeline di validazione esistente di numpydoc per trovare dove vengono gestiti i docstring estratti e i codici di errore. Aggiungi il controllo mirato per le introduzioni che terminano con i due punti e sono seguite da elenchi puntati, quindi copri i casi positivi e quelli senza corrispondenza nei test di validazione e documenta il codice assegnato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Issue
Sphinx with the Napoleon extension (which numpydoc-validation users almost universally pair with) silently mis-renders bullet lists inside docstring section bodies when the list is not separated from its introductory line by a blank line. The bullet markers get inlined into the introductory paragraph as literal characters rather than being parsed as a list.
Concrete example, taken from a real public-API method:
def analyze_persistence(self, ...) -> dict[str, Any]:
"""...
Returns
-------
dict[str, Any]
Dictionary containing:
- "mean_effect_during": Mean effect during intervention period
- "mean_effect_post": Mean effect during post-intervention period
- "persistence_ratio": ...
"""
Napoleon collapses the four lines after Dictionary containing: into a single paragraph, so the rendered HTML reads as a wall of prose with literal hyphens rather than as four <li> elements. The fix is mechanically simple — insert a blank line between the introductory line and the first bullet — but the defect is invisible at edit time because the source is also valid (if uninspiring) RST.
This bit a downstream library recently (pymc-labs/CausalPy#892, where ~30 sites were affected across the public API).
Why existing tooling does not catch this
numpydoc-validationchecks (GL01–GL10,SS01–SS06,PR01–PR10,RT01–RT05,SA01–SA04,EX01,YD01,ES01) all validate section structure — section names, ordering, parameter sync, summary capitalisation, etc. None inspect the body content of a section.- Ruff's pydocstyle (
D) rules cover docstring presence, surrounding whitespace, and blank lines around section headers (D406–D416), but not within section bodies. - Sphinx itself does not warn — Napoleon happily produces the broken paragraph.
- Markdown linters (
pymarkdown,markdownlint) only operate on.mdfiles, so they never see these docstrings.
Feature request
Add a new validation check, e.g.:
GL11(or whatever code is free):"Bullet list inside docstring is not preceded by a blank line and will be rendered as inline prose by Sphinx Napoleon."
The detection rule that worked cleanly in practice (zero false positives across a 13k-line scientific Python codebase) is:
Flag a line that starts (after whitespace) with a bullet marker (
-,*, or+followed by whitespace) when the immediately preceding non-blank line ends in:and is not itself a bullet line.
This is intentionally narrower than "all bullet lists must be surrounded by blank lines" — it only targets the unambiguous Napoleon-collapse pattern (intro: followed directly by bullets), which is the form that produces the silent rendering bug. Stricter forms can be added later as separate codes if there is appetite.
Precedent
Issue #507 (Add built-in validation checks for directive syntax) makes a structurally identical case: Sphinx silently fails or mis-renders, and numpydoc-validation is the natural place to lint for it before the docs build. This proposal is a sibling in the same spirit but for bullet-list shape rather than directive shape.
Reference implementation
A working AST-based detector (~30 lines) that we are using locally as a stop-gap:
https://github.com/pymc-labs/CausalPy/blob/main/scripts/validate_docstring_lists.py
It walks ast.walk over each module, calls ast.get_docstring(..., clean=False), and applies the rule above. Plumbing it into numpydoc's existing validation pipeline should be straightforward since the docstring is already extracted there.
Offer
Happy to send a PR if the maintainers think this is in scope — would prefer to confirm appetite before investing in the full submission (tests, docs, error-code allocation).
Thank you for your time.
- Lingua principale
- Python
- Stelle
- 354
- Fork
- 185
- Merge medio
- 4m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di numpy/numpydoc
-
Don't require ``RT01`` for propertiesForse di nuovo libera @Nani-2007-code l’ha presa 30 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
-
DOC: Version link overflowing on navbarForse di nuovo libera @swoyer2 l’ha presa 52 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
needs-decision
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Tutte le issue di numpy/numpydoc
Issue simili
-
00 - Bug component: numpy.linalg
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
521xueweihan/HelloGitHub#4543 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
emeryberger/CSrankings#15700 ·
I maintainer di solito rispondono entro 2 giorni
-
Bug | 工作不正常 Triage | 待检查
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
OneDragon-Anything/ZenlessZoneZero-OneDragon#3084 ·
I maintainer di solito rispondono entro 1 giorno
-
Task select patterns with uppercase letters never matchForse già presa @manobhisriram l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno