-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 type annotations in string-or-bytes-too-long
(PYI053
)
#13002
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PYI062 | 14 | 0 | 14 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+0 -14 violations, +0 -0 fixes in 1 projects; 53 projects unchanged)
python/typeshed (+0 -14 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select E,F,FA,I,PYI,RUF,UP,W
- stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:11052: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:11057: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:11062: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:11067: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:3422: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:5868: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:5873: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:8355: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:8360: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:8689: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi:1188:8694: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi:496:918: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi:496:923: PYI062 Duplicate literal member `...` - stubs/tensorflow/tensorflow/core/protobuf/rewriter_config_pb2.pyi:496:928: PYI062 Duplicate literal member `...`
Changes by rule (1 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PYI062 | 14 | 0 | 14 | 0 | 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -59,6 +59,10 @@ pub(crate) fn string_or_bytes_too_long(checker: &mut Checker, string: StringLike | |||
return; | |||
} | |||
|
|||
if semantic.in_annotation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered if it might be better to be more targeted in our exclusions here, since there are relatively few valid annotations in stub files that would involve long string literals -- basically just Literal
and Annotated
, I think? We can detect if we're in a typing.Literal
slice like this:
if semantic.in_annotation() { | |
if semantic.in_typing_literal() { |
But we don't currently track in the semantic model whether we're in an Annotated
slice in the same way, and I'm not sure if it's worth it to add that tracking just for this, as I'm not sure it would practically get us much.
TL;DR -- this seems good; thanks!
string-or-bytes-too-long (PYI053)
flake8-pyi
] Skip type annotations in string-or-bytes-too-long
(PYI053
)
PYI053 is meant to protect against default arguments being too lengthy, not, e.g., type annotations with long literal strings.
Closes #12995