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

[flake8-pyi] Skip Annotated and Literal for string-or-bytes-too-long (PYI053) #13020

Closed
wants to merge 7 commits into from

Conversation

dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Aug 21, 2024

PYI053 now skips strings which appear inside Literal[...] or Annotated[...].

This is a modification of #13002, which skipped any type annotation for this rule. So, on the one hand, this PR allows the check to proceed in some cases that the prior PR skipped (e.g. return type annotations wrapped - unnecessarily, for a stub file - in quotes), and, on the other hand, this PR skips certain strings that the prior PR did not (e.g. type alias assignments to a Literal or Annotated type.)

In order to implement this change, the PR adds a new semantic flag for PEP593 annotations (i.e. typing.Annotated[...])

Closes #12995 (hopefully!)

@dylwil3 dylwil3 requested a review from AlexWaygood as a code owner August 21, 2024 03:56
@dhruvmanila dhruvmanila added the bug Something isn't working label Aug 21, 2024
Copy link
Contributor

github-actions bot commented Aug 21, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood self-assigned this Aug 21, 2024
/// ```python
/// def f(x: Annotated[int, "A"]): ...
/// ```
const TYPING_ANNOTATED_PEP593 = 1<<27;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof... but I have been trying to think of a better name for 10 minutes and I've got nothing 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a reasonable name given other variants although I leave this up to you to decide, maybe you come up with a better name in the morning ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside, it would be useful to provide a link to PEP 593 in the documentation above @dylwil3

@AlexWaygood
Copy link
Member

I know this has been waiting on me for a little bit -- have to call it for the day now, but will try to land it tomorrow!

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Aug 27, 2024

I know this has been waiting on me for a little bit -- have to call it for the day now, but will try to land it tomorrow!

No worries at all!

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Sep 20, 2024

@AlexWaygood if it was possible to meekly whisper a nudge in the form of a notification, I would, but github allows for only one volume. Let me know if there's anything else you'd like me to do on this one 😄

@charliermarsh
Copy link
Member

@dylwil3 - Just a heads up (in case it wasn't mentioned elsewhere) that Alex is on vacation this week so may be a few more days before he gets to it. (It's totally fine that you nudged and in fact your nudge was very gracious!)

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Dec 5, 2024

Closing in favor of #14797

@dylwil3 dylwil3 closed this Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

string-or-bytes-too-long (PYI053) flags and removes long strings in Literal, producing invalid type
4 participants