Multiline summary is not split correctly
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia con la funzione split_summary e riproduci l’esempio multilinea dell’issue. Esamina come vengono consumate le righe restituite, quindi aggiungi una copertura di regressione per l’ordinamento mostrato e conferma che l’output corretto preservi le righe successive.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 598
- Fork
- 95
- Merge medio
- 2g 3h
- PR unite (30g)
- 11
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 PyCQA/docformatter
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesForse di nuovo libera @adityaanikam l’ha presa 68 giorni fa e non c’è nessuna pull request aperta. ApertaC: convention P: bug U: high
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
PyCQA/docformatter#367 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its valueApertaC: convention P: bug U: high
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
PyCQA/docformatter#366 ·
I maintainer di solito rispondono entro 1 giorno
-
C: stakeholder P: enhancement U: low
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
PyCQA/docformatter#346 ·
I maintainer di solito rispondono entro 1 giorno
-
C: convention P: bug U: high
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
PyCQA/docformatter#345 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
C: convention help wanted P: bug U: high
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
PyCQA/docformatter#285 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di PyCQA/docformatter
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
FavioVazquez/showtime#101 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rossant/awesome-math#199 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
nautechsystems/nautilus_trader#5365 ·
I maintainer di solito rispondono entro 1 giorno
-
Examples say cnxApertadocumentation embedded
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno