Skip to content

Commit d86a710

Browse files
committed
Fix workspace support for RustPython AST fields
Assisted-by: Codex:GPT-5
1 parent 6fc0479 commit d86a710

142 files changed

Lines changed: 495 additions & 14 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ruff_graph/src/collector.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl<'ast> SourceOrderVisitor<'ast> for Collector<'_> {
4949
is_lazy: _,
5050
range: _,
5151
node_index: _,
52+
runtime_level: _,
5253
}) => {
5354
let module = module.as_deref();
5455
let level = *level;
@@ -106,6 +107,7 @@ impl<'ast> SourceOrderVisitor<'ast> for Collector<'_> {
106107
elif_else_clauses,
107108
range: _,
108109
node_index: _,
110+
runtime_body: _,
109111
}) => {
110112
// Skip TYPE_CHECKING blocks if not requested
111113
if self.type_checking_imports || !is_type_checking_condition(test) {

crates/ruff_linter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ruff_db = { workspace = true, features = ["junit", "serde"] }
1818
ruff_diagnostics = { workspace = true, features = ["serde"] }
1919
ruff_macros = { workspace = true }
2020
ruff_notebook = { workspace = true }
21-
ruff_python_ast = { workspace = true }
21+
ruff_python_ast = { workspace = true, features = ["serde", "cache"] }
2222
ruff_python_codegen = { workspace = true }
2323
ruff_python_importer = { workspace = true }
2424
ruff_python_index = { workspace = true }

crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub(crate) fn except_handler(except_handler: &ExceptHandler, checker: &Checker)
1616
body,
1717
range: _,
1818
node_index: _,
19+
runtime_body: _,
1920
}) => {
2021
if checker.is_rule_enabled(Rule::BareExcept) {
2122
pycodestyle::rules::bare_except(checker, type_.as_deref(), body, except_handler);

crates/ruff_linter/src/checkers/ast/analyze/expression.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
206206
range: _,
207207
node_index: _,
208208
parenthesized: _,
209+
runtime_elts: _,
209210
})
210211
| Expr::List(ast::ExprList {
211212
elts,
212213
ctx,
213214
range: _,
214215
node_index: _,
216+
runtime_elts: _,
215217
}) => {
216218
if checker.is_rule_enabled(Rule::ImplicitStringConcatenationInCollectionLiteral) {
217219
flake8_implicit_str_concat::rules::implicit_string_concatenation_in_collection_literal(
@@ -538,6 +540,8 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
538540
keywords,
539541
range: _,
540542
node_index: _,
543+
runtime_args: _,
544+
runtime_bases: _,
541545
},
542546
range_start: _,
543547
node_index: _,
@@ -1651,6 +1655,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
16511655
comparators,
16521656
range: _,
16531657
node_index: _,
1658+
runtime_comparators: _,
16541659
},
16551660
) => {
16561661
if checker.any_rule_enabled(&[Rule::NoneComparison, Rule::TrueFalseComparison]) {

crates/ruff_linter/src/checkers/ast/analyze/statement.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
5959
type_params: _,
6060
range: _,
6161
node_index: _,
62+
runtime_decorator_list: _,
63+
runtime_type_comment: _,
64+
runtime_type_comment_bytes: _,
65+
runtime_body: _,
6266
},
6367
) => {
6468
if checker.is_rule_enabled(Rule::DjangoNonLeadingReceiverDecorator) {
@@ -387,6 +391,8 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
387391
body,
388392
range: _,
389393
node_index: _,
394+
runtime_decorator_list: _,
395+
runtime_body: _,
390396
},
391397
) => {
392398
if checker.is_rule_enabled(Rule::NoClassmethodDecorator) {
@@ -715,6 +721,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
715721
is_lazy: _,
716722
range: _,
717723
node_index: _,
724+
runtime_level: _,
718725
},
719726
) => {
720727
let level = *level;
@@ -1255,6 +1262,10 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
12551262
is_async,
12561263
range: _,
12571264
node_index: _,
1265+
runtime_type_comment: _,
1266+
runtime_type_comment_bytes: _,
1267+
runtime_body: _,
1268+
runtime_orelse: _,
12581269
},
12591270
) => {
12601271
if checker.is_rule_enabled(Rule::TooManyNestedBlocks) {
@@ -1632,6 +1643,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
16321643
targets,
16331644
range: _,
16341645
node_index: _,
1646+
runtime_targets: _,
16351647
},
16361648
) => {
16371649
if checker.is_rule_enabled(Rule::GlobalStatement) {

crates/ruff_linter/src/checkers/ast/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
11371137
is_lazy,
11381138
range: _,
11391139
node_index: _,
1140+
runtime_level: _,
11401141
}) => {
11411142
if self.semantic.at_top_level() {
11421143
self.importer.visit_import(stmt);
@@ -1581,6 +1582,9 @@ impl<'a> Visitor<'a> for Checker<'a> {
15811582
is_async: _,
15821583
range: _,
15831584
node_index: _,
1585+
runtime_type_comment: _,
1586+
runtime_type_comment_bytes: _,
1587+
runtime_body: _,
15841588
}) => {
15851589
for item in items {
15861590
self.visit_with_item(item);
@@ -1595,6 +1599,8 @@ impl<'a> Visitor<'a> for Checker<'a> {
15951599
orelse,
15961600
range: _,
15971601
node_index: _,
1602+
runtime_body: _,
1603+
runtime_orelse: _,
15981604
}) => {
15991605
self.visit_boolean_test(test);
16001606
self.visit_body(body);
@@ -1611,6 +1617,10 @@ impl<'a> Visitor<'a> for Checker<'a> {
16111617
iter,
16121618
body,
16131619
orelse,
1620+
runtime_type_comment: _,
1621+
runtime_type_comment_bytes: _,
1622+
runtime_body: _,
1623+
runtime_orelse: _,
16141624
}) => {
16151625
self.visit_expr(iter);
16161626
self.visit_expr(target);
@@ -1627,6 +1637,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
16271637
elif_else_clauses,
16281638
range: _,
16291639
node_index: _,
1640+
runtime_body: _,
16301641
},
16311642
) => {
16321643
self.visit_boolean_test(test);
@@ -2079,6 +2090,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
20792090
items,
20802091
range: _,
20812092
node_index: _,
2093+
runtime_values: _,
20822094
}) = arg
20832095
{
20842096
for ast::DictItem { key, value } in items {
@@ -2189,6 +2201,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
21892201
range: _,
21902202
node_index: _,
21912203
parenthesized: _,
2204+
runtime_elts: _,
21922205
}) = slice.as_ref()
21932206
{
21942207
let mut iter = elts.iter();
@@ -2216,6 +2229,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
22162229
items,
22172230
range: _,
22182231
node_index: _,
2232+
runtime_values: _,
22192233
}) = slice.as_ref()
22202234
{
22212235
for item in items {
@@ -2307,6 +2321,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
23072321
body: _,
23082322
range: _,
23092323
node_index: _,
2324+
runtime_body: _,
23102325
}) => {
23112326
if let Some(name) = name {
23122327
// Store the existing binding, if any.

crates/ruff_linter/src/importer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ impl<'a> Importer<'a> {
468468
is_lazy: _,
469469
range: _,
470470
node_index: _,
471+
runtime_level: _,
471472
}) = stmt
472473
{
473474
if *level == 0

crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ fn find_runtime_varying_call<'a>(
268268
| Expr::BooleanLiteral(_)
269269
| Expr::NoneLiteral(_)
270270
| Expr::EllipsisLiteral(_)
271+
| Expr::Constant(_)
271272
| Expr::IpyEscapeCommand(_) => None,
272273
}
273274
}

crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ pub(crate) fn definition(
649649
parameters,
650650
returns,
651651
body,
652+
runtime_decorator_list: _,
653+
runtime_type_comment: _,
654+
runtime_type_comment_bytes: _,
655+
runtime_body: _,
652656
} = function;
653657

654658
let is_method = definition.is_method();

0 commit comments

Comments
 (0)