[flake8-pyi] Skip type annotations in string-or-bytes-too-long (PYI053)#13002
[flake8-pyi] Skip type annotations in string-or-bytes-too-long (PYI053)#13002AlexWaygood merged 3 commits intoastral-sh:mainfrom
flake8-pyi] Skip type annotations in string-or-bytes-too-long (PYI053)#13002Conversation
|
| 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 |
| return; | ||
| } | ||
|
|
||
| if semantic.in_annotation() { |
There was a problem hiding this comment.
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