Multiline summary is not split correctly
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Empieza con la función split_summary y reproduce el ejemplo multilínea del issue. Inspecciona cómo se consumen las líneas que devuelve y, después, añade cobertura de regresión para el orden mostrado y confirma que la salida corregida conserva las líneas posteriores.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I saw the error in CI because I used master (that was needed for a while to use with pre-commit version 4 and above).
Some multi lines sentences are split incorrectly. This is the behavior of the function split_summary
>>> split_summary(["First sentence is here. Second sentence is long", "and split in two. I even have a third sentence here.", "", "And other text here."])
['First sentence is here.',
'and split in two. I even have a third sentence here.',
'Second sentence is long',
'',
'And other text here.']
I think this comes from the split_summary function that does this:
lines[0] = first_sentence
if rest_text:
lines.insert(2, rest_text)
and inserts at the wrong place if we have sentences that are too long.
I am not familiar with the code base, but maybe something along those lines could work?
def split_summary(lines) -> List[str]:
"""Split multi-sentence summary into the first sentence and the rest."""
if not lines or not lines[0].strip():
return lines
text = lines[0].strip()
tokens = re.split(r"(\s+)", text) # Keep whitespace for accurate rejoining
sentence = []
rest = []
i = 0
while i < len(tokens):
token = tokens[i]
sentence.append(token)
if token.endswith(".") and not any(
"".join(sentence).strip().endswith(abbr) for abbr in ABBREVIATIONS
):
i += 1
break
i += 1
rest = tokens[i:]
first_sentence = "".join(sentence).strip()
rest_text = "".join(rest).strip()
new_lines = [first_sentence, ""]
if rest_text:
new_lines.append(rest_text)
new_lines.extend(line for line in lines[1:] if line)
return new_lines
This gives:
>>> split_summary(["First sentence is here. Second sentence is long", "and split in two. I even have a third sentence here.", "", "And other text here."])
['First sentence is here.',
'',
'Second sentence is long',
'and split in two. I even have a third sentence here.',
'And other text here.']
I do not know if the result should be processed more before returning or if it is something that is taken into account elsewhere in the codebase.
- Lenguaje dominante
- Python
- Estrellas
- 599
- Forks
- 95
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 7
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
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesQuizá libre de nuevo @adityaanikam la tomó hace 60 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 ·
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its valueAbiertoC: convention P: bug U: high
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
PyCQA/docformatter#366 ·
-
docformatter deadlock with ruff-format: blank lines around nested definitionsPosiblemente ocupada @wolfgang-aura la tomó hace 2 días. AbiertoC: convention P: bug U: high
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
PyCQA/docformatter#354 · 3 reacciones ·
-
C: stakeholder P: enhancement U: low
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
PyCQA/docformatter#346 ·
-
C: convention P: bug U: high
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
PyCQA/docformatter#345 · 1 reacción ·
Todos los issues de PyCQA/docformatter
Issues similares
-
Performance: deprecated DeviceEntry.config_entries access blocks the event loop for tens of secondsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
tuya/tuya_cloud_ha_bridge#14 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
semantica-agi/semantica#1968 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
agent: ready area: submission priority: high type: docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dkritarth/scopewatch#213 ·
Los mantenedores suelen responder en 1 día
-
Broken link in RELEASE.mdPosiblemente ocupada @Jah-yee la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
sphinx-contrib/httpdomain#143 ·
Los mantenedores suelen responder en 1 día