Skip to content

PYI015 covers parts of PYI052 #4227

@twoertwein

Description

@twoertwein

flake8-pyi

Y015 Only simple default values are allowed for assignments. Similar to Y011, but for assignments rather than parameter annotations.
Y052 Y052 disallows assignments to constant values where the assignment does not have a type annotation. For example, x = 0 in the global namespace is ambiguous in a stub, as there are four different types that could be inferred for the variable x: int, Final[int], Literal[0], or Final[Literal[0]]. Enum members are excluded from this check, as are various special assignments such as all and match_args.

ruff seems to include Y52 in Y15 but does not exclude enums.

in pyi file:

from enum import Enum

class _NoDefault(Enum):
    no_default = ...

no_default: Final = _NoDefault.no_default  # noqa: PYI015
NoDefault = Literal[_NoDefault.no_default]

xref pandas-dev/pandas#53062 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions