mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:14:52 +00:00
[ty] Shrink size of AstNodeRef
(#20028)
## Summary Removes the `module_ptr` field from `AstNodeRef` in release mode, and change `NodeIndex` to a `NonZeroU32` to reduce the size of `Option<AstNodeRef<_>>` fields. I believe CI runs in debug mode, so this won't show up in the memory report, but this reduces memory by ~2% in release mode.
This commit is contained in:
parent
886c4e4773
commit
7abc41727b
648 changed files with 19641 additions and 20364 deletions
|
@ -92,14 +92,14 @@ impl ParsedModule {
|
|||
self.inner.store(None);
|
||||
}
|
||||
|
||||
/// Returns a pointer for this [`ParsedModule`].
|
||||
/// Returns the pointer address of this [`ParsedModule`].
|
||||
///
|
||||
/// The pointer uniquely identifies the module within the current Salsa revision,
|
||||
/// regardless of whether particular [`ParsedModuleRef`] instances are garbage collected.
|
||||
pub fn as_ptr(&self) -> *const () {
|
||||
pub fn addr(&self) -> usize {
|
||||
// Note that the outer `Arc` in `inner` is stable across garbage collection, while the inner
|
||||
// `Arc` within the `ArcSwap` may change.
|
||||
Arc::as_ptr(&self.inner).cast()
|
||||
Arc::as_ptr(&self.inner).addr()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,9 +202,13 @@ mod indexed {
|
|||
|
||||
/// Returns the node at the given index.
|
||||
pub fn get_by_index<'ast>(&'ast self, index: NodeIndex) -> AnyRootNodeRef<'ast> {
|
||||
let index = index
|
||||
.as_u32()
|
||||
.expect("attempted to access uninitialized `NodeIndex`");
|
||||
|
||||
// Note that this method restores the correct lifetime: the nodes are valid for as
|
||||
// long as the reference to `IndexedModule` is alive.
|
||||
self.index[index.as_usize()]
|
||||
self.index[index as usize]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +224,7 @@ mod indexed {
|
|||
T: HasNodeIndex + std::fmt::Debug,
|
||||
AnyRootNodeRef<'a>: From<&'a T>,
|
||||
{
|
||||
node.node_index().set(self.index);
|
||||
node.node_index().set(NodeIndex::from(self.index));
|
||||
self.nodes.push(AnyRootNodeRef::from(node));
|
||||
self.index += 1;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ impl AutoPythonType {
|
|||
let expr = Expr::Name(ast::ExprName {
|
||||
id: Name::from(binding),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
});
|
||||
Some((expr, vec![no_return_edit]))
|
||||
|
@ -204,7 +204,7 @@ fn type_expr(python_type: PythonType) -> Option<Expr> {
|
|||
Expr::Name(ast::ExprName {
|
||||
id: name.into(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -52,13 +52,13 @@ impl AlwaysFixableViolation for AssertFalse {
|
|||
fn assertion_error(msg: Option<&Expr>) -> Stmt {
|
||||
Stmt::Raise(ast::StmtRaise {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
exc: Some(Box::new(Expr::Call(ast::ExprCall {
|
||||
func: Box::new(Expr::Name(ast::ExprName {
|
||||
id: "AssertionError".into(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
arguments: Arguments {
|
||||
args: if let Some(msg) = msg {
|
||||
|
@ -68,10 +68,10 @@ fn assertion_error(msg: Option<&Expr>) -> Stmt {
|
|||
},
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))),
|
||||
cause: None,
|
||||
})
|
||||
|
|
|
@ -113,7 +113,7 @@ fn type_pattern(elts: Vec<&Expr>) -> Expr {
|
|||
elts: elts.into_iter().cloned().collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
}
|
||||
.into()
|
||||
|
|
|
@ -53,11 +53,11 @@ fn assignment(obj: &Expr, name: &str, value: &Expr, generator: Generator) -> Str
|
|||
attr: Identifier::new(name.to_string(), TextRange::default()),
|
||||
ctx: ExprContext::Store,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})],
|
||||
value: Box::new(value.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
generator.stmt(&stmt)
|
||||
}
|
||||
|
|
|
@ -209,18 +209,18 @@ fn fix_unnecessary_dict_comprehension(value: &Expr, generator: &Comprehension) -
|
|||
},
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
Expr::Call(ExprCall {
|
||||
func: Box::new(Expr::Name(ExprName {
|
||||
id: "dict.fromkeys".into(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
arguments: args,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -178,21 +178,21 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) {
|
|||
.collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
});
|
||||
let node1 = Expr::Name(ast::ExprName {
|
||||
id: arg_name.into(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let node2 = Expr::Attribute(ast::ExprAttribute {
|
||||
value: Box::new(node1),
|
||||
attr: Identifier::new(attr_name.to_string(), TextRange::default()),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let node3 = Expr::Call(ast::ExprCall {
|
||||
func: Box::new(node2),
|
||||
|
@ -200,10 +200,10 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) {
|
|||
args: Box::from([node]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let call = node3;
|
||||
|
||||
|
@ -223,7 +223,7 @@ pub(crate) fn multiple_starts_ends_with(checker: &Checker, expr: &Expr) {
|
|||
})
|
||||
.collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let bool_op = node;
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
|
|
|
@ -92,14 +92,14 @@ pub(crate) fn duplicate_literal_member<'a>(checker: &Checker, expr: &'a Expr) {
|
|||
Expr::Tuple(ast::ExprTuple {
|
||||
elts: unique_nodes.into_iter().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: false,
|
||||
})
|
||||
}),
|
||||
value: subscript.value.clone(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
});
|
||||
let fix = Fix::applicable_edit(
|
||||
|
|
|
@ -187,7 +187,7 @@ fn generate_pep604_fix(
|
|||
op: Operator::BitOr,
|
||||
right: Box::new(right.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
} else {
|
||||
Some(right.clone())
|
||||
|
@ -202,7 +202,7 @@ fn generate_pep604_fix(
|
|||
}
|
||||
|
||||
static VIRTUAL_NONE_LITERAL: Expr = Expr::NoneLiteral(ExprNoneLiteral {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::new(TextSize::new(0), TextSize::new(0)),
|
||||
});
|
||||
|
||||
|
|
|
@ -133,17 +133,17 @@ fn generate_union_fix(
|
|||
// Construct the expression as `Subscript[typing.Union, Tuple[expr, [expr, ...]]]`
|
||||
let new_expr = Expr::Subscript(ExprSubscript {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
value: Box::new(Expr::Name(ExprName {
|
||||
id: Name::new(binding),
|
||||
ctx: ExprContext::Store,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
slice: Box::new(Expr::Tuple(ExprTuple {
|
||||
elts: nodes.into_iter().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: false,
|
||||
})),
|
||||
|
|
|
@ -205,13 +205,13 @@ fn create_fix(
|
|||
let new_literal_expr = Expr::Subscript(ast::ExprSubscript {
|
||||
value: Box::new(literal_subscript.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
slice: Box::new(if literal_elements.len() > 1 {
|
||||
Expr::Tuple(ast::ExprTuple {
|
||||
elts: literal_elements.into_iter().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: true,
|
||||
})
|
||||
|
@ -235,7 +235,7 @@ fn create_fix(
|
|||
UnionKind::BitOr => {
|
||||
let none_expr = Expr::NoneLiteral(ExprNoneLiteral {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let union_expr = pep_604_union(&[new_literal_expr, none_expr]);
|
||||
let content = checker.generator().expr(&union_expr);
|
||||
|
|
|
@ -261,7 +261,7 @@ fn generate_pep604_fix(
|
|||
op: Operator::BitOr,
|
||||
right: Box::new(right.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
} else {
|
||||
Some(right.clone())
|
||||
|
|
|
@ -140,12 +140,12 @@ pub(crate) fn unnecessary_literal_union<'a>(checker: &Checker, expr: &'a Expr) {
|
|||
slice: Box::new(Expr::Tuple(ast::ExprTuple {
|
||||
elts: literal_exprs.into_iter().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: true,
|
||||
})),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
});
|
||||
|
||||
|
@ -164,12 +164,12 @@ pub(crate) fn unnecessary_literal_union<'a>(checker: &Checker, expr: &'a Expr) {
|
|||
slice: Box::new(Expr::Tuple(ast::ExprTuple {
|
||||
elts,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: true,
|
||||
})),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
}))
|
||||
} else {
|
||||
|
|
|
@ -134,12 +134,12 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &Checker, union: &'a Expr) {
|
|||
id: Name::new_static("type"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
slice: Box::new(pep_604_union(&elts)),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
if other_exprs.is_empty() {
|
||||
|
@ -159,7 +159,7 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &Checker, union: &'a Expr) {
|
|||
id: Name::new_static("type"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
slice: Box::new(Expr::Subscript(ast::ExprSubscript {
|
||||
value: subscript.value.clone(),
|
||||
|
@ -171,22 +171,22 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &Checker, union: &'a Expr) {
|
|||
id: type_member,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
})),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
if other_exprs.is_empty() {
|
||||
|
@ -202,12 +202,12 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &Checker, union: &'a Expr) {
|
|||
elts: exprs.into_iter().cloned().collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
})),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
checker.generator().expr(&union)
|
||||
|
|
|
@ -301,7 +301,7 @@ fn elts_to_csv(elts: &[Expr], generator: Generator, flags: StringLiteralFlags) -
|
|||
})
|
||||
.into_boxed_str(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags,
|
||||
});
|
||||
Some(generator.expr(&node))
|
||||
|
@ -367,14 +367,14 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr
|
|||
Expr::from(ast::StringLiteral {
|
||||
value: Box::from(*name),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags: checker.default_string_flags(),
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
});
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
|
@ -404,14 +404,14 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr
|
|||
Expr::from(ast::StringLiteral {
|
||||
value: Box::from(*name),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags: checker.default_string_flags(),
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&node),
|
||||
|
@ -440,7 +440,7 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr
|
|||
elts: elts.clone(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&node),
|
||||
|
@ -485,7 +485,7 @@ fn check_names(checker: &Checker, call: &ExprCall, expr: &Expr, argvalues: &Expr
|
|||
elts: elts.clone(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
});
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
|
|
|
@ -166,7 +166,7 @@ fn assert(expr: &Expr, msg: Option<&Expr>) -> Stmt {
|
|||
test: Box::new(expr.clone()),
|
||||
msg: msg.map(|msg| Box::new(msg.clone())),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ fn compare(left: &Expr, cmp_op: CmpOp, right: &Expr) -> Expr {
|
|||
ops: Box::from([cmp_op]),
|
||||
comparators: Box::from([right.clone()]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ impl UnittestAssert {
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(expr.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}),
|
||||
msg,
|
||||
)
|
||||
|
@ -370,7 +370,7 @@ impl UnittestAssert {
|
|||
};
|
||||
let node = Expr::NoneLiteral(ast::ExprNoneLiteral {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let expr = compare(expr, cmp_op, &node);
|
||||
Ok(assert(&expr, msg))
|
||||
|
@ -387,7 +387,7 @@ impl UnittestAssert {
|
|||
id: Name::new_static("isinstance"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node1 = ast::ExprCall {
|
||||
func: Box::new(node.into()),
|
||||
|
@ -395,10 +395,10 @@ impl UnittestAssert {
|
|||
args: Box::from([(**obj).clone(), (**cls).clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let isinstance = node1.into();
|
||||
if matches!(self, UnittestAssert::IsInstance) {
|
||||
|
@ -408,7 +408,7 @@ impl UnittestAssert {
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(isinstance),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let expr = node.into();
|
||||
Ok(assert(&expr, msg))
|
||||
|
@ -429,14 +429,14 @@ impl UnittestAssert {
|
|||
id: Name::new_static("re"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node1 = ast::ExprAttribute {
|
||||
value: Box::new(node.into()),
|
||||
attr: Identifier::new("search".to_string(), TextRange::default()),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node2 = ast::ExprCall {
|
||||
func: Box::new(node1.into()),
|
||||
|
@ -444,10 +444,10 @@ impl UnittestAssert {
|
|||
args: Box::from([(**regex).clone(), (**text).clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let re_search = node2.into();
|
||||
if matches!(self, UnittestAssert::Regex | UnittestAssert::RegexpMatches) {
|
||||
|
@ -457,7 +457,7 @@ impl UnittestAssert {
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(re_search),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
Ok(assert(&node.into(), msg))
|
||||
}
|
||||
|
|
|
@ -421,7 +421,7 @@ pub(crate) fn duplicate_isinstance_call(checker: &Checker, expr: &Expr) {
|
|||
.collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
};
|
||||
let isinstance_call = ast::ExprCall {
|
||||
|
@ -430,7 +430,7 @@ pub(crate) fn duplicate_isinstance_call(checker: &Checker, expr: &Expr) {
|
|||
id: Name::new_static("isinstance"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -438,10 +438,10 @@ pub(crate) fn duplicate_isinstance_call(checker: &Checker, expr: &Expr) {
|
|||
args: Box::from([target.clone(), tuple.into()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into();
|
||||
|
||||
|
@ -458,7 +458,7 @@ pub(crate) fn duplicate_isinstance_call(checker: &Checker, expr: &Expr) {
|
|||
.chain(after)
|
||||
.collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into();
|
||||
let fixed_source = checker.generator().expr(&bool_op);
|
||||
|
@ -552,21 +552,21 @@ pub(crate) fn compare_with_tuple(checker: &Checker, expr: &Expr) {
|
|||
elts: comparators.into_iter().cloned().collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
};
|
||||
let node1 = ast::ExprName {
|
||||
id: id.clone(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node2 = ast::ExprCompare {
|
||||
left: Box::new(node1.into()),
|
||||
ops: Box::from([CmpOp::In]),
|
||||
comparators: Box::from([node.into()]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let in_expr = node2.into();
|
||||
let mut diagnostic = checker.report_diagnostic(
|
||||
|
@ -589,7 +589,7 @@ pub(crate) fn compare_with_tuple(checker: &Checker, expr: &Expr) {
|
|||
op: BoolOp::Or,
|
||||
values: iter::once(in_expr).chain(unmatched).collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
node.into()
|
||||
};
|
||||
|
|
|
@ -232,7 +232,7 @@ fn check_os_environ_subscript(checker: &Checker, expr: &Expr) {
|
|||
}
|
||||
}),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let new_env_var = node.into();
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
|
|
|
@ -188,7 +188,7 @@ pub(crate) fn if_expr_with_true_false(
|
|||
id: Name::new_static("bool"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -196,10 +196,10 @@ pub(crate) fn if_expr_with_true_false(
|
|||
args: Box::from([test.clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -227,7 +227,7 @@ pub(crate) fn if_expr_with_false_true(
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(test.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -282,7 +282,7 @@ pub(crate) fn twisted_arms_in_ifexpr(
|
|||
body: Box::new(node1),
|
||||
orelse: Box::new(node),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&node3.into()),
|
||||
|
|
|
@ -186,7 +186,7 @@ pub(crate) fn negation_with_equal_op(checker: &Checker, expr: &Expr, op: UnaryOp
|
|||
ops: Box::from([CmpOp::NotEq]),
|
||||
comparators: comparators.clone(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&node.into()),
|
||||
|
@ -242,7 +242,7 @@ pub(crate) fn negation_with_not_equal_op(
|
|||
ops: Box::from([CmpOp::Eq]),
|
||||
comparators: comparators.clone(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&node.into()),
|
||||
|
@ -284,7 +284,7 @@ pub(crate) fn double_negation(checker: &Checker, expr: &Expr, op: UnaryOp, opera
|
|||
id: Name::new_static("bool"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node1 = ast::ExprCall {
|
||||
func: Box::new(node.into()),
|
||||
|
@ -292,10 +292,10 @@ pub(crate) fn double_negation(checker: &Checker, expr: &Expr, op: UnaryOp, opera
|
|||
args: Box::from([*operand.clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&node1.into()),
|
||||
|
|
|
@ -190,7 +190,7 @@ pub(crate) fn if_else_block_instead_of_dict_get(checker: &Checker, stmt_if: &ast
|
|||
attr: Identifier::new("get".to_string(), TextRange::default()),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node3 = ast::ExprCall {
|
||||
func: Box::new(node2.into()),
|
||||
|
@ -198,17 +198,17 @@ pub(crate) fn if_else_block_instead_of_dict_get(checker: &Checker, stmt_if: &ast
|
|||
args: Box::from([node1, node]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node4 = expected_var.clone();
|
||||
let node5 = ast::StmtAssign {
|
||||
targets: vec![node4],
|
||||
value: Box::new(node3.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let contents = checker.generator().stmt(&node5.into());
|
||||
|
||||
|
@ -299,7 +299,7 @@ pub(crate) fn if_exp_instead_of_dict_get(
|
|||
attr: Identifier::new("get".to_string(), TextRange::default()),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let fixed_node = ast::ExprCall {
|
||||
func: Box::new(dict_get_node.into()),
|
||||
|
@ -307,10 +307,10 @@ pub(crate) fn if_exp_instead_of_dict_get(
|
|||
args: Box::from([dict_key_node, default_value_node]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
|
||||
let contents = checker.generator().expr(&fixed_node.into());
|
||||
|
|
|
@ -266,13 +266,13 @@ fn assignment_ternary(
|
|||
body: Box::new(body_value.clone()),
|
||||
orelse: Box::new(orelse_value.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node1 = ast::StmtAssign {
|
||||
targets: vec![target_var.clone()],
|
||||
value: Box::new(node.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
node1.into()
|
||||
}
|
||||
|
@ -282,13 +282,13 @@ fn assignment_binary_and(target_var: &Expr, left_value: &Expr, right_value: &Exp
|
|||
op: BoolOp::And,
|
||||
values: vec![left_value.clone(), right_value.clone()],
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node1 = ast::StmtAssign {
|
||||
targets: vec![target_var.clone()],
|
||||
value: Box::new(node.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
node1.into()
|
||||
}
|
||||
|
@ -296,12 +296,12 @@ fn assignment_binary_and(target_var: &Expr, left_value: &Expr, right_value: &Exp
|
|||
fn assignment_binary_or(target_var: &Expr, left_value: &Expr, right_value: &Expr) -> Stmt {
|
||||
(ast::StmtAssign {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
targets: vec![target_var.clone()],
|
||||
value: Box::new(
|
||||
(ast::ExprBoolOp {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
op: BoolOp::Or,
|
||||
values: vec![left_value.clone(), right_value.clone()],
|
||||
})
|
||||
|
|
|
@ -256,7 +256,7 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) {
|
|||
left: left.clone(),
|
||||
comparators: Box::new([right.clone()]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) {
|
|||
op: ast::UnaryOp::Not,
|
||||
operand: Box::new(if_test.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
}
|
||||
} else if if_test.is_compare_expr() {
|
||||
|
@ -277,7 +277,7 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) {
|
|||
id: Name::new_static("bool"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let call_node = ast::ExprCall {
|
||||
func: Box::new(func_node.into()),
|
||||
|
@ -285,10 +285,10 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) {
|
|||
args: Box::from([if_test.clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
Some(Expr::Call(call_node))
|
||||
} else {
|
||||
|
@ -301,7 +301,7 @@ pub(crate) fn needless_bool(checker: &Checker, stmt: &Stmt) {
|
|||
Stmt::Return(ast::StmtReturn {
|
||||
value: Some(Box::new(expr.clone())),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
|||
ops: Box::from([op]),
|
||||
comparators: Box::from([comparator.clone()]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
node.into()
|
||||
} else {
|
||||
|
@ -173,7 +173,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(loop_.test.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
node.into()
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ pub(crate) fn convert_for_loop_to_any_all(checker: &Checker, stmt: &Stmt) {
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(loop_.test.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
node.into()
|
||||
}
|
||||
|
@ -406,17 +406,17 @@ fn return_stmt(id: Name, test: &Expr, target: &Expr, iter: &Expr, generator: Gen
|
|||
ifs: vec![],
|
||||
is_async: false,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}],
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: false,
|
||||
};
|
||||
let node1 = ast::ExprName {
|
||||
id,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node2 = ast::ExprCall {
|
||||
func: Box::new(node1.into()),
|
||||
|
@ -424,15 +424,15 @@ fn return_stmt(id: Name, test: &Expr, target: &Expr, iter: &Expr, generator: Gen
|
|||
args: Box::from([node.into()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let node3 = ast::StmtReturn {
|
||||
value: Some(Box::new(node2.into())),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
generator.stmt(&node3.into())
|
||||
}
|
||||
|
|
|
@ -163,14 +163,14 @@ fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr {
|
|||
Expr::from(StringLiteral {
|
||||
value: Box::from(*elt),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags: element_flags,
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ fn fix_banned_relative_import(
|
|||
names: names.clone(),
|
||||
level: 0,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let content = generator.stmt(&node.into());
|
||||
Some(Fix::unsafe_edit(Edit::range_replacement(
|
||||
|
|
|
@ -436,7 +436,7 @@ impl<'a> QuoteAnnotator<'a> {
|
|||
let annotation = subgenerator.expr(&expr_without_forward_references);
|
||||
generator.expr(&Expr::from(ast::StringLiteral {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
value: annotation.into_boxed_str(),
|
||||
flags: self.flags,
|
||||
}))
|
||||
|
|
|
@ -9,7 +9,7 @@ fn to_interpolated_string_interpolation_element(inner: &Expr) -> ast::Interpolat
|
|||
conversion: ConversionFlag::None,
|
||||
format_spec: None,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ pub(super) fn to_interpolated_string_literal_element(s: &str) -> ast::Interpolat
|
|||
ast::InterpolatedStringElement::Literal(ast::InterpolatedStringLiteralElement {
|
||||
value: Box::from(s),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ fn build_fstring(joiner: &str, joinees: &[Expr], flags: FStringFlags) -> Option<
|
|||
.into_boxed_str(),
|
||||
flags: flags?,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
return Some(node.into());
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ fn build_fstring(joiner: &str, joinees: &[Expr], flags: FStringFlags) -> Option<
|
|||
let node = ast::FString {
|
||||
elements: f_string_elements.into(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags,
|
||||
};
|
||||
Some(node.into())
|
||||
|
|
|
@ -182,7 +182,7 @@ fn function(
|
|||
ExprEllipsisLiteral::default(),
|
||||
))),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let parameters = lambda.parameters.as_deref().cloned().unwrap_or_default();
|
||||
if let Some(annotation) = annotation {
|
||||
|
@ -230,7 +230,7 @@ fn function(
|
|||
returns: Some(Box::new(return_type)),
|
||||
type_params: None,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let generated = checker.generator().stmt(&func);
|
||||
|
||||
|
@ -246,7 +246,7 @@ fn function(
|
|||
returns: None,
|
||||
type_params: None,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let generated = checker.generator().stmt(&function);
|
||||
|
||||
|
|
|
@ -72,11 +72,11 @@ pub(crate) fn manual_from_import(checker: &Checker, stmt: &Stmt, alias: &Alias,
|
|||
name: asname.clone(),
|
||||
asname: None,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}],
|
||||
level: 0,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
|
||||
checker.generator().stmt(&node.into()),
|
||||
|
|
|
@ -147,7 +147,7 @@ fn collect_nested_args(min_max: MinMax, args: &[Expr], semantic: &SemanticModel)
|
|||
value: Box::new(arg.clone()),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
new_args.push(new_arg);
|
||||
continue;
|
||||
|
@ -204,10 +204,10 @@ pub(crate) fn nested_min_max(
|
|||
args: collect_nested_args(min_max, args, checker.semantic()).into_boxed_slice(),
|
||||
keywords: Box::from(keywords),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
|
||||
checker.generator().expr(&flattened_expr),
|
||||
|
|
|
@ -170,13 +170,13 @@ pub(crate) fn repeated_equality_comparison(checker: &Checker, bool_op: &ast::Exp
|
|||
Expr::Set(ast::ExprSet {
|
||||
elts: comparators.iter().copied().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
} else {
|
||||
Expr::Tuple(ast::ExprTuple {
|
||||
elts: comparators.iter().copied().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: true,
|
||||
})
|
||||
|
@ -194,12 +194,12 @@ pub(crate) fn repeated_equality_comparison(checker: &Checker, bool_op: &ast::Exp
|
|||
},
|
||||
comparators: Box::from([comparator]),
|
||||
range: bool_op.range(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})))
|
||||
.chain(after)
|
||||
.collect(),
|
||||
range: bool_op.range(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
bool_op.range(),
|
||||
)));
|
||||
|
|
|
@ -188,7 +188,7 @@ fn generate_keyword_fix(checker: &Checker, call: &ast::ExprCall) -> Fix {
|
|||
value: Box::from("utf-8"),
|
||||
flags: checker.default_string_flags(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
),
|
||||
&call.arguments,
|
||||
|
|
|
@ -87,7 +87,7 @@ pub(crate) fn convert_named_tuple_functional_to_class(
|
|||
// Ex) `NamedTuple("MyType")`
|
||||
([_typename], []) => vec![Stmt::Pass(ast::StmtPass {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})],
|
||||
// Ex) `NamedTuple("MyType", [("a", int), ("b", str)])`
|
||||
([_typename, fields], []) => {
|
||||
|
@ -165,7 +165,7 @@ fn create_field_assignment_stmt(field: Name, annotation: &Expr) -> Stmt {
|
|||
id: field,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -173,7 +173,7 @@ fn create_field_assignment_stmt(field: Name, annotation: &Expr) -> Stmt {
|
|||
value: None,
|
||||
simple: true,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ fn create_fields_from_fields_arg(fields: &Expr) -> Option<Vec<Stmt>> {
|
|||
if fields.is_empty() {
|
||||
let node = Stmt::Pass(ast::StmtPass {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Some(vec![node])
|
||||
} else {
|
||||
|
@ -236,13 +236,13 @@ fn create_class_def_stmt(typename: &str, body: Vec<Stmt>, base_class: &Expr) ->
|
|||
args: Box::from([base_class.clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
body,
|
||||
type_params: None,
|
||||
decorator_list: vec![],
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ fn create_field_assignment_stmt(field: &str, annotation: &Expr) -> Stmt {
|
|||
id: field.into(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -158,7 +158,7 @@ fn create_field_assignment_stmt(field: &str, annotation: &Expr) -> Stmt {
|
|||
value: None,
|
||||
simple: true,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -179,13 +179,13 @@ fn create_class_def_stmt(
|
|||
None => Box::from([]),
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
body,
|
||||
type_params: None,
|
||||
decorator_list: vec![],
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ fn fields_from_dict_literal(items: &[ast::DictItem]) -> Option<Vec<Stmt>> {
|
|||
if items.is_empty() {
|
||||
let node = Stmt::Pass(ast::StmtPass {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Some(vec![node])
|
||||
} else {
|
||||
|
@ -228,7 +228,7 @@ fn fields_from_dict_call(func: &Expr, keywords: &[Keyword]) -> Option<Vec<Stmt>>
|
|||
if keywords.is_empty() {
|
||||
let node = Stmt::Pass(ast::StmtPass {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Some(vec![node])
|
||||
} else {
|
||||
|
@ -241,7 +241,7 @@ fn fields_from_keywords(keywords: &[Keyword]) -> Option<Vec<Stmt>> {
|
|||
if keywords.is_empty() {
|
||||
let node = Stmt::Pass(ast::StmtPass {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
return Some(vec![node]);
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ fn match_fields_and_total(arguments: &Arguments) -> Option<(Vec<Stmt>, Option<&K
|
|||
([_typename], []) => {
|
||||
let node = Stmt::Pass(ast::StmtPass {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Some((vec![node], None))
|
||||
}
|
||||
|
|
|
@ -39,27 +39,27 @@ impl LiteralType {
|
|||
LiteralType::Str => ast::StringLiteral {
|
||||
value: Box::default(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags: checker.default_string_flags(),
|
||||
}
|
||||
.into(),
|
||||
LiteralType::Bytes => ast::BytesLiteral {
|
||||
value: Box::default(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
flags: checker.default_bytes_flags(),
|
||||
}
|
||||
.into(),
|
||||
LiteralType::Int => ast::ExprNumberLiteral {
|
||||
value: ast::Number::Int(Int::from(0u8)),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
LiteralType::Float => ast::ExprNumberLiteral {
|
||||
value: ast::Number::Float(0.0),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
LiteralType::Bool => ast::ExprBooleanLiteral::default().into(),
|
||||
|
|
|
@ -116,7 +116,7 @@ fn tuple_diagnostic(checker: &Checker, tuple: &ast::ExprTuple, aliases: &[&Expr]
|
|||
id: Name::new_static("OSError"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
remaining.insert(0, node.into());
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ fn tuple_diagnostic(checker: &Checker, tuple: &ast::ExprTuple, aliases: &[&Expr]
|
|||
elts: remaining,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
};
|
||||
format!("({})", checker.generator().expr(&node.into()))
|
||||
|
|
|
@ -140,14 +140,14 @@ impl<'a> From<&'a TypeVar<'a>> for TypeParam {
|
|||
TypeParamKind::TypeVar => {
|
||||
TypeParam::TypeVar(TypeParamTypeVar {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
name: Identifier::new(*name, TextRange::default()),
|
||||
bound: match restriction {
|
||||
Some(TypeVarRestriction::Bound(bound)) => Some(Box::new((*bound).clone())),
|
||||
Some(TypeVarRestriction::Constraint(constraints)) => {
|
||||
Some(Box::new(Expr::Tuple(ast::ExprTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
elts: constraints.iter().map(|expr| (*expr).clone()).collect(),
|
||||
ctx: ast::ExprContext::Load,
|
||||
parenthesized: true,
|
||||
|
@ -156,17 +156,17 @@ impl<'a> From<&'a TypeVar<'a>> for TypeParam {
|
|||
Some(TypeVarRestriction::AnyStr) => {
|
||||
Some(Box::new(Expr::Tuple(ast::ExprTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
elts: vec![
|
||||
Expr::Name(ExprName {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
id: Name::from("str"),
|
||||
ctx: ast::ExprContext::Load,
|
||||
}),
|
||||
Expr::Name(ExprName {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
id: Name::from("bytes"),
|
||||
ctx: ast::ExprContext::Load,
|
||||
}),
|
||||
|
@ -184,13 +184,13 @@ impl<'a> From<&'a TypeVar<'a>> for TypeParam {
|
|||
}
|
||||
TypeParamKind::TypeVarTuple => TypeParam::TypeVarTuple(TypeParamTypeVarTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
name: Identifier::new(*name, TextRange::default()),
|
||||
default: None,
|
||||
}),
|
||||
TypeParamKind::ParamSpec => TypeParam::ParamSpec(TypeParamParamSpec {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
name: Identifier::new(*name, TextRange::default()),
|
||||
default: None,
|
||||
}),
|
||||
|
|
|
@ -130,7 +130,7 @@ fn tuple_diagnostic(checker: &Checker, tuple: &ast::ExprTuple, aliases: &[&Expr]
|
|||
id: Name::new_static("TimeoutError"),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
remaining.insert(0, node.into());
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ fn tuple_diagnostic(checker: &Checker, tuple: &ast::ExprTuple, aliases: &[&Expr]
|
|||
elts: remaining,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
};
|
||||
format!("({})", checker.generator().expr(&node.into()))
|
||||
|
|
|
@ -127,13 +127,13 @@ pub(crate) fn unnecessary_default_type_args(checker: &Checker, expr: &Expr) {
|
|||
elts: valid_elts,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
})
|
||||
}),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
expr.range(),
|
||||
),
|
||||
|
|
|
@ -17,7 +17,7 @@ pub(super) fn generate_method_call(name: Name, method: &str, generator: Generato
|
|||
id: name,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Construct `name.method`.
|
||||
let attr = ast::ExprAttribute {
|
||||
|
@ -25,7 +25,7 @@ pub(super) fn generate_method_call(name: Name, method: &str, generator: Generato
|
|||
attr: ast::Identifier::new(method.to_string(), TextRange::default()),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Make it into a call `name.method()`
|
||||
let call = ast::ExprCall {
|
||||
|
@ -34,16 +34,16 @@ pub(super) fn generate_method_call(name: Name, method: &str, generator: Generato
|
|||
args: Box::from([]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// And finally, turn it into a statement.
|
||||
let stmt = ast::StmtExpr {
|
||||
value: Box::new(call.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
generator.stmt(&stmt.into())
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub(super) fn replace_with_identity_check(
|
|||
ops: [op].into(),
|
||||
comparators: [ast::ExprNoneLiteral::default().into()].into(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
let new_content = generator.expr(&new_expr);
|
||||
|
|
|
@ -185,7 +185,7 @@ fn make_suggestion(set: &ast::ExprName, element: &Expr, generator: Generator) ->
|
|||
attr: ast::Identifier::new("discard".to_string(), TextRange::default()),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Make the actual call `set.discard(element)`
|
||||
let call = ast::ExprCall {
|
||||
|
@ -194,16 +194,16 @@ fn make_suggestion(set: &ast::ExprName, element: &Expr, generator: Generator) ->
|
|||
args: Box::from([element.clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// And finally, turn it into a statement.
|
||||
let stmt = ast::StmtExpr {
|
||||
value: Box::new(call.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
generator.stmt(&stmt.into())
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ fn make_suggestion(open: &FileOpen<'_>, generator: Generator) -> SourceCodeSnipp
|
|||
id: open.mode.pathlib_method(),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let call = ast::ExprCall {
|
||||
func: Box::new(name.into()),
|
||||
|
@ -138,10 +138,10 @@ fn make_suggestion(open: &FileOpen<'_>, generator: Generator) -> SourceCodeSnipp
|
|||
args: Box::from([]),
|
||||
keywords: open.keywords.iter().copied().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
SourceCodeSnippet::from_str(&generator.expr(&call.into()))
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ fn construct_starmap_call(starmap_binding: Name, iter: &Expr, func: &Expr) -> as
|
|||
id: starmap_binding,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
ast::ExprCall {
|
||||
func: Box::new(starmap.into()),
|
||||
|
@ -306,10 +306,10 @@ fn construct_starmap_call(starmap_binding: Name, iter: &Expr, func: &Expr) -> as
|
|||
args: Box::from([func.clone(), iter.clone()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ fn wrap_with_call_to(call: ast::ExprCall, func_name: Name) -> ast::ExprCall {
|
|||
id: func_name,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
ast::ExprCall {
|
||||
func: Box::new(name.into()),
|
||||
|
@ -327,10 +327,10 @@ fn wrap_with_call_to(call: ast::ExprCall, func_name: Name) -> ast::ExprCall {
|
|||
args: Box::from([call.into()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ fn make_suggestion(group: &AppendGroup, generator: Generator) -> String {
|
|||
elts,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
};
|
||||
// Make `var.extend`.
|
||||
|
@ -352,7 +352,7 @@ fn make_suggestion(group: &AppendGroup, generator: Generator) -> String {
|
|||
attr: ast::Identifier::new("extend".to_string(), TextRange::default()),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Make the actual call `var.extend((elt1, elt2, ..., eltN))`
|
||||
let call = ast::ExprCall {
|
||||
|
@ -361,16 +361,16 @@ fn make_suggestion(group: &AppendGroup, generator: Generator) -> String {
|
|||
args: Box::from([tuple.into()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// And finally, turn it into a statement.
|
||||
let stmt = ast::StmtExpr {
|
||||
value: Box::new(call.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
generator.stmt(&stmt.into())
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String {
|
|||
id: name,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Construct `len(name)`.
|
||||
let len = ast::ExprCall {
|
||||
|
@ -241,7 +241,7 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String {
|
|||
id: Name::new_static("len"),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -249,10 +249,10 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String {
|
|||
args: Box::from([var.into()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Construct `range(len(name))`.
|
||||
let range = ast::ExprCall {
|
||||
|
@ -261,7 +261,7 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String {
|
|||
id: Name::new_static("range"),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
|
@ -269,16 +269,16 @@ fn generate_range_len_call(name: Name, generator: Generator) -> String {
|
|||
args: Box::from([len.into()]),
|
||||
keywords: Box::from([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// And finally, turn it into a statement.
|
||||
let stmt = ast::StmtExpr {
|
||||
value: Box::new(range.into()),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
generator.stmt(&stmt.into())
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ fn make_suggestion(open: &FileOpen<'_>, arg: &Expr, generator: Generator) -> Sou
|
|||
id: open.mode.pathlib_method(),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let mut arg = arg.clone();
|
||||
relocate_expr(&mut arg, TextRange::default());
|
||||
|
@ -158,10 +158,10 @@ fn make_suggestion(open: &FileOpen<'_>, arg: &Expr, generator: Generator) -> Sou
|
|||
args: Box::new([arg]),
|
||||
keywords: open.keywords.iter().copied().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
SourceCodeSnippet::from_str(&generator.expr(&call.into()))
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ pub(crate) fn assert_with_print_message(checker: &Checker, stmt: &ast::StmtAsser
|
|||
test: stmt.test.clone(),
|
||||
msg: print_arguments::to_expr(&call.arguments, checker).map(Box::new),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
// We have to replace the entire statement,
|
||||
// as the `print` could be empty and thus `call.range()`
|
||||
|
@ -114,7 +114,7 @@ mod print_arguments {
|
|||
InterpolatedStringElement::Literal(InterpolatedStringLiteralElement {
|
||||
value: part.value.clone(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
|
@ -131,7 +131,7 @@ mod print_arguments {
|
|||
conversion: ConversionFlag::None,
|
||||
format_spec: None,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
)],
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ mod print_arguments {
|
|||
value: literal.value.clone(),
|
||||
flags,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Some(acc)
|
||||
} else {
|
||||
|
@ -212,7 +212,7 @@ mod print_arguments {
|
|||
value: combined_string.into(),
|
||||
flags,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -246,10 +246,10 @@ mod print_arguments {
|
|||
elements: InterpolatedStringElements::from(fstring_elements),
|
||||
flags,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ mod print_arguments {
|
|||
vec![InterpolatedStringElement::Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
value: " ".into(),
|
||||
},
|
||||
)]
|
||||
|
|
|
@ -78,7 +78,7 @@ fn make_splat_elts(
|
|||
value: Box::from(splat_element.clone()),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
let splat = node.into();
|
||||
if splat_at_left {
|
||||
|
@ -166,14 +166,14 @@ fn concatenate_expressions(expr: &Expr) -> Option<(Expr, Type)> {
|
|||
elts: new_elts,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into(),
|
||||
Type::Tuple => ast::ExprTuple {
|
||||
elts: new_elts,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
}
|
||||
.into(),
|
||||
|
|
|
@ -140,7 +140,7 @@ fn generate_fix(checker: &Checker, conversion_type: ConversionType, expr: &Expr)
|
|||
op: Operator::BitOr,
|
||||
right: Box::new(Expr::NoneLiteral(ast::ExprNoneLiteral::default())),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
let content = checker.generator().expr(&new_expr);
|
||||
let edit = Edit::range_replacement(content, expr.range());
|
||||
|
@ -160,12 +160,12 @@ fn generate_fix(checker: &Checker, conversion_type: ConversionType, expr: &Expr)
|
|||
let (import_edit, binding) = importer.import(expr.start())?;
|
||||
let new_expr = Expr::Subscript(ast::ExprSubscript {
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
value: Box::new(Expr::Name(ast::ExprName {
|
||||
id: Name::new(binding),
|
||||
ctx: ast::ExprContext::Store,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})),
|
||||
slice: Box::new(expr.clone()),
|
||||
ctx: ast::ExprContext::Load,
|
||||
|
|
|
@ -245,16 +245,16 @@ fn generate_with_statement(
|
|||
});
|
||||
|
||||
let context_call = ast::ExprCall {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
func: legacy_call.func.clone(),
|
||||
arguments: ast::Arguments {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
args: expected.cloned().as_slice().into(),
|
||||
keywords: match_arg
|
||||
.map(|expr| ast::Keyword {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
// Take range from the original expression so that the keyword
|
||||
// argument is generated after positional arguments
|
||||
range: expr.range(),
|
||||
|
@ -267,11 +267,11 @@ fn generate_with_statement(
|
|||
};
|
||||
|
||||
let func_call = ast::ExprCall {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
func: Box::new(func.clone()),
|
||||
arguments: ast::Arguments {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
args: func_args.into(),
|
||||
keywords: func_keywords.into(),
|
||||
|
@ -280,25 +280,25 @@ fn generate_with_statement(
|
|||
|
||||
let body = if let Some(assign_targets) = assign_targets {
|
||||
Stmt::Assign(ast::StmtAssign {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
targets: assign_targets.to_vec(),
|
||||
value: Box::new(func_call.into()),
|
||||
})
|
||||
} else {
|
||||
Stmt::Expr(StmtExpr {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
value: Box::new(func_call.into()),
|
||||
})
|
||||
};
|
||||
|
||||
Some(StmtWith {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
is_async: false,
|
||||
items: vec![WithItem {
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range: TextRange::default(),
|
||||
context_expr: context_call.into(),
|
||||
optional_vars: optional_vars.map(|var| Box::new(var.clone())),
|
||||
|
|
|
@ -102,7 +102,7 @@ fn generate_dict_comprehension(keys: &Expr, value: &Expr, generator: Generator)
|
|||
id: Name::new_static("key"),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
// Construct `key in keys`.
|
||||
let comp = ast::Comprehension {
|
||||
|
@ -110,7 +110,7 @@ fn generate_dict_comprehension(keys: &Expr, value: &Expr, generator: Generator)
|
|||
iter: keys.clone(),
|
||||
ifs: vec![],
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
is_async: false,
|
||||
};
|
||||
// Construct the dict comprehension.
|
||||
|
@ -119,7 +119,7 @@ fn generate_dict_comprehension(keys: &Expr, value: &Expr, generator: Generator)
|
|||
value: Box::new(value.clone()),
|
||||
generators: vec![comp],
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
};
|
||||
generator.expr(&dict_comp.into())
|
||||
}
|
||||
|
|
|
@ -164,12 +164,12 @@ pub(crate) fn never_union(checker: &Checker, expr: &Expr) {
|
|||
elts: rest,
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
})),
|
||||
ctx: ast::ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
}))
|
||||
},
|
||||
expr.range(),
|
||||
|
|
|
@ -116,14 +116,14 @@ pub(crate) fn unnecessary_nested_literal<'a>(checker: &Checker, literal_expr: &'
|
|||
Expr::Tuple(ExprTuple {
|
||||
elts: nodes.into_iter().cloned().collect(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: false,
|
||||
})
|
||||
}),
|
||||
value: subscript.value.clone(),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
});
|
||||
let fix = Fix::applicable_edit(
|
||||
|
|
|
@ -303,7 +303,7 @@ impl<'a> ReFunc<'a> {
|
|||
op: UnaryOp::Not,
|
||||
operand: Box::new(expr),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Some(negated_expr)
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ impl<'a> ReFunc<'a> {
|
|||
ops: Box::new([op]),
|
||||
comparators: Box::new([right.clone()]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ impl<'a> ReFunc<'a> {
|
|||
attr: Identifier::new(method, TextRange::default()),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
});
|
||||
Expr::Call(ExprCall {
|
||||
func: Box::new(method),
|
||||
|
@ -347,10 +347,10 @@ impl<'a> ReFunc<'a> {
|
|||
args: args.into_boxed_slice(),
|
||||
keywords: Box::new([]),
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: TextRange::default(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::dummy(),
|
||||
node_index: ruff_python_ast::AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1489,7 +1489,7 @@ pub fn pep_604_optional(expr: &Expr) -> Expr {
|
|||
op: Operator::BitOr,
|
||||
right: Box::new(Expr::NoneLiteral(ast::ExprNoneLiteral::default())),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -1501,7 +1501,7 @@ pub fn pep_604_union(elts: &[Expr]) -> Expr {
|
|||
elts: vec![],
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
}),
|
||||
[Expr::Tuple(ast::ExprTuple { elts, .. })] => pep_604_union(elts),
|
||||
|
@ -1511,7 +1511,7 @@ pub fn pep_604_union(elts: &[Expr]) -> Expr {
|
|||
op: Operator::BitOr,
|
||||
right: Box::new(pep_604_union(std::slice::from_ref(elt))),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -1522,13 +1522,13 @@ pub fn typing_optional(elt: Expr, binding: Name) -> Expr {
|
|||
value: Box::new(Expr::Name(ast::ExprName {
|
||||
id: binding,
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
slice: Box::new(elt),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1541,19 +1541,19 @@ pub fn typing_union(elts: &[Expr], binding: Name) -> Expr {
|
|||
value: Box::new(Expr::Name(ast::ExprName {
|
||||
id: binding,
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
slice: Box::new(Expr::Tuple(ast::ExprTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
elts: elts.to_vec(),
|
||||
ctx: ExprContext::Load,
|
||||
parenthesized: false,
|
||||
})),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1686,34 +1686,34 @@ mod tests {
|
|||
let name = Expr::Name(ExprName {
|
||||
id: "x".into(),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
ctx: ExprContext::Load,
|
||||
});
|
||||
let constant_one = Expr::NumberLiteral(ExprNumberLiteral {
|
||||
value: Number::Int(Int::from(1u8)),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
let constant_two = Expr::NumberLiteral(ExprNumberLiteral {
|
||||
value: Number::Int(Int::from(2u8)),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
let constant_three = Expr::NumberLiteral(ExprNumberLiteral {
|
||||
value: Number::Int(Int::from(3u8)),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
let type_var_one = TypeParam::TypeVar(TypeParamTypeVar {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
bound: Some(Box::new(constant_one.clone())),
|
||||
default: None,
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
});
|
||||
let type_var_two = TypeParam::TypeVar(TypeParamTypeVar {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
bound: None,
|
||||
default: Some(Box::new(constant_two.clone())),
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
|
@ -1723,11 +1723,11 @@ mod tests {
|
|||
type_params: Some(Box::new(TypeParams {
|
||||
type_params: vec![type_var_one, type_var_two],
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
value: Box::new(constant_three.clone()),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
assert!(!any_over_stmt(&type_alias, &|expr| {
|
||||
seen.borrow_mut().push(expr.clone());
|
||||
|
@ -1743,7 +1743,7 @@ mod tests {
|
|||
fn any_over_type_param_type_var() {
|
||||
let type_var_no_bound = TypeParam::TypeVar(TypeParamTypeVar {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
bound: None,
|
||||
default: None,
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
|
@ -1753,12 +1753,12 @@ mod tests {
|
|||
let constant = Expr::NumberLiteral(ExprNumberLiteral {
|
||||
value: Number::Int(Int::ONE),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
let type_var_with_bound = TypeParam::TypeVar(TypeParamTypeVar {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
bound: Some(Box::new(constant.clone())),
|
||||
default: None,
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
|
@ -1776,7 +1776,7 @@ mod tests {
|
|||
|
||||
let type_var_with_default = TypeParam::TypeVar(TypeParamTypeVar {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
default: Some(Box::new(constant.clone())),
|
||||
bound: None,
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
|
@ -1797,7 +1797,7 @@ mod tests {
|
|||
fn any_over_type_param_type_var_tuple() {
|
||||
let type_var_tuple = TypeParam::TypeVarTuple(TypeParamTypeVarTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
default: None,
|
||||
});
|
||||
|
@ -1809,12 +1809,12 @@ mod tests {
|
|||
let constant = Expr::NumberLiteral(ExprNumberLiteral {
|
||||
value: Number::Int(Int::ONE),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
let type_var_tuple_with_default = TypeParam::TypeVarTuple(TypeParamTypeVarTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
default: Some(Box::new(constant.clone())),
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
});
|
||||
|
@ -1834,7 +1834,7 @@ mod tests {
|
|||
fn any_over_type_param_param_spec() {
|
||||
let type_param_spec = TypeParam::ParamSpec(TypeParamParamSpec {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
default: None,
|
||||
});
|
||||
|
@ -1846,12 +1846,12 @@ mod tests {
|
|||
let constant = Expr::NumberLiteral(ExprNumberLiteral {
|
||||
value: Number::Int(Int::ONE),
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
let param_spec_with_default = TypeParam::TypeVarTuple(TypeParamTypeVarTuple {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
default: Some(Box::new(constant.clone())),
|
||||
name: Identifier::new("x", TextRange::default()),
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::num::NonZeroU32;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
/// An AST node that has an index.
|
||||
|
@ -16,64 +17,82 @@ where
|
|||
}
|
||||
|
||||
/// A unique index for a node within an AST.
|
||||
///
|
||||
/// This type is interiorly mutable to allow assigning node indices
|
||||
/// on-demand after parsing.
|
||||
#[derive(Default)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct AtomicNodeIndex(AtomicU32);
|
||||
|
||||
impl AtomicNodeIndex {
|
||||
/// Returns a placeholder `AtomicNodeIndex`.
|
||||
pub const fn dummy() -> AtomicNodeIndex {
|
||||
AtomicNodeIndex(AtomicU32::new(u32::MAX))
|
||||
}
|
||||
|
||||
/// Load the current value of the `AtomicNodeIndex`.
|
||||
pub fn load(&self) -> NodeIndex {
|
||||
NodeIndex(self.0.load(Ordering::Relaxed))
|
||||
}
|
||||
|
||||
/// Set the value of the `AtomicNodeIndex`.
|
||||
pub fn set(&self, value: u32) {
|
||||
self.0.store(value, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
/// A unique index for a node within an AST.
|
||||
#[derive(PartialEq, Eq, Debug, PartialOrd, Ord, Clone, Copy, Hash)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct NodeIndex(u32);
|
||||
pub struct NodeIndex(NonZeroU32);
|
||||
|
||||
impl NodeIndex {
|
||||
pub fn as_usize(self) -> usize {
|
||||
self.0 as _
|
||||
}
|
||||
/// A placeholder `NodeIndex`.
|
||||
pub const NONE: NodeIndex = NodeIndex(NonZeroU32::new(NodeIndex::_NONE).unwrap());
|
||||
|
||||
pub fn as_u32(self) -> u32 {
|
||||
self.0
|
||||
// Note that the index `u32::MAX` is reserved for the `NonZeroU32` niche, and
|
||||
// this placeholder also reserves the second highest index.
|
||||
const _NONE: u32 = u32::MAX - 1;
|
||||
|
||||
/// Returns the index as a `u32`. or `None` for `NodeIndex::NONE`.
|
||||
pub fn as_u32(self) -> Option<u32> {
|
||||
if self == NodeIndex::NONE {
|
||||
None
|
||||
} else {
|
||||
Some(self.0.get() - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for NodeIndex {
|
||||
fn from(value: u32) -> Self {
|
||||
NodeIndex(value)
|
||||
match NonZeroU32::new(value + 1).map(NodeIndex) {
|
||||
None | Some(NodeIndex::NONE) => panic!("exceeded maximum `NodeIndex`"),
|
||||
Some(index) => index,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for AtomicNodeIndex {
|
||||
fn from(value: u32) -> Self {
|
||||
AtomicNodeIndex(AtomicU32::from(value))
|
||||
impl std::fmt::Debug for NodeIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if *self == Self::NONE {
|
||||
f.debug_tuple("NodeIndex(None)").finish()
|
||||
} else {
|
||||
f.debug_tuple("NodeIndex").field(&self.0).finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A unique index for a node within an AST.
|
||||
///
|
||||
/// This type is interiorly mutable to allow assigning node indices
|
||||
/// on-demand after parsing.
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct AtomicNodeIndex(AtomicU32);
|
||||
|
||||
#[allow(clippy::declare_interior_mutable_const)]
|
||||
impl AtomicNodeIndex {
|
||||
/// A placeholder `AtomicNodeIndex`.
|
||||
pub const NONE: AtomicNodeIndex = AtomicNodeIndex(AtomicU32::new(NodeIndex::_NONE));
|
||||
|
||||
/// Load the current value of the `AtomicNodeIndex`.
|
||||
pub fn load(&self) -> NodeIndex {
|
||||
let index = NonZeroU32::new(self.0.load(Ordering::Relaxed))
|
||||
.expect("value stored was a valid `NodeIndex`");
|
||||
|
||||
NodeIndex(index)
|
||||
}
|
||||
|
||||
/// Set the value of the `AtomicNodeIndex`.
|
||||
pub fn set(&self, index: NodeIndex) {
|
||||
self.0.store(index.0.get(), Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AtomicNodeIndex {
|
||||
fn default() -> Self {
|
||||
Self::NONE
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for AtomicNodeIndex {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if *self == AtomicNodeIndex::dummy() {
|
||||
f.debug_tuple("AtomicNodeIndex").finish_non_exhaustive()
|
||||
} else {
|
||||
f.debug_tuple("AtomicNodeIndex").field(&self.0).finish()
|
||||
}
|
||||
std::fmt::Debug::fmt(&self.load(), f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,3 +127,26 @@ impl Clone for AtomicNodeIndex {
|
|||
Self(AtomicU32::from(self.0.load(Ordering::Relaxed)))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{AtomicNodeIndex, NodeIndex};
|
||||
|
||||
#[test]
|
||||
fn test_node_index() {
|
||||
let index = AtomicNodeIndex::NONE;
|
||||
|
||||
assert_eq!(index.load(), NodeIndex::NONE);
|
||||
assert_eq!(format!("{index:?}"), "NodeIndex(None)");
|
||||
|
||||
index.set(NodeIndex::from(1));
|
||||
assert_eq!(index.load(), NodeIndex::from(1));
|
||||
assert_eq!(index.load().as_u32(), Some(1));
|
||||
|
||||
let index = NodeIndex::from(0);
|
||||
assert_eq!(index.as_u32(), Some(0));
|
||||
|
||||
let index = NodeIndex::NONE;
|
||||
assert_eq!(index.as_u32(), None);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1602,7 +1602,7 @@ impl StringLiteral {
|
|||
Self {
|
||||
range,
|
||||
value: "".into(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
flags: StringLiteralFlags::empty().with_invalid(),
|
||||
}
|
||||
}
|
||||
|
@ -1622,7 +1622,7 @@ impl From<StringLiteral> for Expr {
|
|||
fn from(payload: StringLiteral) -> Self {
|
||||
ExprStringLiteral {
|
||||
range: payload.range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
value: StringLiteralValue::single(payload),
|
||||
}
|
||||
.into()
|
||||
|
@ -2001,7 +2001,7 @@ impl BytesLiteral {
|
|||
Self {
|
||||
range,
|
||||
value: Box::new([]),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
flags: BytesLiteralFlags::empty().with_invalid(),
|
||||
}
|
||||
}
|
||||
|
@ -2011,7 +2011,7 @@ impl From<BytesLiteral> for Expr {
|
|||
fn from(payload: BytesLiteral) -> Self {
|
||||
ExprBytesLiteral {
|
||||
range: payload.range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
value: BytesLiteralValue::single(payload),
|
||||
}
|
||||
.into()
|
||||
|
@ -3545,7 +3545,7 @@ impl Identifier {
|
|||
pub fn new(id: impl Into<Name>, range: TextRange) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
range,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,12 +196,12 @@ mod tests {
|
|||
fn debug() {
|
||||
let continue_statement = StmtContinue {
|
||||
range: TextRange::new(TextSize::new(18), TextSize::new(26)),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
|
||||
let break_statement = StmtBreak {
|
||||
range: TextRange::new(TextSize::new(55), TextSize::new(60)),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
|
||||
let source = r"# leading comment
|
||||
|
|
|
@ -69,7 +69,7 @@ mod tests {
|
|||
fn equality() {
|
||||
let continue_statement = StmtContinue {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
|
||||
let ref_a = NodeRefEqualityKey::from_ref(AnyNodeRef::from(&continue_statement));
|
||||
|
@ -83,7 +83,7 @@ mod tests {
|
|||
fn inequality() {
|
||||
let continue_statement = StmtContinue {
|
||||
range: TextRange::default(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
|
||||
let boxed = Box::new(continue_statement.clone());
|
||||
|
|
|
@ -82,7 +82,7 @@ impl Transformer for Normalizer {
|
|||
value: Box::from(string.value.to_str()),
|
||||
range: string.range,
|
||||
flags: StringLiteralFlags::empty(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ impl Transformer for Normalizer {
|
|||
value: bytes.value.bytes().collect(),
|
||||
range: bytes.range,
|
||||
flags: BytesLiteralFlags::empty(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ impl Transformer for Normalizer {
|
|||
InterpolatedStringLiteralElement {
|
||||
range,
|
||||
value: literal.into(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ impl Transformer for Normalizer {
|
|||
elements: collector.elements.into(),
|
||||
range: fstring.range,
|
||||
flags: FStringFlags::empty(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ pub fn parse_parenthesized_expression_range(
|
|||
/// value: "'''\n int | str'''".to_string().into_boxed_str(),
|
||||
/// flags: StringLiteralFlags::empty(),
|
||||
/// range: TextRange::new(TextSize::new(0), TextSize::new(16)),
|
||||
/// node_index: AtomicNodeIndex::dummy()
|
||||
/// node_index: AtomicNodeIndex::NONE
|
||||
/// };
|
||||
/// let parsed = parse_string_annotation("'''\n int | str'''", &string);
|
||||
/// assert!(!parsed.is_ok());
|
||||
|
|
|
@ -304,7 +304,7 @@ impl<'src> Parser<'src> {
|
|||
op: bin_op,
|
||||
right: Box::new(right.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
};
|
||||
|
@ -472,7 +472,7 @@ impl<'src> Parser<'src> {
|
|||
range: identifier.range,
|
||||
id: identifier.id,
|
||||
ctx,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ impl<'src> Parser<'src> {
|
|||
return ast::Identifier {
|
||||
id: name,
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ impl<'src> Parser<'src> {
|
|||
return ast::Identifier {
|
||||
id,
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ impl<'src> Parser<'src> {
|
|||
ast::Identifier {
|
||||
id,
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
} else {
|
||||
self.add_error(
|
||||
|
@ -531,7 +531,7 @@ impl<'src> Parser<'src> {
|
|||
ast::Identifier {
|
||||
id: Name::empty(),
|
||||
range: self.missing_node_range(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: Number::Float(value),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Complex => {
|
||||
|
@ -561,7 +561,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: Number::Complex { real, imag },
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Int => {
|
||||
|
@ -571,7 +571,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: Number::Int(value),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::True => {
|
||||
|
@ -579,7 +579,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::BooleanLiteral(ast::ExprBooleanLiteral {
|
||||
value: true,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::False => {
|
||||
|
@ -587,21 +587,21 @@ impl<'src> Parser<'src> {
|
|||
Expr::BooleanLiteral(ast::ExprBooleanLiteral {
|
||||
value: false,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::None => {
|
||||
self.bump(TokenKind::None);
|
||||
Expr::NoneLiteral(ast::ExprNoneLiteral {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Ellipsis => {
|
||||
self.bump(TokenKind::Ellipsis);
|
||||
Expr::EllipsisLiteral(ast::ExprEllipsisLiteral {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Name => Expr::Name(self.parse_name()),
|
||||
|
@ -629,7 +629,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.missing_node_range(),
|
||||
id: Name::empty(),
|
||||
ctx: ExprContext::Invalid,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ impl<'src> Parser<'src> {
|
|||
func: Box::new(func),
|
||||
arguments,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ impl<'src> Parser<'src> {
|
|||
arg: None,
|
||||
value: value.expr,
|
||||
range: parser.node_range(argument_start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
seen_keyword_unpacking = true;
|
||||
|
@ -767,7 +767,7 @@ impl<'src> Parser<'src> {
|
|||
ast::Identifier {
|
||||
id: ident_expr.id,
|
||||
range: ident_expr.range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
} else {
|
||||
// TODO(dhruvmanila): Parser shouldn't drop the `parsed_expr` if it's
|
||||
|
@ -780,7 +780,7 @@ impl<'src> Parser<'src> {
|
|||
ast::Identifier {
|
||||
id: Name::empty(),
|
||||
range: parsed_expr.range(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -790,7 +790,7 @@ impl<'src> Parser<'src> {
|
|||
arg: Some(arg),
|
||||
value: value.expr,
|
||||
range: parser.node_range(argument_start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
} else {
|
||||
if !parsed_expr.is_unparenthesized_starred_expr() {
|
||||
|
@ -815,7 +815,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
let arguments = ast::Arguments {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
args: args.into_boxed_slice(),
|
||||
keywords: keywords.into_boxed_slice(),
|
||||
};
|
||||
|
@ -857,11 +857,11 @@ impl<'src> Parser<'src> {
|
|||
range: slice_range,
|
||||
id: Name::empty(),
|
||||
ctx: ExprContext::Invalid,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ impl<'src> Parser<'src> {
|
|||
ctx: ExprContext::Load,
|
||||
range: self.node_range(slice_start),
|
||||
parenthesized: false,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
} else if slice.is_starred_expr() {
|
||||
// If the only slice element is a starred expression, that is represented
|
||||
|
@ -892,7 +892,7 @@ impl<'src> Parser<'src> {
|
|||
ctx: ExprContext::Load,
|
||||
range: self.node_range(slice_start),
|
||||
parenthesized: false,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -941,7 +941,7 @@ impl<'src> Parser<'src> {
|
|||
slice: Box::new(slice),
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
Expr::Slice(ast::ExprSlice {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
lower,
|
||||
upper,
|
||||
step,
|
||||
|
@ -1066,7 +1066,7 @@ impl<'src> Parser<'src> {
|
|||
op,
|
||||
operand: Box::new(operand.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ impl<'src> Parser<'src> {
|
|||
attr,
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ impl<'src> Parser<'src> {
|
|||
values,
|
||||
op,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1215,7 +1215,7 @@ impl<'src> Parser<'src> {
|
|||
ops: operators.into_boxed_slice(),
|
||||
comparators: comparators.into_boxed_slice(),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1285,22 +1285,22 @@ impl<'src> Parser<'src> {
|
|||
StringType::Str(string) => Expr::StringLiteral(ast::ExprStringLiteral {
|
||||
value: ast::StringLiteralValue::single(string),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}),
|
||||
StringType::Bytes(bytes) => Expr::BytesLiteral(ast::ExprBytesLiteral {
|
||||
value: ast::BytesLiteralValue::single(bytes),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}),
|
||||
StringType::FString(fstring) => Expr::FString(ast::ExprFString {
|
||||
value: ast::FStringValue::single(fstring),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}),
|
||||
StringType::TString(tstring) => Expr::TString(ast::ExprTString {
|
||||
value: ast::TStringValue::single(tstring),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}),
|
||||
},
|
||||
_ => self.handle_implicitly_concatenated_strings(strings, range),
|
||||
|
@ -1367,7 +1367,7 @@ impl<'src> Parser<'src> {
|
|||
return Expr::from(ast::ExprBytesLiteral {
|
||||
value: ast::BytesLiteralValue::concatenated(values),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1395,7 +1395,7 @@ impl<'src> Parser<'src> {
|
|||
return Expr::from(ast::ExprTString {
|
||||
value: ast::TStringValue::concatenated(values),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1433,7 +1433,7 @@ impl<'src> Parser<'src> {
|
|||
return Expr::from(ast::ExprStringLiteral {
|
||||
value: ast::StringLiteralValue::concatenated(values),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1457,7 +1457,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::from(ast::ExprFString {
|
||||
value: ast::FStringValue::concatenated(parts),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1493,7 +1493,7 @@ impl<'src> Parser<'src> {
|
|||
value: Box::new([]),
|
||||
range,
|
||||
flags: ast::BytesLiteralFlags::from(flags).with_invalid(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
} else {
|
||||
// test_err invalid_string_literal
|
||||
|
@ -1503,7 +1503,7 @@ impl<'src> Parser<'src> {
|
|||
value: "".into(),
|
||||
range,
|
||||
flags: ast::StringLiteralFlags::from(flags).with_invalid(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1677,7 +1677,7 @@ impl<'src> Parser<'src> {
|
|||
ast::InterpolatedStringLiteralElement {
|
||||
value: "".into(),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
@ -1846,7 +1846,7 @@ impl<'src> Parser<'src> {
|
|||
Some(Box::new(ast::InterpolatedStringFormatSpec {
|
||||
range: self.node_range(spec_start),
|
||||
elements,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
|
@ -1898,7 +1898,7 @@ impl<'src> Parser<'src> {
|
|||
conversion,
|
||||
format_spec,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1928,7 +1928,7 @@ impl<'src> Parser<'src> {
|
|||
elts: vec![],
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1980,7 +1980,7 @@ impl<'src> Parser<'src> {
|
|||
return Expr::Dict(ast::ExprDict {
|
||||
items: vec![],
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2091,7 +2091,7 @@ impl<'src> Parser<'src> {
|
|||
elts: vec![],
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
parenthesized: true,
|
||||
})
|
||||
.into();
|
||||
|
@ -2180,7 +2180,7 @@ impl<'src> Parser<'src> {
|
|||
elts,
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
parenthesized: parenthesized.is_yes(),
|
||||
}
|
||||
}
|
||||
|
@ -2209,7 +2209,7 @@ impl<'src> Parser<'src> {
|
|||
elts,
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2258,7 +2258,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
ast::ExprSet {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
elts,
|
||||
}
|
||||
}
|
||||
|
@ -2301,7 +2301,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
ast::ExprDict {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
items,
|
||||
}
|
||||
}
|
||||
|
@ -2369,7 +2369,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
ast::Comprehension {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
target: target.expr,
|
||||
iter: iter.expr,
|
||||
ifs,
|
||||
|
@ -2399,7 +2399,7 @@ impl<'src> Parser<'src> {
|
|||
elt: Box::new(element),
|
||||
generators,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
parenthesized: parenthesized.is_yes(),
|
||||
}
|
||||
}
|
||||
|
@ -2420,7 +2420,7 @@ impl<'src> Parser<'src> {
|
|||
elt: Box::new(element),
|
||||
generators,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2442,7 +2442,7 @@ impl<'src> Parser<'src> {
|
|||
value: Box::new(value),
|
||||
generators,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2462,7 +2462,7 @@ impl<'src> Parser<'src> {
|
|||
elt: Box::new(element),
|
||||
generators,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2499,7 +2499,7 @@ impl<'src> Parser<'src> {
|
|||
value: Box::new(parsed_expr.expr),
|
||||
ctx: ExprContext::Load,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2522,7 +2522,7 @@ impl<'src> Parser<'src> {
|
|||
ast::ExprAwait {
|
||||
value: Box::new(parsed_expr.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2571,7 +2571,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::Yield(ast::ExprYield {
|
||||
value,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2611,7 +2611,7 @@ impl<'src> Parser<'src> {
|
|||
Expr::YieldFrom(ast::ExprYieldFrom {
|
||||
value: Box::new(expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2652,7 +2652,7 @@ impl<'src> Parser<'src> {
|
|||
target: Box::new(target),
|
||||
value: Box::new(value.expr),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2700,7 +2700,7 @@ impl<'src> Parser<'src> {
|
|||
body: Box::new(body.expr),
|
||||
parameters,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2725,7 +2725,7 @@ impl<'src> Parser<'src> {
|
|||
test: Box::new(test.expr),
|
||||
orelse: Box::new(orelse.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2751,7 +2751,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
let command = ast::ExprIpyEscapeCommand {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
kind,
|
||||
value,
|
||||
};
|
||||
|
@ -3010,7 +3010,7 @@ impl From<InterpolatedStringData> for FString {
|
|||
elements: value.elements,
|
||||
range: value.range,
|
||||
flags: value.flags.into(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3021,7 +3021,7 @@ impl From<InterpolatedStringData> for TString {
|
|||
elements: value.elements,
|
||||
range: value.range,
|
||||
flags: value.flags.into(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ impl<'src> Parser<'src> {
|
|||
ModExpression {
|
||||
body: Box::new(parsed_expr.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ impl<'src> Parser<'src> {
|
|||
ModModule {
|
||||
body,
|
||||
range: TextRange::new(self.start_offset, self.current_token_range().end()),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ impl Parser<'_> {
|
|||
lhs = Pattern::MatchOr(ast::PatternMatchOr {
|
||||
range: self.node_range(start),
|
||||
patterns,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl Parser<'_> {
|
|||
range: self.node_range(start),
|
||||
name: Some(ident),
|
||||
pattern: Some(Box::new(lhs)),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ impl Parser<'_> {
|
|||
keys,
|
||||
patterns,
|
||||
rest,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ impl Parser<'_> {
|
|||
} else {
|
||||
Some(ident)
|
||||
},
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ impl Parser<'_> {
|
|||
return Pattern::MatchSequence(ast::PatternMatchSequence {
|
||||
patterns: vec![],
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ impl Parser<'_> {
|
|||
ast::PatternMatchSequence {
|
||||
range: self.node_range(start),
|
||||
patterns,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ impl Parser<'_> {
|
|||
Pattern::MatchSingleton(ast::PatternMatchSingleton {
|
||||
value: Singleton::None,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::True => {
|
||||
|
@ -397,7 +397,7 @@ impl Parser<'_> {
|
|||
Pattern::MatchSingleton(ast::PatternMatchSingleton {
|
||||
value: Singleton::True,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::False => {
|
||||
|
@ -405,7 +405,7 @@ impl Parser<'_> {
|
|||
Pattern::MatchSingleton(ast::PatternMatchSingleton {
|
||||
value: Singleton::False,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::String | TokenKind::FStringStart | TokenKind::TStringStart => {
|
||||
|
@ -414,7 +414,7 @@ impl Parser<'_> {
|
|||
Pattern::MatchValue(ast::PatternMatchValue {
|
||||
value: Box::new(str),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Complex => {
|
||||
|
@ -427,10 +427,10 @@ impl Parser<'_> {
|
|||
value: Box::new(Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: Number::Complex { real, imag },
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Int => {
|
||||
|
@ -443,10 +443,10 @@ impl Parser<'_> {
|
|||
value: Box::new(Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: Number::Int(value),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Float => {
|
||||
|
@ -459,10 +459,10 @@ impl Parser<'_> {
|
|||
value: Box::new(Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: Number::Float(value),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
kind => {
|
||||
|
@ -489,7 +489,7 @@ impl Parser<'_> {
|
|||
return Pattern::MatchValue(ast::PatternMatchValue {
|
||||
value: Box::new(Expr::UnaryOp(unary_expr)),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ impl Parser<'_> {
|
|||
Pattern::MatchValue(ast::PatternMatchValue {
|
||||
value: Box::new(attribute),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
} else {
|
||||
// test_ok match_as_pattern_soft_keyword
|
||||
|
@ -530,7 +530,7 @@ impl Parser<'_> {
|
|||
range: ident.range,
|
||||
pattern: None,
|
||||
name: if &ident == "_" { None } else { Some(ident) },
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
|
@ -544,12 +544,12 @@ impl Parser<'_> {
|
|||
range: self.missing_node_range(),
|
||||
id: Name::empty(),
|
||||
ctx: ExprContext::Invalid,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
Pattern::MatchValue(ast::PatternMatchValue {
|
||||
range: invalid_node.range(),
|
||||
value: Box::new(invalid_node),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -605,10 +605,10 @@ impl Parser<'_> {
|
|||
op: operator,
|
||||
right: rhs_value,
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,14 +648,14 @@ impl Parser<'_> {
|
|||
range: ident.range(),
|
||||
id: ident.id,
|
||||
ctx: ExprContext::Load,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}))
|
||||
} else {
|
||||
Box::new(Expr::Name(ast::ExprName {
|
||||
range: ident.range(),
|
||||
id: Name::empty(),
|
||||
ctx: ExprContext::Invalid,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ impl Parser<'_> {
|
|||
ast::Identifier {
|
||||
id: Name::empty(),
|
||||
range: parser.missing_node_range(),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -717,7 +717,7 @@ impl Parser<'_> {
|
|||
attr: key,
|
||||
pattern: value_pattern,
|
||||
range: parser.node_range(pattern_start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
} else {
|
||||
has_seen_pattern = true;
|
||||
|
@ -743,10 +743,10 @@ impl Parser<'_> {
|
|||
patterns,
|
||||
keywords,
|
||||
range: self.node_range(arguments_start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
},
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ expression: parsed.expr()
|
|||
---
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..5,
|
||||
id: Name("first"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -4,20 +4,20 @@ expression: parsed.syntax()
|
|||
---
|
||||
Module(
|
||||
ModModule {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..929,
|
||||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 21..42,
|
||||
value: BinOp(
|
||||
ExprBinOp {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 27..40,
|
||||
left: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 27..28,
|
||||
id: Name("a"),
|
||||
ctx: Load,
|
||||
|
@ -26,7 +26,7 @@ Module(
|
|||
op: Mod,
|
||||
right: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 39..40,
|
||||
id: Name("b"),
|
||||
ctx: Load,
|
||||
|
@ -38,7 +38,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 66..73,
|
||||
kind: Help2,
|
||||
value: "a.foo",
|
||||
|
@ -46,7 +46,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 74..80,
|
||||
kind: Help,
|
||||
value: "a.foo",
|
||||
|
@ -54,7 +54,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 81..88,
|
||||
kind: Help,
|
||||
value: "a.foo",
|
||||
|
@ -62,7 +62,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 89..100,
|
||||
kind: Help2,
|
||||
value: "a.foo()",
|
||||
|
@ -70,7 +70,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 115..128,
|
||||
kind: Magic,
|
||||
value: "timeit a = b",
|
||||
|
@ -78,7 +78,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 129..147,
|
||||
kind: Magic,
|
||||
value: "timeit foo(b) % 3",
|
||||
|
@ -86,7 +86,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 148..176,
|
||||
kind: Magic,
|
||||
value: "alias showPath pwd && ls -a",
|
||||
|
@ -94,7 +94,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 177..205,
|
||||
kind: Magic,
|
||||
value: "timeit a = foo(b); b = 2",
|
||||
|
@ -102,7 +102,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 206..226,
|
||||
kind: Magic,
|
||||
value: "matplotlib --inline",
|
||||
|
@ -110,7 +110,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 227..253,
|
||||
kind: Magic,
|
||||
value: "matplotlib --inline",
|
||||
|
@ -118,7 +118,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 277..309,
|
||||
kind: Shell,
|
||||
value: "pwd && ls -a | sed 's/^/\\ /'",
|
||||
|
@ -126,7 +126,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 310..347,
|
||||
kind: Shell,
|
||||
value: "pwd && ls -a | sed 's/^/\\\\ /'",
|
||||
|
@ -134,7 +134,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 348..393,
|
||||
kind: ShCap,
|
||||
value: "cd /Users/foo/Library/Application\\ Support/",
|
||||
|
@ -142,21 +142,19 @@ Module(
|
|||
),
|
||||
FunctionDef(
|
||||
StmtFunctionDef {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 566..626,
|
||||
is_async: false,
|
||||
decorator_list: [],
|
||||
name: Identifier {
|
||||
id: Name("foo"),
|
||||
range: 570..573,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
},
|
||||
type_params: None,
|
||||
parameters: Parameters {
|
||||
range: 573..575,
|
||||
node_index: AtomicNodeIndex(
|
||||
0,
|
||||
),
|
||||
node_index: NodeIndex(None),
|
||||
posonlyargs: [],
|
||||
args: [],
|
||||
vararg: None,
|
||||
|
@ -167,16 +165,16 @@ Module(
|
|||
body: [
|
||||
Return(
|
||||
StmtReturn {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 581..626,
|
||||
value: Some(
|
||||
Compare(
|
||||
ExprCompare {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 598..620,
|
||||
left: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 598..599,
|
||||
id: Name("a"),
|
||||
ctx: Load,
|
||||
|
@ -188,7 +186,7 @@ Module(
|
|||
comparators: [
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 619..620,
|
||||
id: Name("b"),
|
||||
ctx: Load,
|
||||
|
@ -205,7 +203,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 656..664,
|
||||
kind: Paren,
|
||||
value: "foo 1 2",
|
||||
|
@ -213,7 +211,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 665..673,
|
||||
kind: Quote2,
|
||||
value: "foo 1 2",
|
||||
|
@ -221,7 +219,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 674..682,
|
||||
kind: Quote,
|
||||
value: "foo 1 2",
|
||||
|
@ -229,12 +227,12 @@ Module(
|
|||
),
|
||||
For(
|
||||
StmtFor {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 711..737,
|
||||
is_async: false,
|
||||
target: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 715..716,
|
||||
id: Name("a"),
|
||||
ctx: Store,
|
||||
|
@ -242,11 +240,11 @@ Module(
|
|||
),
|
||||
iter: Call(
|
||||
ExprCall {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 720..728,
|
||||
func: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 720..725,
|
||||
id: Name("range"),
|
||||
ctx: Load,
|
||||
|
@ -254,11 +252,11 @@ Module(
|
|||
),
|
||||
arguments: Arguments {
|
||||
range: 725..728,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
args: [
|
||||
NumberLiteral(
|
||||
ExprNumberLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 726..727,
|
||||
value: Int(
|
||||
5,
|
||||
|
@ -273,7 +271,7 @@ Module(
|
|||
body: [
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 734..737,
|
||||
kind: Shell,
|
||||
value: "ls",
|
||||
|
@ -285,12 +283,12 @@ Module(
|
|||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 739..748,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 739..741,
|
||||
id: Name("p1"),
|
||||
ctx: Store,
|
||||
|
@ -299,7 +297,7 @@ Module(
|
|||
],
|
||||
value: IpyEscapeCommand(
|
||||
ExprIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 744..748,
|
||||
kind: Shell,
|
||||
value: "pwd",
|
||||
|
@ -309,11 +307,11 @@ Module(
|
|||
),
|
||||
AnnAssign(
|
||||
StmtAnnAssign {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 749..763,
|
||||
target: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 749..751,
|
||||
id: Name("p2"),
|
||||
ctx: Store,
|
||||
|
@ -321,7 +319,7 @@ Module(
|
|||
),
|
||||
annotation: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 753..756,
|
||||
id: Name("str"),
|
||||
ctx: Load,
|
||||
|
@ -330,7 +328,7 @@ Module(
|
|||
value: Some(
|
||||
IpyEscapeCommand(
|
||||
ExprIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 759..763,
|
||||
kind: Shell,
|
||||
value: "pwd",
|
||||
|
@ -342,12 +340,12 @@ Module(
|
|||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 764..784,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 764..767,
|
||||
id: Name("foo"),
|
||||
ctx: Store,
|
||||
|
@ -356,7 +354,7 @@ Module(
|
|||
],
|
||||
value: IpyEscapeCommand(
|
||||
ExprIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 770..784,
|
||||
kind: Magic,
|
||||
value: "foo bar",
|
||||
|
@ -366,7 +364,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 786..791,
|
||||
kind: Magic,
|
||||
value: " foo",
|
||||
|
@ -374,12 +372,12 @@ Module(
|
|||
),
|
||||
Assign(
|
||||
StmtAssign {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 792..813,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 792..795,
|
||||
id: Name("foo"),
|
||||
ctx: Store,
|
||||
|
@ -388,7 +386,7 @@ Module(
|
|||
],
|
||||
value: IpyEscapeCommand(
|
||||
ExprIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 798..813,
|
||||
kind: Magic,
|
||||
value: "foo # comment",
|
||||
|
@ -398,7 +396,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 838..842,
|
||||
kind: Help,
|
||||
value: "foo",
|
||||
|
@ -406,7 +404,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 843..852,
|
||||
kind: Help2,
|
||||
value: "foo.bar",
|
||||
|
@ -414,7 +412,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 853..865,
|
||||
kind: Help,
|
||||
value: "foo.bar.baz",
|
||||
|
@ -422,7 +420,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 866..874,
|
||||
kind: Help2,
|
||||
value: "foo[0]",
|
||||
|
@ -430,7 +428,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 875..885,
|
||||
kind: Help,
|
||||
value: "foo[0][1]",
|
||||
|
@ -438,7 +436,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 886..905,
|
||||
kind: Help2,
|
||||
value: "foo.bar[0].baz[1]",
|
||||
|
@ -446,7 +444,7 @@ Module(
|
|||
),
|
||||
IpyEscapeCommand(
|
||||
StmtIpyEscapeCommand {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 906..929,
|
||||
kind: Help2,
|
||||
value: "foo.bar[0].baz[2].egg",
|
||||
|
|
|
@ -5,12 +5,12 @@ expression: suite
|
|||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..37,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..1,
|
||||
id: Name("x"),
|
||||
ctx: Store,
|
||||
|
@ -19,13 +19,13 @@ expression: suite
|
|||
],
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 4..37,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 4..37,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{8}another cool trick",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -312,7 +312,7 @@ impl<'src> Parser<'src> {
|
|||
Stmt::Expr(ast::StmtExpr {
|
||||
range: self.node_range(start),
|
||||
value: Box::new(parsed_expr.expr),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ impl<'src> Parser<'src> {
|
|||
ast::StmtDelete {
|
||||
targets,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ impl<'src> Parser<'src> {
|
|||
ast::StmtReturn {
|
||||
range: self.node_range(start),
|
||||
value,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
exc,
|
||||
cause,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -564,7 +564,7 @@ impl<'src> Parser<'src> {
|
|||
ast::StmtImport {
|
||||
range: self.node_range(start),
|
||||
names,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -676,7 +676,7 @@ impl<'src> Parser<'src> {
|
|||
names,
|
||||
level: leading_dots,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -693,11 +693,11 @@ impl<'src> Parser<'src> {
|
|||
name: ast::Identifier {
|
||||
id: Name::new_static("*"),
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
},
|
||||
asname: None,
|
||||
range,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
name,
|
||||
asname,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,7 +759,7 @@ impl<'src> Parser<'src> {
|
|||
ast::Identifier {
|
||||
id: Name::from(dotted_name),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,7 +775,7 @@ impl<'src> Parser<'src> {
|
|||
self.bump(TokenKind::Pass);
|
||||
ast::StmtPass {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -791,7 +791,7 @@ impl<'src> Parser<'src> {
|
|||
self.bump(TokenKind::Continue);
|
||||
ast::StmtContinue {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ impl<'src> Parser<'src> {
|
|||
self.bump(TokenKind::Break);
|
||||
ast::StmtBreak {
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -857,7 +857,7 @@ impl<'src> Parser<'src> {
|
|||
test: Box::new(test.expr),
|
||||
msg,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ impl<'src> Parser<'src> {
|
|||
ast::StmtGlobal {
|
||||
range: self.node_range(start),
|
||||
names,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -942,7 +942,7 @@ impl<'src> Parser<'src> {
|
|||
ast::StmtNonlocal {
|
||||
range: self.node_range(start),
|
||||
names,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,7 @@ impl<'src> Parser<'src> {
|
|||
type_params: type_params.map(Box::new),
|
||||
value: Box::new(value.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ impl<'src> Parser<'src> {
|
|||
range,
|
||||
kind,
|
||||
value,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ impl<'src> Parser<'src> {
|
|||
value: value.into_boxed_str(),
|
||||
kind,
|
||||
range: self.node_range(parsed_expr.start()),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ impl<'src> Parser<'src> {
|
|||
targets,
|
||||
value: Box::new(value.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1267,7 @@ impl<'src> Parser<'src> {
|
|||
value,
|
||||
simple,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1322,7 +1322,7 @@ impl<'src> Parser<'src> {
|
|||
op,
|
||||
value: Box::new(value.expr),
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1378,7 +1378,7 @@ impl<'src> Parser<'src> {
|
|||
body,
|
||||
elif_else_clauses,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1422,7 +1422,7 @@ impl<'src> Parser<'src> {
|
|||
test,
|
||||
body,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1572,7 +1572,7 @@ impl<'src> Parser<'src> {
|
|||
finalbody,
|
||||
is_star,
|
||||
range: self.node_range(try_start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1722,7 +1722,7 @@ impl<'src> Parser<'src> {
|
|||
name,
|
||||
body: except_body,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}),
|
||||
block_kind,
|
||||
)
|
||||
|
@ -1834,7 +1834,7 @@ impl<'src> Parser<'src> {
|
|||
body,
|
||||
orelse,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1882,7 +1882,7 @@ impl<'src> Parser<'src> {
|
|||
body,
|
||||
orelse,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2012,7 +2012,7 @@ impl<'src> Parser<'src> {
|
|||
is_async: false,
|
||||
returns,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2082,7 +2082,7 @@ impl<'src> Parser<'src> {
|
|||
type_params: type_params.map(Box::new),
|
||||
arguments,
|
||||
body,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2109,7 +2109,7 @@ impl<'src> Parser<'src> {
|
|||
body,
|
||||
is_async: false,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2378,7 +2378,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
context_expr: context_expr.expr,
|
||||
optional_vars,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2447,7 +2447,7 @@ impl<'src> Parser<'src> {
|
|||
subject: Box::new(subject),
|
||||
cases,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
TokenKind::Newline if matches!(self.peek2(), (TokenKind::Indent, TokenKind::Case)) => {
|
||||
|
@ -2470,7 +2470,7 @@ impl<'src> Parser<'src> {
|
|||
subject: Box::new(subject),
|
||||
cases,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
|
@ -2518,7 +2518,7 @@ impl<'src> Parser<'src> {
|
|||
subject: Box::new(subject),
|
||||
cases,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2697,7 +2697,7 @@ impl<'src> Parser<'src> {
|
|||
guard,
|
||||
body,
|
||||
range: self.node_range(start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2866,7 +2866,7 @@ impl<'src> Parser<'src> {
|
|||
decorators.push(ast::Decorator {
|
||||
expression: parsed_expr.expr,
|
||||
range: self.node_range(decorator_start),
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
});
|
||||
|
||||
// test_err decorator_missing_newline
|
||||
|
@ -3080,7 +3080,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
name,
|
||||
annotation,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3130,7 +3130,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
parameter,
|
||||
default,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3448,7 +3448,7 @@ impl<'src> Parser<'src> {
|
|||
ast::TypeParams {
|
||||
range: self.node_range(start),
|
||||
type_params,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3511,7 +3511,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
name,
|
||||
default,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
|
||||
// test_ok type_param_param_spec
|
||||
|
@ -3551,7 +3551,7 @@ impl<'src> Parser<'src> {
|
|||
range: self.node_range(start),
|
||||
name,
|
||||
default,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
// test_ok type_param_type_var
|
||||
// type X[T] = int
|
||||
|
@ -3635,7 +3635,7 @@ impl<'src> Parser<'src> {
|
|||
name,
|
||||
bound,
|
||||
default,
|
||||
node_index: AtomicNodeIndex::dummy(),
|
||||
node_index: AtomicNodeIndex::NONE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..15,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..15,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..15,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{8}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..9,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..9,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..9,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{7}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..21,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..21,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..21,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\r",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..45,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..45,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..45,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{89}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..12,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..12,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..12,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{7f}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,12 +5,12 @@ expression: suite
|
|||
[
|
||||
Assign(
|
||||
StmtAssign {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..16,
|
||||
targets: [
|
||||
Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..4,
|
||||
id: Name("bold"),
|
||||
ctx: Store,
|
||||
|
@ -19,13 +19,13 @@ expression: suite
|
|||
],
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 7..16,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 7..16,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{3}8[1m",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..738,
|
||||
value: BytesLiteral(
|
||||
ExprBytesLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..738,
|
||||
value: BytesLiteralValue {
|
||||
inner: Single(
|
||||
BytesLiteral {
|
||||
range: 0..738,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: [
|
||||
0,
|
||||
1,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..12,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..12,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..12,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{1b}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..13,
|
||||
value: BytesLiteral(
|
||||
ExprBytesLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..13,
|
||||
value: BytesLiteralValue {
|
||||
inner: Single(
|
||||
BytesLiteral {
|
||||
range: 0..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: [
|
||||
111,
|
||||
109,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..14,
|
||||
value: BytesLiteral(
|
||||
ExprBytesLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..14,
|
||||
value: BytesLiteralValue {
|
||||
inner: Single(
|
||||
BytesLiteral {
|
||||
range: 0..14,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: [
|
||||
35,
|
||||
97,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..15,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..15,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..15,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{c}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,33 +5,33 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..22,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..22,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..22,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 2..5,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "aaa",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 5..10,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 6..9,
|
||||
id: Name("bbb"),
|
||||
ctx: Load,
|
||||
|
@ -45,17 +45,17 @@ expression: suite
|
|||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 10..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "ccc",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 13..18,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 14..17,
|
||||
id: Name("ddd"),
|
||||
ctx: Load,
|
||||
|
@ -69,7 +69,7 @@ expression: suite
|
|||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 18..21,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "eee",
|
||||
},
|
||||
),
|
||||
|
|
|
@ -5,33 +5,33 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..8,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..8,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 2..4,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\\",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 4..7,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 5..6,
|
||||
id: Name("x"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -5,33 +5,33 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..8,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..8,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 2..4,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\n",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 4..7,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 5..6,
|
||||
id: Name("x"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -5,33 +5,33 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..9,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..9,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..9,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 3..5,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\\\n",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 5..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 6..7,
|
||||
id: Name("x"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -5,26 +5,26 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..10,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..10,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..10,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 2..9,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..7,
|
||||
id: Name("user"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -5,33 +5,33 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..38,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..38,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..38,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 2..6,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "mix ",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 6..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 7..11,
|
||||
id: Name("user"),
|
||||
ctx: Load,
|
||||
|
@ -50,17 +50,17 @@ expression: suite
|
|||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 13..28,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: " with text and ",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 28..37,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 29..35,
|
||||
id: Name("second"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -5,26 +5,26 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..14,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..14,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..14,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 2..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..7,
|
||||
id: Name("user"),
|
||||
ctx: Load,
|
||||
|
@ -40,12 +40,12 @@ expression: suite
|
|||
format_spec: Some(
|
||||
InterpolatedStringFormatSpec {
|
||||
range: 9..12,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 9..12,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: ">10",
|
||||
},
|
||||
),
|
||||
|
|
|
@ -5,33 +5,33 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..11,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..11,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..11,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 4..5,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\n",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 5..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 6..7,
|
||||
id: Name("x"),
|
||||
ctx: Load,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..9,
|
||||
value: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..9,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 0..9,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "\u{88}",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,18 +5,18 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..3,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..3,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..3,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [],
|
||||
flags: FStringFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,17 +5,17 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..3,
|
||||
value: TString(
|
||||
ExprTString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..3,
|
||||
value: TStringValue {
|
||||
inner: Single(
|
||||
TString {
|
||||
range: 0..3,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [],
|
||||
flags: TStringFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,11 +5,11 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..17,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..17,
|
||||
value: FStringValue {
|
||||
inner: Concatenated(
|
||||
|
@ -17,7 +17,7 @@ expression: suite
|
|||
Literal(
|
||||
StringLiteral {
|
||||
range: 0..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "Hello ",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
@ -29,12 +29,12 @@ expression: suite
|
|||
FString(
|
||||
FString {
|
||||
range: 9..17,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 11..16,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "world",
|
||||
},
|
||||
),
|
||||
|
|
|
@ -5,11 +5,11 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..17,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..17,
|
||||
value: FStringValue {
|
||||
inner: Concatenated(
|
||||
|
@ -17,7 +17,7 @@ expression: suite
|
|||
Literal(
|
||||
StringLiteral {
|
||||
range: 0..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "Hello ",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
@ -29,12 +29,12 @@ expression: suite
|
|||
FString(
|
||||
FString {
|
||||
range: 9..17,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 11..16,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "world",
|
||||
},
|
||||
),
|
||||
|
|
|
@ -5,11 +5,11 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..22,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..22,
|
||||
value: FStringValue {
|
||||
inner: Concatenated(
|
||||
|
@ -17,7 +17,7 @@ expression: suite
|
|||
Literal(
|
||||
StringLiteral {
|
||||
range: 0..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "Hello ",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
@ -29,28 +29,28 @@ expression: suite
|
|||
FString(
|
||||
FString {
|
||||
range: 9..22,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 11..16,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "world",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 16..21,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 17..20,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 17..20,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "!",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
|
|
@ -5,11 +5,11 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..31,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..31,
|
||||
value: FStringValue {
|
||||
inner: Concatenated(
|
||||
|
@ -17,7 +17,7 @@ expression: suite
|
|||
Literal(
|
||||
StringLiteral {
|
||||
range: 0..8,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "Hello ",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
@ -29,28 +29,28 @@ expression: suite
|
|||
FString(
|
||||
FString {
|
||||
range: 9..22,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 11..16,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "world",
|
||||
},
|
||||
),
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 16..21,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 17..20,
|
||||
value: StringLiteralValue {
|
||||
inner: Single(
|
||||
StringLiteral {
|
||||
range: 17..20,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "!",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Double,
|
||||
|
@ -78,7 +78,7 @@ expression: suite
|
|||
Literal(
|
||||
StringLiteral {
|
||||
range: 23..31,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "again!",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
|
|
@ -5,26 +5,26 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..18,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..18,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..18,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 2..5,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..4,
|
||||
id: Name("a"),
|
||||
ctx: Load,
|
||||
|
@ -38,10 +38,10 @@ expression: suite
|
|||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 5..10,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 7..8,
|
||||
id: Name("b"),
|
||||
ctx: Load,
|
||||
|
@ -55,7 +55,7 @@ expression: suite
|
|||
Literal(
|
||||
InterpolatedStringLiteralElement {
|
||||
range: 10..17,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "{foo}",
|
||||
},
|
||||
),
|
||||
|
|
|
@ -5,30 +5,30 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..13,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..13,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 2..12,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Compare(
|
||||
ExprCompare {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..11,
|
||||
left: NumberLiteral(
|
||||
ExprNumberLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..5,
|
||||
value: Int(
|
||||
42,
|
||||
|
@ -41,7 +41,7 @@ expression: suite
|
|||
comparators: [
|
||||
NumberLiteral(
|
||||
ExprNumberLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 9..11,
|
||||
value: Int(
|
||||
42,
|
||||
|
|
|
@ -5,26 +5,26 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..16,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..16,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..16,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 2..15,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..6,
|
||||
id: Name("foo"),
|
||||
ctx: Load,
|
||||
|
@ -35,15 +35,15 @@ expression: suite
|
|||
format_spec: Some(
|
||||
InterpolatedStringFormatSpec {
|
||||
range: 7..14,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 7..14,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: StringLiteral(
|
||||
ExprStringLiteral {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 8..13,
|
||||
value: StringLiteralValue {
|
||||
inner: Concatenated(
|
||||
|
@ -51,7 +51,7 @@ expression: suite
|
|||
strings: [
|
||||
StringLiteral {
|
||||
range: 8..10,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
@ -61,7 +61,7 @@ expression: suite
|
|||
},
|
||||
StringLiteral {
|
||||
range: 11..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
value: "",
|
||||
flags: StringLiteralFlags {
|
||||
quote_style: Single,
|
||||
|
|
|
@ -5,26 +5,26 @@ expression: suite
|
|||
[
|
||||
Expr(
|
||||
StmtExpr {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..15,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 0..15,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..15,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 2..14,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 3..6,
|
||||
id: Name("foo"),
|
||||
ctx: Load,
|
||||
|
@ -35,15 +35,15 @@ expression: suite
|
|||
format_spec: Some(
|
||||
InterpolatedStringFormatSpec {
|
||||
range: 7..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
elements: [
|
||||
Interpolation(
|
||||
InterpolatedElement {
|
||||
range: 7..13,
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
expression: Name(
|
||||
ExprName {
|
||||
node_index: AtomicNodeIndex(..),
|
||||
node_index: NodeIndex(None),
|
||||
range: 8..12,
|
||||
id: Name("spec"),
|
||||
ctx: Load,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue