Silently mangled docstrings: lone backslash line-continuations in non-raw docstrings collapse command examples
I maintainer di solito rispondono entro 3 giorni
@madhusudhan1260 ci sta già lavorando.
Dal 5/11/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Inizia con docs/examples/requirements/code_generation_and_execution_bash.py righe 37 e 41, dove il blocco di utilizzo collassa; lo stesso pattern \-nuova riga isolato si trova in docs/examples/granite-switch/answerability_openai.py (8-9), hallucination_detection_openai.py (8-9), manual_adapter_loading.py (20-21) e test/backends/test_audio_openai.py (11-21). Anteponi r a ogni docstring di modulo (come in docs/examples/requirements/code_generation_and_execution.py) o raddoppia i backslash, seguendo la convenzione già usata in docs/examples/m_serve/multimodal-audio/m_serve_example_multimodal_audio_llama_server.py. Fatto appare come ogni docstring reso con le continuazioni intatte tramite inspect.getdoc, come mostra lo snippet di verifica.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
User impact
Reading an example's docstring through help(), pydoc, or an IDE hover shows garbled command examples: multi-line shell commands collapse onto one line with the \ continuations silently removed. For example, the Usage block of code_generation_and_execution_bash.py renders as:
uv run python docs/examples/requirements/code_generation_and_execution_bash.py --workspace /path/to/workspace
instead of the intended two-line command. The files compile and run normally — this is a documentation rendering defect only. GitHub source view shows the raw text correctly, and the docs site is unaffected (example docstrings are not rendered by the docs pipeline).
Mechanism
\<newline> inside a non-raw string literal is a line-continuation escape: Python consumes both characters at compile time, so the docstring text stored in __doc__ never contains them. A docstring that documents a shell continuation must either:
- be a raw string (
r"""— used bydocs/examples/requirements/code_generation_and_execution.py), or - double the backslashes (
\\— used bydocs/examples/m_serve/multimodal-audio/m_serve_example_multimodal_audio_llama_server.py).
Neither ruff check (default rule selection) nor ruff check --select W605 flags this, because \<newline> is a valid escape sequence — W605 only fires on invalid ones. The failure is completely silent.
Occurrences
Non-raw module docstrings containing lone \-newline sequences (verified by AST analysis and rendered output):
| File | Lines | Escapes |
|---|---|---|
docs/examples/requirements/code_generation_and_execution_bash.py |
37, 41 | 2 |
docs/examples/granite-switch/answerability_openai.py |
8–9 | 2 |
docs/examples/granite-switch/hallucination_detection_openai.py |
8–9 | 2 |
docs/examples/granite-switch/manual_adapter_loading.py |
20–21 | 2 |
test/backends/test_audio_openai.py |
11–21 | 11 |
The first row is introduced by #1766 (fixing it there is optional — this issue tracks all occurrences). The rest pre-date that PR.
Suggested fix
Per file: prefix the module docstring with r, or double the backslashes. Both conventions already exist in the repo (links above).
To prevent recurrence, a small pre-commit hook could parse each .py file with ast and flag module docstrings that are non-raw and contain a lone \ immediately before a newline.
Verifying the fix
Render the docstring through the consumer path and check the continuation survives, e.g.:
import inspect
assert "--workspace" in inspect.getdoc(module).splitlines()[-1] # line ends with \
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 161
- Merge medio
- 4g 3h
- PR unite (30g)
- 45
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 generative-computing/mellea
-
bug: `mellea.plugins.builtin_debug.generation.log_generation_post_call` shows model as unknownApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
generative-computing/mellea#1864 ·
I maintainer di solito rispondono entro 3 giorni
-
bug: instruct() and react() replay tool-call turns without tool_callsForse già presa @simonyang08 l’ha presa 21 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
generative-computing/mellea#1784 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
area/telemetry enhancement p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
generative-computing/mellea#1210 ·
I maintainer di solito rispondono entro 3 giorni
-
Add requirement priorityApertaarea/requirement area/stdlib enhancement p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
generative-computing/mellea#31 · 2 commenti ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
generative-computing/mellea#1863 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di generative-computing/mellea
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
OpenFreeEnergy/openfe#2371 ·
I maintainer di solito rispondono entro 2 giorni
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
NCATSTranslator/Babel#1269 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
404 on sample dataApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
bcgov/nr-hydrometric-rating-curve#443 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100