Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its value

Abierto
#366 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
tooling

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

C: convention P: bug U: high

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PyCQA/docformatter

Todos los issues de PyCQA/docformatter

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.