Docformatter inappropriately removes newline between classes
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
- 66/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- developer-experience, tooling
Direzione di ricerca
Start by reproducing the report with the minimal Annotated class examples and docformatter 1.7.8, then trace the formatter’s handling of attribute docstrings and blank lines between classes. Compare the examples with and without a following method to narrow down the case. Done when formatting preserves the blank line between classes consistently with Black and the reported pre-commit deadlock is resolved.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am currently experiencing a pre-commit deadlock between Black and Docformatter , but only in a very specific case.
Consider the following:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, dict(something=1)]
"""Value that makes the parameter visible."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
Docformatter is removing a newline from in between the docstring for the equals property and the TransformParameter class, causing a deadlock in pre-commit because black puts two blank lines between classes.
This appears to only affect classes that use Annotated, and only if one of the parameters to Annotated contains a callable at any point with a keyword argument. The property must also not be followed by any methods. For example, this has the same bug:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, {"something": dict(something=1)}]
"""Value that makes the parameter visible."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
But this does not:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, {"something": dict(something=1)}]
"""Value that makes the parameter visible."""
def function(self):
"""Does a thing."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
I also found that in this scenario, it removes the newline between the classes:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, {"something": dict(something=1)}]
"""Value that makes the parameter visible."""
prop: Any
"""A description of the property."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
Versions and Config
I am using docformatter version 1.7.8. Below are my settings for both Black and Docformatter:
[tool.docformatter]
recursive = true
blank = true
black = true
in-place = true
[tool.black]
unstable = true
enable-unstable-feature = ["string_processing"]
- Lingua principale
- Python
- Stelle
- 600
- Fork
- 107
- Merge medio
- 22h 15m
- PR unite (30g)
- 12
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
-
`--docstring-length` removes blank line after docstrings it doesn't format (ping-pong with ruff format / Black)Forse già presa @RClaudiuM l’ha presa 1 giorno fa. Apertafresh
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
PyCQA/docformatter#420 ·
I maintainer di solito rispondono entro 1 giorno
-
docformatter fix does not consider parameters for added newlinesForse di nuovo libera @AtharvRG l’ha presa 25 giorni fa e non c’è nessuna pull request aperta. Apertafresh
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
PyCQA/docformatter#408 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
BUG: Inconsistent behavior between `docformatter` and `black`Forse di nuovo libera @AtharvRG l’ha presa 25 giorni fa e non c’è nessuna pull request aperta. Apertafresh
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
PyCQA/docformatter#399 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesForse di nuovo libera @adityaanikam l’ha presa 106 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 · 1 reazione ·
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 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di PyCQA/docformatter
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
NatLabRockies/openstudio-mcp#286 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
intersystems/ipm#1338 ·
I maintainer di solito rispondono entro 1 giorno
-
separate_packages splits imports from the same explicitly configured packageForse già presa @rahul05ranjan l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionApertav1
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno