Skip to content

UP013, UP014: Comments inside the definition are dropped #9715

@JelleZijlstra

Description

@JelleZijlstra

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions