-
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
Move Q001-3
to AST based checker
#10312
Move Q001-3
to AST based checker
#10312
Conversation
dad0e35
to
ab4b600
Compare
7b77530
to
1e24c01
Compare
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
INP001 | 224 | 112 | 112 | 0 | 0 |
S104 | 6 | 3 | 3 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+115 -115 violations, +0 -0 fixes in 1 projects; 43 projects unchanged)
bokeh/bokeh (+115 -115 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ examples/basic/annotations/arrow.py:1:1: INP001 File `examples/basic/annotations/arrow.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/arrow.py:1:1: INP001 File `examples/basic/annotations/arrow.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/arrowheads.py:1:1: INP001 File `examples/basic/annotations/arrowheads.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/arrowheads.py:1:1: INP001 File `examples/basic/annotations/arrowheads.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/band.py:1:1: INP001 File `examples/basic/annotations/band.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/band.py:1:1: INP001 File `examples/basic/annotations/band.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/box_annotation.py:1:1: INP001 File `examples/basic/annotations/box_annotation.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/box_annotation.py:1:1: INP001 File `examples/basic/annotations/box_annotation.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/colorbar_log.py:1:1: INP001 File `examples/basic/annotations/colorbar_log.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/colorbar_log.py:1:1: INP001 File `examples/basic/annotations/colorbar_log.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/label.py:1:1: INP001 File `examples/basic/annotations/label.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/label.py:1:1: INP001 File `examples/basic/annotations/label.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/legend.py:1:1: INP001 File `examples/basic/annotations/legend.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/legend.py:1:1: INP001 File `examples/basic/annotations/legend.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/legend_two_dimensions.py:1:1: INP001 File `examples/basic/annotations/legend_two_dimensions.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/legend_two_dimensions.py:1:1: INP001 File `examples/basic/annotations/legend_two_dimensions.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/legends_item_visibility.py:1:1: INP001 File `examples/basic/annotations/legends_item_visibility.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/legends_item_visibility.py:1:1: INP001 File `examples/basic/annotations/legends_item_visibility.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/slope.py:1:1: INP001 File `examples/basic/annotations/slope.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/slope.py:1:1: INP001 File `examples/basic/annotations/slope.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/annotations/whisker.py:1:1: INP001 File `examples/basic/annotations/whisker.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/annotations/whisker.py:1:1: INP001 File `examples/basic/annotations/whisker.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/areas/stacked_area.py:1:1: INP001 File `examples/basic/areas/stacked_area.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/areas/stacked_area.py:1:1: INP001 File `examples/basic/areas/stacked_area.py` is part of an implicit namespace package. Add an `__init__.py`. + examples/basic/axes/logplot.py:1:1: INP001 File `examples/basic/axes/logplot.py` is part of an implicit namespace package. Add an `__init__.py`. - examples/basic/axes/logplot.py:1:1: INP001 File `examples/basic/axes/logplot.py` is part of an implicit namespace package. Add an `__init__.py`. ... 199 additional changes omitted for rule INP001 + tests/unit/bokeh/command/subcommands/test_serve.py:540:20: S104 Possible binding to all interfaces - tests/unit/bokeh/command/subcommands/test_serve.py:540:20: S104 Possible binding to all interfaces + tests/unit/bokeh/test_server.py:51:48: S104 Possible binding to all interfaces - tests/unit/bokeh/test_server.py:51:48: S104 Possible binding to all interfaces + tests/unit/bokeh/test_server.py:52:34: S104 Possible binding to all interfaces - tests/unit/bokeh/test_server.py:52:34: S104 Possible binding to all interfaces ... 198 additional changes omitted for project
Changes by rule (2 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
INP001 | 224 | 112 | 112 | 0 | 0 |
S104 | 6 | 3 | 3 | 0 | 0 |
Oh right. We will visit the strings inside a f-string and try to change that. I'll fix this later. |
Oops, approved before I saw the ecosystem changes. |
42bf089
to
d30dc29
Compare
CodSpeed Performance ReportMerging #10312 will not alter performanceComparing Summary
|
crates/ruff_linter/src/rules/flake8_quotes/rules/check_string_quotes.rs
Outdated
Show resolved
Hide resolved
ab4b600
to
67810b6
Compare
d30dc29
to
b096569
Compare
67810b6
to
1ef5e95
Compare
b096569
to
e2ae5a0
Compare
e2ae5a0
to
677178a
Compare
.indexer() | ||
.fstring_ranges() | ||
.outermost(string_like.start()) | ||
.is_some_and(|outer| outer.start() < string_like.start() && string_like.end() < outer.end()) |
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.
We only want to ignore strings which are strictly inside another f-string which is not what TextRange::contains_range
does.
Weird, this PR doesn't include any change to the rules detected in the ecosystem checks |
continue; | ||
} | ||
pub(crate) fn check_string_quotes(checker: &mut Checker, string_like: StringLike) { | ||
// If the string is part of a f-string, ignore it. |
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.
Nit: I noticed that this rule performs quiet many allocations even in the happy path where the quotes match (collects the text ranges, collects the trivia, etc).
I wonder if we could add a fast path (you may need to wait for @AlexWaygood's changes) where we first test if:
- If it's a docstring, the quote matches the configured docstring quotes and if so, exits.
- For "regular strings", early exit if the configured inline or multiline quotes are the same and the string quotes match.
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.
Yeah, I had something similar in mind which is to completely rewrite this rule by only using the string flags which I think should be possible. I'll open a tracking issue for it. Thanks for the suggestion!
Edit: #10456
677178a
to
743c772
Compare
Summary
Continuing with #7595, this PR moves the
Q001
,Q002
,Q003
rules to the AST based checker.Test Plan
Make sure all of the existing test cases pass and verify there are no ecosystem changes.