Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYI015 covers parts of PYI052 #4227

Closed
twoertwein opened this issue May 4, 2023 · 4 comments
Closed

PYI015 covers parts of PYI052 #4227

twoertwein opened this issue May 4, 2023 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@twoertwein
Copy link

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)

@charliermarsh charliermarsh added the bug Something isn't working label May 4, 2023
@charliermarsh
Copy link
Member

👍 I think the best solution here is to implement Y052, and fix Y015 such that they're non-overlapping (as in flake8-pyi).

@charliermarsh charliermarsh added the good first issue Good for newcomers label May 6, 2023
@sladyn98
Copy link
Contributor

sladyn98 commented May 6, 2023

@charliermarsh I would like to work on this issue, can you point me to some code pointers and I can work on it.

@mccullocht
Copy link
Contributor

@sladyn98 I briefly looked into this. The pylint implementation of Y052 and Y015 appear together, it probably makes sense structure things similarly and place it near the ruff implementation of Y015.

@charliermarsh
Copy link
Member

Closed by #4293.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants