Add built-in validation check for bullet lists missing a preceding blank line
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 63/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- python
- Área
- documentation
Línea de trabajo
Comienza con el detector referenciado scripts/validate_docstring_lists.py y sigue la canalización de validación existente de numpydoc para encontrar dónde se procesan los docstrings extraídos y los códigos de error. Añade la comprobación específica para introducciones que terminan en dos puntos y van seguidas de viñetas; después, cubre los casos positivos y los que no coinciden en las pruebas de validación y documenta el código asignado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 354
- Forks
- 185
- Merge medio
- 4 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de numpy/numpydoc
-
Don't require ``RT01`` for propertiesQuizá libre de nuevo @Nani-2007-code la tomó hace 30 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 57/100
-
DOC: Version link overflowing on navbarQuizá libre de nuevo @swoyer2 la tomó hace 52 días y no hay ningún pull request abierto. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
-
needs-decision
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Todos los issues de numpy/numpydoc
Issues similares
-
00 - Bug component: numpy.linalg
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
521xueweihan/HelloGitHub#4543 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
emeryberger/CSrankings#15700 ·
Los mantenedores suelen responder en 2 días
-
Bug | 工作不正常 Triage | 待检查
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
OneDragon-Anything/ZenlessZoneZero-OneDragon#3084 ·
Los mantenedores suelen responder en 1 día
-
Task select patterns with uppercase letters never matchPosiblemente ocupada @manobhisriram la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día