astral-sh/ruff

UP013, UP014: Comments inside the definition are dropped

Open

#9.715 aberto em 30 de jan. de 2024

Ver no GitHub
 (3 comments) (3 reactions) (1 assignee)Rust (2.088 forks)batch import
bugfixeshelp wanted

Métricas do repositório

Stars
 (47.527 stars)
Métricas de merge de PR
 (Mesclagem média 3d 8h) (573 fundiu PRs em 30d)

Description

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.

Guia do colaborador