astral-sh/ruff

UP013, UP014: Comments inside the definition are dropped

Open

#9715 aperta il 30 gen 2024

Vedi su GitHub
 (3 commenti) (3 reazioni) (1 assegnatario)Rust (2088 fork)batch import
bugfixeshelp wanted

Metriche repository

Star
 (47.527 star)
Metriche merge PR
 (Merge medio 3g 8h) (573 PR mergiate in 30 g)

Descrizione

Starting with this code:

from typing import NamedTuple, TypedDict

X = TypedDict("X", {
    "some_config": int,  # important
})

Y = NamedTuple("Y", [
    ("some_config", int),  # important
])

Ruff (via rules UP013 and UP014) turns it into:

from typing import NamedTuple, TypedDict

class X(TypedDict):
    some_config: int

class Y(NamedTuple):
    some_config: int

Ideally it should retain the end-of-line comments.

Guida contributor