1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its value
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
Línea de trabajo
Comienza revisando el commit 926d9f0 y el tratamiento de las cadenas entre comillas triples en concatenaciones entre paréntesis. Usa el reproductor t.py proporcionado con docformatter --in-place y, después, ejecútalo bajo Python para comparar el valor resultante de X. Se considera terminado cuando este literal que no es un docstring permanece sin cambios y el comportamiento de formato existente sigue funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
docformatter 1.7.8 treats a triple-quoted string that opens a parenthesized concatenation as a docstring and reformats its contents: it splits the first sentence off, indents the remainder by four spaces, and moves the closing quotes onto their own line. The file still compiles, so the only effect is that the string the program builds is wrong.
Reproducer
X = (
"""#!/bin/bash
# Ends here.
# A second line.
_real="""
+ "y"
)
$ docformatter --in-place t.py
$ python3 -c "ns={}; exec(open('t.py').read(), ns); print(repr(ns['X']))"
| version | value of X |
|---|---|
| 1.7.7 | '#!/bin/bash\n# Ends here.\n# A second line.\n_real=y' |
| 1.7.8 | '#!/bin/bash\n# Ends here.\n\n # A second line.\n _real=\n y' |
No config file and no flags are needed. The trigger is the string's position: the same literal assigned directly to a name is left alone.
# Ends here. matters because the trailing period is what makes docformatter treat the first line as a summary and split a description off after it.
Scale
Running 1.7.7 and 1.7.8 over the same 1,257-file tree, one file at a time, on CPython 3.11: of the 1,250 files both versions processed without error, 475 come out different. Most are docstring-formatting changes that look intentional, but this class is in there and is invisible: the output parses, so nothing downstream complains.
Root cause
git bisect between v1.7.7 and 1b3f03d names 926d9f0 ("refactor: split long functions into smaller functions", #318) as the first bad commit. Its parent fe1a85f is clean. Being a refactor, the behavior change looks unintended.
This is the same family as #344 (non-docstring literals in call arguments), but a different position: a parenthesized concatenation rather than a call argument, so #364 does not cover it. The reproducer above works as a test case.
Environment
CPython 3.11.15, Linux x86-64, docformatter==1.7.8 from PyPI. Still present on master.
- Lenguaje dominante
- Python
- Estrellas
- 598
- Forks
- 97
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 11
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 PyCQA/docformatter
-
fresh
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
PyCQA/docformatter#399 ·
Los mantenedores suelen responder en 1 día
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesQuizá libre de nuevo @adityaanikam la tomó hace 76 días y no hay ningún pull request abierto. AbiertoC: convention P: bug U: high
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
PyCQA/docformatter#367 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
C: stakeholder P: enhancement U: low
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
PyCQA/docformatter#346 ·
Los mantenedores suelen responder en 1 día
-
C: convention P: bug U: high
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
PyCQA/docformatter#345 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Multiline summary is not split correctlyQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoC: convention P: bug U: high
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
PyCQA/docformatter#315 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de PyCQA/docformatter
Issues similares
-
[Resource] agent-claimcheckAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
yzhao062/awesome-auditable-ai#45 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NVIDIA/flare-local-inference#90 ·
Los mantenedores suelen responder en 1 día
-
area/streaming comp/gateway P2 platform/telegram type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#144897 ·
Los mantenedores suelen responder en 1 día
-
request-theme
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
LizardByte/ThemerrDB#9575 ·
Los mantenedores suelen responder en 1 día