mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 15:47:41 +00:00
Upgrade RustPython (#5334)
This commit is contained in:
parent
f45d1c2b84
commit
6ba9d5d5a4
5 changed files with 265 additions and 271 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -2102,7 +2102,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruff_text_size"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
|
||||
dependencies = [
|
||||
"schemars",
|
||||
"serde",
|
||||
|
@ -2180,7 +2180,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rustpython-ast"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
|
||||
dependencies = [
|
||||
"is-macro",
|
||||
"num-bigint",
|
||||
|
@ -2191,7 +2191,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rustpython-format"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
|
||||
dependencies = [
|
||||
"bitflags 2.3.1",
|
||||
"itertools",
|
||||
|
@ -2203,7 +2203,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rustpython-literal"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
|
||||
dependencies = [
|
||||
"hexf-parse",
|
||||
"is-macro",
|
||||
|
@ -2215,7 +2215,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rustpython-parser"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"is-macro",
|
||||
|
@ -2238,7 +2238,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rustpython-parser-core"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11"
|
||||
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
|
||||
dependencies = [
|
||||
"is-macro",
|
||||
"memchr",
|
||||
|
|
19
Cargo.toml
19
Cargo.toml
|
@ -49,16 +49,15 @@ toml = { version = "0.7.2" }
|
|||
|
||||
# v0.0.1
|
||||
libcst = { git = "https://github.com/charliermarsh/LibCST", rev = "80e4c1399f95e5beb532fdd1e209ad2dbb470438" }
|
||||
# v0.0.3
|
||||
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" }
|
||||
# v0.0.3
|
||||
rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" , default-features = false, features = ["all-nodes-with-ranges", "num-bigint"]}
|
||||
# v0.0.3
|
||||
rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11", default-features = false, features = ["num-bigint"] }
|
||||
# v0.0.3
|
||||
rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11", default-features = false }
|
||||
# v0.0.3
|
||||
rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" , default-features = false, features = ["full-lexer", "all-nodes-with-ranges", "num-bigint"] }
|
||||
|
||||
# Please tag the RustPython version everytime you update its revision here.
|
||||
# Tagging the version ensures that older ruff versions continue to build from source even when we rebase our RustPython fork.
|
||||
# Current tag: v0.0.6
|
||||
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c" }
|
||||
rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c" , default-features = false, features = ["num-bigint"]}
|
||||
rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c", default-features = false, features = ["num-bigint"] }
|
||||
rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c", default-features = false }
|
||||
rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c" , default-features = false, features = ["full-lexer", "num-bigint"] }
|
||||
|
||||
[profile.release]
|
||||
lto = "fat"
|
||||
|
|
|
@ -68,7 +68,7 @@ pub(crate) fn compare_to_empty_string(
|
|||
let mut first = true;
|
||||
for ((lhs, rhs), op) in std::iter::once(left)
|
||||
.chain(comparators.iter())
|
||||
.tuple_windows::<(&Expr<_>, &Expr<_>)>()
|
||||
.tuple_windows::<(&Expr, &Expr)>()
|
||||
.zip(ops)
|
||||
{
|
||||
if let Ok(op) = EmptyStringCmpOp::try_from(op) {
|
||||
|
|
|
@ -17,83 +17,83 @@ pub trait AstNode: Ranged {
|
|||
|
||||
#[derive(Clone, Debug, is_macro::Is, PartialEq)]
|
||||
pub enum AnyNode {
|
||||
ModModule(ModModule<TextRange>),
|
||||
ModInteractive(ModInteractive<TextRange>),
|
||||
ModExpression(ModExpression<TextRange>),
|
||||
ModFunctionType(ModFunctionType<TextRange>),
|
||||
StmtFunctionDef(StmtFunctionDef<TextRange>),
|
||||
StmtAsyncFunctionDef(StmtAsyncFunctionDef<TextRange>),
|
||||
StmtClassDef(StmtClassDef<TextRange>),
|
||||
StmtReturn(StmtReturn<TextRange>),
|
||||
StmtDelete(StmtDelete<TextRange>),
|
||||
StmtAssign(StmtAssign<TextRange>),
|
||||
StmtAugAssign(StmtAugAssign<TextRange>),
|
||||
StmtAnnAssign(StmtAnnAssign<TextRange>),
|
||||
StmtFor(StmtFor<TextRange>),
|
||||
StmtAsyncFor(StmtAsyncFor<TextRange>),
|
||||
StmtWhile(StmtWhile<TextRange>),
|
||||
StmtIf(StmtIf<TextRange>),
|
||||
StmtWith(StmtWith<TextRange>),
|
||||
StmtAsyncWith(StmtAsyncWith<TextRange>),
|
||||
StmtMatch(StmtMatch<TextRange>),
|
||||
StmtRaise(StmtRaise<TextRange>),
|
||||
StmtTry(StmtTry<TextRange>),
|
||||
StmtTryStar(StmtTryStar<TextRange>),
|
||||
StmtAssert(StmtAssert<TextRange>),
|
||||
StmtImport(StmtImport<TextRange>),
|
||||
StmtImportFrom(StmtImportFrom<TextRange>),
|
||||
StmtGlobal(StmtGlobal<TextRange>),
|
||||
StmtNonlocal(StmtNonlocal<TextRange>),
|
||||
StmtExpr(StmtExpr<TextRange>),
|
||||
StmtPass(StmtPass<TextRange>),
|
||||
StmtBreak(StmtBreak<TextRange>),
|
||||
StmtContinue(StmtContinue<TextRange>),
|
||||
ExprBoolOp(ExprBoolOp<TextRange>),
|
||||
ExprNamedExpr(ExprNamedExpr<TextRange>),
|
||||
ExprBinOp(ExprBinOp<TextRange>),
|
||||
ExprUnaryOp(ExprUnaryOp<TextRange>),
|
||||
ExprLambda(ExprLambda<TextRange>),
|
||||
ExprIfExp(ExprIfExp<TextRange>),
|
||||
ExprDict(ExprDict<TextRange>),
|
||||
ExprSet(ExprSet<TextRange>),
|
||||
ExprListComp(ExprListComp<TextRange>),
|
||||
ExprSetComp(ExprSetComp<TextRange>),
|
||||
ExprDictComp(ExprDictComp<TextRange>),
|
||||
ExprGeneratorExp(ExprGeneratorExp<TextRange>),
|
||||
ExprAwait(ExprAwait<TextRange>),
|
||||
ExprYield(ExprYield<TextRange>),
|
||||
ExprYieldFrom(ExprYieldFrom<TextRange>),
|
||||
ExprCompare(ExprCompare<TextRange>),
|
||||
ExprCall(ExprCall<TextRange>),
|
||||
ExprFormattedValue(ExprFormattedValue<TextRange>),
|
||||
ExprJoinedStr(ExprJoinedStr<TextRange>),
|
||||
ExprConstant(ExprConstant<TextRange>),
|
||||
ExprAttribute(ExprAttribute<TextRange>),
|
||||
ExprSubscript(ExprSubscript<TextRange>),
|
||||
ExprStarred(ExprStarred<TextRange>),
|
||||
ExprName(ExprName<TextRange>),
|
||||
ExprList(ExprList<TextRange>),
|
||||
ExprTuple(ExprTuple<TextRange>),
|
||||
ExprSlice(ExprSlice<TextRange>),
|
||||
ExceptHandlerExceptHandler(ExceptHandlerExceptHandler<TextRange>),
|
||||
PatternMatchValue(PatternMatchValue<TextRange>),
|
||||
PatternMatchSingleton(PatternMatchSingleton<TextRange>),
|
||||
PatternMatchSequence(PatternMatchSequence<TextRange>),
|
||||
PatternMatchMapping(PatternMatchMapping<TextRange>),
|
||||
PatternMatchClass(PatternMatchClass<TextRange>),
|
||||
PatternMatchStar(PatternMatchStar<TextRange>),
|
||||
PatternMatchAs(PatternMatchAs<TextRange>),
|
||||
PatternMatchOr(PatternMatchOr<TextRange>),
|
||||
TypeIgnoreTypeIgnore(TypeIgnoreTypeIgnore<TextRange>),
|
||||
Comprehension(Comprehension<TextRange>),
|
||||
Arguments(Arguments<TextRange>),
|
||||
Arg(Arg<TextRange>),
|
||||
ArgWithDefault(ArgWithDefault<TextRange>),
|
||||
Keyword(Keyword<TextRange>),
|
||||
Alias(Alias<TextRange>),
|
||||
WithItem(WithItem<TextRange>),
|
||||
MatchCase(MatchCase<TextRange>),
|
||||
Decorator(Decorator<TextRange>),
|
||||
ModModule(ModModule),
|
||||
ModInteractive(ModInteractive),
|
||||
ModExpression(ModExpression),
|
||||
ModFunctionType(ModFunctionType),
|
||||
StmtFunctionDef(StmtFunctionDef),
|
||||
StmtAsyncFunctionDef(StmtAsyncFunctionDef),
|
||||
StmtClassDef(StmtClassDef),
|
||||
StmtReturn(StmtReturn),
|
||||
StmtDelete(StmtDelete),
|
||||
StmtAssign(StmtAssign),
|
||||
StmtAugAssign(StmtAugAssign),
|
||||
StmtAnnAssign(StmtAnnAssign),
|
||||
StmtFor(StmtFor),
|
||||
StmtAsyncFor(StmtAsyncFor),
|
||||
StmtWhile(StmtWhile),
|
||||
StmtIf(StmtIf),
|
||||
StmtWith(StmtWith),
|
||||
StmtAsyncWith(StmtAsyncWith),
|
||||
StmtMatch(StmtMatch),
|
||||
StmtRaise(StmtRaise),
|
||||
StmtTry(StmtTry),
|
||||
StmtTryStar(StmtTryStar),
|
||||
StmtAssert(StmtAssert),
|
||||
StmtImport(StmtImport),
|
||||
StmtImportFrom(StmtImportFrom),
|
||||
StmtGlobal(StmtGlobal),
|
||||
StmtNonlocal(StmtNonlocal),
|
||||
StmtExpr(StmtExpr),
|
||||
StmtPass(StmtPass),
|
||||
StmtBreak(StmtBreak),
|
||||
StmtContinue(StmtContinue),
|
||||
ExprBoolOp(ExprBoolOp),
|
||||
ExprNamedExpr(ExprNamedExpr),
|
||||
ExprBinOp(ExprBinOp),
|
||||
ExprUnaryOp(ExprUnaryOp),
|
||||
ExprLambda(ExprLambda),
|
||||
ExprIfExp(ExprIfExp),
|
||||
ExprDict(ExprDict),
|
||||
ExprSet(ExprSet),
|
||||
ExprListComp(ExprListComp),
|
||||
ExprSetComp(ExprSetComp),
|
||||
ExprDictComp(ExprDictComp),
|
||||
ExprGeneratorExp(ExprGeneratorExp),
|
||||
ExprAwait(ExprAwait),
|
||||
ExprYield(ExprYield),
|
||||
ExprYieldFrom(ExprYieldFrom),
|
||||
ExprCompare(ExprCompare),
|
||||
ExprCall(ExprCall),
|
||||
ExprFormattedValue(ExprFormattedValue),
|
||||
ExprJoinedStr(ExprJoinedStr),
|
||||
ExprConstant(ExprConstant),
|
||||
ExprAttribute(ExprAttribute),
|
||||
ExprSubscript(ExprSubscript),
|
||||
ExprStarred(ExprStarred),
|
||||
ExprName(ExprName),
|
||||
ExprList(ExprList),
|
||||
ExprTuple(ExprTuple),
|
||||
ExprSlice(ExprSlice),
|
||||
ExceptHandlerExceptHandler(ExceptHandlerExceptHandler),
|
||||
PatternMatchValue(PatternMatchValue),
|
||||
PatternMatchSingleton(PatternMatchSingleton),
|
||||
PatternMatchSequence(PatternMatchSequence),
|
||||
PatternMatchMapping(PatternMatchMapping),
|
||||
PatternMatchClass(PatternMatchClass),
|
||||
PatternMatchStar(PatternMatchStar),
|
||||
PatternMatchAs(PatternMatchAs),
|
||||
PatternMatchOr(PatternMatchOr),
|
||||
TypeIgnoreTypeIgnore(TypeIgnoreTypeIgnore),
|
||||
Comprehension(Comprehension),
|
||||
Arguments(Arguments),
|
||||
Arg(Arg),
|
||||
ArgWithDefault(ArgWithDefault),
|
||||
Keyword(Keyword),
|
||||
Alias(Alias),
|
||||
WithItem(WithItem),
|
||||
MatchCase(MatchCase),
|
||||
Decorator(Decorator),
|
||||
}
|
||||
|
||||
impl AnyNode {
|
||||
|
@ -707,7 +707,7 @@ impl AnyNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl AstNode for ModModule<TextRange> {
|
||||
impl AstNode for ModModule {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -735,7 +735,7 @@ impl AstNode for ModModule<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ModInteractive<TextRange> {
|
||||
impl AstNode for ModInteractive {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -763,7 +763,7 @@ impl AstNode for ModInteractive<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ModExpression<TextRange> {
|
||||
impl AstNode for ModExpression {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -791,7 +791,7 @@ impl AstNode for ModExpression<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ModFunctionType<TextRange> {
|
||||
impl AstNode for ModFunctionType {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -819,7 +819,7 @@ impl AstNode for ModFunctionType<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtFunctionDef<TextRange> {
|
||||
impl AstNode for StmtFunctionDef {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -847,7 +847,7 @@ impl AstNode for StmtFunctionDef<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAsyncFunctionDef<TextRange> {
|
||||
impl AstNode for StmtAsyncFunctionDef {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -875,7 +875,7 @@ impl AstNode for StmtAsyncFunctionDef<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtClassDef<TextRange> {
|
||||
impl AstNode for StmtClassDef {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -903,7 +903,7 @@ impl AstNode for StmtClassDef<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtReturn<TextRange> {
|
||||
impl AstNode for StmtReturn {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -931,7 +931,7 @@ impl AstNode for StmtReturn<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtDelete<TextRange> {
|
||||
impl AstNode for StmtDelete {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -959,7 +959,7 @@ impl AstNode for StmtDelete<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAssign<TextRange> {
|
||||
impl AstNode for StmtAssign {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -987,7 +987,7 @@ impl AstNode for StmtAssign<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAugAssign<TextRange> {
|
||||
impl AstNode for StmtAugAssign {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1015,7 +1015,7 @@ impl AstNode for StmtAugAssign<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAnnAssign<TextRange> {
|
||||
impl AstNode for StmtAnnAssign {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1043,7 +1043,7 @@ impl AstNode for StmtAnnAssign<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtFor<TextRange> {
|
||||
impl AstNode for StmtFor {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1071,7 +1071,7 @@ impl AstNode for StmtFor<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAsyncFor<TextRange> {
|
||||
impl AstNode for StmtAsyncFor {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1099,7 +1099,7 @@ impl AstNode for StmtAsyncFor<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtWhile<TextRange> {
|
||||
impl AstNode for StmtWhile {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1127,7 +1127,7 @@ impl AstNode for StmtWhile<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtIf<TextRange> {
|
||||
impl AstNode for StmtIf {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1155,7 +1155,7 @@ impl AstNode for StmtIf<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtWith<TextRange> {
|
||||
impl AstNode for StmtWith {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1183,7 +1183,7 @@ impl AstNode for StmtWith<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAsyncWith<TextRange> {
|
||||
impl AstNode for StmtAsyncWith {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1211,7 +1211,7 @@ impl AstNode for StmtAsyncWith<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtMatch<TextRange> {
|
||||
impl AstNode for StmtMatch {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1239,7 +1239,7 @@ impl AstNode for StmtMatch<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtRaise<TextRange> {
|
||||
impl AstNode for StmtRaise {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1267,7 +1267,7 @@ impl AstNode for StmtRaise<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtTry<TextRange> {
|
||||
impl AstNode for StmtTry {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1295,7 +1295,7 @@ impl AstNode for StmtTry<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtTryStar<TextRange> {
|
||||
impl AstNode for StmtTryStar {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1323,7 +1323,7 @@ impl AstNode for StmtTryStar<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtAssert<TextRange> {
|
||||
impl AstNode for StmtAssert {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1351,7 +1351,7 @@ impl AstNode for StmtAssert<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtImport<TextRange> {
|
||||
impl AstNode for StmtImport {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1379,7 +1379,7 @@ impl AstNode for StmtImport<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtImportFrom<TextRange> {
|
||||
impl AstNode for StmtImportFrom {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1407,7 +1407,7 @@ impl AstNode for StmtImportFrom<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtGlobal<TextRange> {
|
||||
impl AstNode for StmtGlobal {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1435,7 +1435,7 @@ impl AstNode for StmtGlobal<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtNonlocal<TextRange> {
|
||||
impl AstNode for StmtNonlocal {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1463,7 +1463,7 @@ impl AstNode for StmtNonlocal<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtExpr<TextRange> {
|
||||
impl AstNode for StmtExpr {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1491,7 +1491,7 @@ impl AstNode for StmtExpr<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtPass<TextRange> {
|
||||
impl AstNode for StmtPass {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1519,7 +1519,7 @@ impl AstNode for StmtPass<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtBreak<TextRange> {
|
||||
impl AstNode for StmtBreak {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1547,7 +1547,7 @@ impl AstNode for StmtBreak<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for StmtContinue<TextRange> {
|
||||
impl AstNode for StmtContinue {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1575,7 +1575,7 @@ impl AstNode for StmtContinue<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprBoolOp<TextRange> {
|
||||
impl AstNode for ExprBoolOp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1603,7 +1603,7 @@ impl AstNode for ExprBoolOp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprNamedExpr<TextRange> {
|
||||
impl AstNode for ExprNamedExpr {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1631,7 +1631,7 @@ impl AstNode for ExprNamedExpr<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprBinOp<TextRange> {
|
||||
impl AstNode for ExprBinOp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1659,7 +1659,7 @@ impl AstNode for ExprBinOp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprUnaryOp<TextRange> {
|
||||
impl AstNode for ExprUnaryOp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1687,7 +1687,7 @@ impl AstNode for ExprUnaryOp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprLambda<TextRange> {
|
||||
impl AstNode for ExprLambda {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1715,7 +1715,7 @@ impl AstNode for ExprLambda<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprIfExp<TextRange> {
|
||||
impl AstNode for ExprIfExp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1743,7 +1743,7 @@ impl AstNode for ExprIfExp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprDict<TextRange> {
|
||||
impl AstNode for ExprDict {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1771,7 +1771,7 @@ impl AstNode for ExprDict<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprSet<TextRange> {
|
||||
impl AstNode for ExprSet {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1799,7 +1799,7 @@ impl AstNode for ExprSet<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprListComp<TextRange> {
|
||||
impl AstNode for ExprListComp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1827,7 +1827,7 @@ impl AstNode for ExprListComp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprSetComp<TextRange> {
|
||||
impl AstNode for ExprSetComp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1855,7 +1855,7 @@ impl AstNode for ExprSetComp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprDictComp<TextRange> {
|
||||
impl AstNode for ExprDictComp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1883,7 +1883,7 @@ impl AstNode for ExprDictComp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprGeneratorExp<TextRange> {
|
||||
impl AstNode for ExprGeneratorExp {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1911,7 +1911,7 @@ impl AstNode for ExprGeneratorExp<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprAwait<TextRange> {
|
||||
impl AstNode for ExprAwait {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1939,7 +1939,7 @@ impl AstNode for ExprAwait<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprYield<TextRange> {
|
||||
impl AstNode for ExprYield {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1967,7 +1967,7 @@ impl AstNode for ExprYield<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprYieldFrom<TextRange> {
|
||||
impl AstNode for ExprYieldFrom {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1995,7 +1995,7 @@ impl AstNode for ExprYieldFrom<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprCompare<TextRange> {
|
||||
impl AstNode for ExprCompare {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2023,7 +2023,7 @@ impl AstNode for ExprCompare<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprCall<TextRange> {
|
||||
impl AstNode for ExprCall {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2051,7 +2051,7 @@ impl AstNode for ExprCall<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprFormattedValue<TextRange> {
|
||||
impl AstNode for ExprFormattedValue {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2079,7 +2079,7 @@ impl AstNode for ExprFormattedValue<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprJoinedStr<TextRange> {
|
||||
impl AstNode for ExprJoinedStr {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2107,7 +2107,7 @@ impl AstNode for ExprJoinedStr<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprConstant<TextRange> {
|
||||
impl AstNode for ExprConstant {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2135,7 +2135,7 @@ impl AstNode for ExprConstant<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprAttribute<TextRange> {
|
||||
impl AstNode for ExprAttribute {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2163,7 +2163,7 @@ impl AstNode for ExprAttribute<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprSubscript<TextRange> {
|
||||
impl AstNode for ExprSubscript {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2191,7 +2191,7 @@ impl AstNode for ExprSubscript<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprStarred<TextRange> {
|
||||
impl AstNode for ExprStarred {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2219,7 +2219,7 @@ impl AstNode for ExprStarred<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprName<TextRange> {
|
||||
impl AstNode for ExprName {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2247,7 +2247,7 @@ impl AstNode for ExprName<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprList<TextRange> {
|
||||
impl AstNode for ExprList {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2275,7 +2275,7 @@ impl AstNode for ExprList<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprTuple<TextRange> {
|
||||
impl AstNode for ExprTuple {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2303,7 +2303,7 @@ impl AstNode for ExprTuple<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExprSlice<TextRange> {
|
||||
impl AstNode for ExprSlice {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2331,7 +2331,7 @@ impl AstNode for ExprSlice<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ExceptHandlerExceptHandler<TextRange> {
|
||||
impl AstNode for ExceptHandlerExceptHandler {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2359,7 +2359,7 @@ impl AstNode for ExceptHandlerExceptHandler<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchValue<TextRange> {
|
||||
impl AstNode for PatternMatchValue {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2387,7 +2387,7 @@ impl AstNode for PatternMatchValue<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchSingleton<TextRange> {
|
||||
impl AstNode for PatternMatchSingleton {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2415,7 +2415,7 @@ impl AstNode for PatternMatchSingleton<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchSequence<TextRange> {
|
||||
impl AstNode for PatternMatchSequence {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2443,7 +2443,7 @@ impl AstNode for PatternMatchSequence<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchMapping<TextRange> {
|
||||
impl AstNode for PatternMatchMapping {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2471,7 +2471,7 @@ impl AstNode for PatternMatchMapping<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchClass<TextRange> {
|
||||
impl AstNode for PatternMatchClass {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2499,7 +2499,7 @@ impl AstNode for PatternMatchClass<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchStar<TextRange> {
|
||||
impl AstNode for PatternMatchStar {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2527,7 +2527,7 @@ impl AstNode for PatternMatchStar<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchAs<TextRange> {
|
||||
impl AstNode for PatternMatchAs {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2555,7 +2555,7 @@ impl AstNode for PatternMatchAs<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for PatternMatchOr<TextRange> {
|
||||
impl AstNode for PatternMatchOr {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2583,7 +2583,7 @@ impl AstNode for PatternMatchOr<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for TypeIgnoreTypeIgnore<TextRange> {
|
||||
impl AstNode for TypeIgnoreTypeIgnore {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2612,7 +2612,7 @@ impl AstNode for TypeIgnoreTypeIgnore<TextRange> {
|
|||
}
|
||||
}
|
||||
|
||||
impl AstNode for Comprehension<TextRange> {
|
||||
impl AstNode for Comprehension {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2640,7 +2640,7 @@ impl AstNode for Comprehension<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for Arguments<TextRange> {
|
||||
impl AstNode for Arguments {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2668,7 +2668,7 @@ impl AstNode for Arguments<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for Arg<TextRange> {
|
||||
impl AstNode for Arg {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2696,7 +2696,7 @@ impl AstNode for Arg<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for ArgWithDefault<TextRange> {
|
||||
impl AstNode for ArgWithDefault {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2724,7 +2724,7 @@ impl AstNode for ArgWithDefault<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for Keyword<TextRange> {
|
||||
impl AstNode for Keyword {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2752,7 +2752,7 @@ impl AstNode for Keyword<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for Alias<TextRange> {
|
||||
impl AstNode for Alias {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2780,7 +2780,7 @@ impl AstNode for Alias<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for WithItem<TextRange> {
|
||||
impl AstNode for WithItem {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2808,7 +2808,7 @@ impl AstNode for WithItem<TextRange> {
|
|||
AnyNode::from(self)
|
||||
}
|
||||
}
|
||||
impl AstNode for MatchCase<TextRange> {
|
||||
impl AstNode for MatchCase {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2837,7 +2837,7 @@ impl AstNode for MatchCase<TextRange> {
|
|||
}
|
||||
}
|
||||
|
||||
impl AstNode for Decorator<TextRange> {
|
||||
impl AstNode for Decorator {
|
||||
fn cast(kind: AnyNode) -> Option<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -3516,83 +3516,83 @@ impl Ranged for AnyNode {
|
|||
|
||||
#[derive(Copy, Clone, Debug, is_macro::Is, PartialEq)]
|
||||
pub enum AnyNodeRef<'a> {
|
||||
ModModule(&'a ModModule<TextRange>),
|
||||
ModInteractive(&'a ModInteractive<TextRange>),
|
||||
ModExpression(&'a ModExpression<TextRange>),
|
||||
ModFunctionType(&'a ModFunctionType<TextRange>),
|
||||
StmtFunctionDef(&'a StmtFunctionDef<TextRange>),
|
||||
StmtAsyncFunctionDef(&'a StmtAsyncFunctionDef<TextRange>),
|
||||
StmtClassDef(&'a StmtClassDef<TextRange>),
|
||||
StmtReturn(&'a StmtReturn<TextRange>),
|
||||
StmtDelete(&'a StmtDelete<TextRange>),
|
||||
StmtAssign(&'a StmtAssign<TextRange>),
|
||||
StmtAugAssign(&'a StmtAugAssign<TextRange>),
|
||||
StmtAnnAssign(&'a StmtAnnAssign<TextRange>),
|
||||
StmtFor(&'a StmtFor<TextRange>),
|
||||
StmtAsyncFor(&'a StmtAsyncFor<TextRange>),
|
||||
StmtWhile(&'a StmtWhile<TextRange>),
|
||||
StmtIf(&'a StmtIf<TextRange>),
|
||||
StmtWith(&'a StmtWith<TextRange>),
|
||||
StmtAsyncWith(&'a StmtAsyncWith<TextRange>),
|
||||
StmtMatch(&'a StmtMatch<TextRange>),
|
||||
StmtRaise(&'a StmtRaise<TextRange>),
|
||||
StmtTry(&'a StmtTry<TextRange>),
|
||||
StmtTryStar(&'a StmtTryStar<TextRange>),
|
||||
StmtAssert(&'a StmtAssert<TextRange>),
|
||||
StmtImport(&'a StmtImport<TextRange>),
|
||||
StmtImportFrom(&'a StmtImportFrom<TextRange>),
|
||||
StmtGlobal(&'a StmtGlobal<TextRange>),
|
||||
StmtNonlocal(&'a StmtNonlocal<TextRange>),
|
||||
StmtExpr(&'a StmtExpr<TextRange>),
|
||||
StmtPass(&'a StmtPass<TextRange>),
|
||||
StmtBreak(&'a StmtBreak<TextRange>),
|
||||
StmtContinue(&'a StmtContinue<TextRange>),
|
||||
ExprBoolOp(&'a ExprBoolOp<TextRange>),
|
||||
ExprNamedExpr(&'a ExprNamedExpr<TextRange>),
|
||||
ExprBinOp(&'a ExprBinOp<TextRange>),
|
||||
ExprUnaryOp(&'a ExprUnaryOp<TextRange>),
|
||||
ExprLambda(&'a ExprLambda<TextRange>),
|
||||
ExprIfExp(&'a ExprIfExp<TextRange>),
|
||||
ExprDict(&'a ExprDict<TextRange>),
|
||||
ExprSet(&'a ExprSet<TextRange>),
|
||||
ExprListComp(&'a ExprListComp<TextRange>),
|
||||
ExprSetComp(&'a ExprSetComp<TextRange>),
|
||||
ExprDictComp(&'a ExprDictComp<TextRange>),
|
||||
ExprGeneratorExp(&'a ExprGeneratorExp<TextRange>),
|
||||
ExprAwait(&'a ExprAwait<TextRange>),
|
||||
ExprYield(&'a ExprYield<TextRange>),
|
||||
ExprYieldFrom(&'a ExprYieldFrom<TextRange>),
|
||||
ExprCompare(&'a ExprCompare<TextRange>),
|
||||
ExprCall(&'a ExprCall<TextRange>),
|
||||
ExprFormattedValue(&'a ExprFormattedValue<TextRange>),
|
||||
ExprJoinedStr(&'a ExprJoinedStr<TextRange>),
|
||||
ExprConstant(&'a ExprConstant<TextRange>),
|
||||
ExprAttribute(&'a ExprAttribute<TextRange>),
|
||||
ExprSubscript(&'a ExprSubscript<TextRange>),
|
||||
ExprStarred(&'a ExprStarred<TextRange>),
|
||||
ExprName(&'a ExprName<TextRange>),
|
||||
ExprList(&'a ExprList<TextRange>),
|
||||
ExprTuple(&'a ExprTuple<TextRange>),
|
||||
ExprSlice(&'a ExprSlice<TextRange>),
|
||||
ExceptHandlerExceptHandler(&'a ExceptHandlerExceptHandler<TextRange>),
|
||||
PatternMatchValue(&'a PatternMatchValue<TextRange>),
|
||||
PatternMatchSingleton(&'a PatternMatchSingleton<TextRange>),
|
||||
PatternMatchSequence(&'a PatternMatchSequence<TextRange>),
|
||||
PatternMatchMapping(&'a PatternMatchMapping<TextRange>),
|
||||
PatternMatchClass(&'a PatternMatchClass<TextRange>),
|
||||
PatternMatchStar(&'a PatternMatchStar<TextRange>),
|
||||
PatternMatchAs(&'a PatternMatchAs<TextRange>),
|
||||
PatternMatchOr(&'a PatternMatchOr<TextRange>),
|
||||
TypeIgnoreTypeIgnore(&'a TypeIgnoreTypeIgnore<TextRange>),
|
||||
Comprehension(&'a Comprehension<TextRange>),
|
||||
Arguments(&'a Arguments<TextRange>),
|
||||
Arg(&'a Arg<TextRange>),
|
||||
ArgWithDefault(&'a ArgWithDefault<TextRange>),
|
||||
Keyword(&'a Keyword<TextRange>),
|
||||
Alias(&'a Alias<TextRange>),
|
||||
WithItem(&'a WithItem<TextRange>),
|
||||
MatchCase(&'a MatchCase<TextRange>),
|
||||
Decorator(&'a Decorator<TextRange>),
|
||||
ModModule(&'a ModModule),
|
||||
ModInteractive(&'a ModInteractive),
|
||||
ModExpression(&'a ModExpression),
|
||||
ModFunctionType(&'a ModFunctionType),
|
||||
StmtFunctionDef(&'a StmtFunctionDef),
|
||||
StmtAsyncFunctionDef(&'a StmtAsyncFunctionDef),
|
||||
StmtClassDef(&'a StmtClassDef),
|
||||
StmtReturn(&'a StmtReturn),
|
||||
StmtDelete(&'a StmtDelete),
|
||||
StmtAssign(&'a StmtAssign),
|
||||
StmtAugAssign(&'a StmtAugAssign),
|
||||
StmtAnnAssign(&'a StmtAnnAssign),
|
||||
StmtFor(&'a StmtFor),
|
||||
StmtAsyncFor(&'a StmtAsyncFor),
|
||||
StmtWhile(&'a StmtWhile),
|
||||
StmtIf(&'a StmtIf),
|
||||
StmtWith(&'a StmtWith),
|
||||
StmtAsyncWith(&'a StmtAsyncWith),
|
||||
StmtMatch(&'a StmtMatch),
|
||||
StmtRaise(&'a StmtRaise),
|
||||
StmtTry(&'a StmtTry),
|
||||
StmtTryStar(&'a StmtTryStar),
|
||||
StmtAssert(&'a StmtAssert),
|
||||
StmtImport(&'a StmtImport),
|
||||
StmtImportFrom(&'a StmtImportFrom),
|
||||
StmtGlobal(&'a StmtGlobal),
|
||||
StmtNonlocal(&'a StmtNonlocal),
|
||||
StmtExpr(&'a StmtExpr),
|
||||
StmtPass(&'a StmtPass),
|
||||
StmtBreak(&'a StmtBreak),
|
||||
StmtContinue(&'a StmtContinue),
|
||||
ExprBoolOp(&'a ExprBoolOp),
|
||||
ExprNamedExpr(&'a ExprNamedExpr),
|
||||
ExprBinOp(&'a ExprBinOp),
|
||||
ExprUnaryOp(&'a ExprUnaryOp),
|
||||
ExprLambda(&'a ExprLambda),
|
||||
ExprIfExp(&'a ExprIfExp),
|
||||
ExprDict(&'a ExprDict),
|
||||
ExprSet(&'a ExprSet),
|
||||
ExprListComp(&'a ExprListComp),
|
||||
ExprSetComp(&'a ExprSetComp),
|
||||
ExprDictComp(&'a ExprDictComp),
|
||||
ExprGeneratorExp(&'a ExprGeneratorExp),
|
||||
ExprAwait(&'a ExprAwait),
|
||||
ExprYield(&'a ExprYield),
|
||||
ExprYieldFrom(&'a ExprYieldFrom),
|
||||
ExprCompare(&'a ExprCompare),
|
||||
ExprCall(&'a ExprCall),
|
||||
ExprFormattedValue(&'a ExprFormattedValue),
|
||||
ExprJoinedStr(&'a ExprJoinedStr),
|
||||
ExprConstant(&'a ExprConstant),
|
||||
ExprAttribute(&'a ExprAttribute),
|
||||
ExprSubscript(&'a ExprSubscript),
|
||||
ExprStarred(&'a ExprStarred),
|
||||
ExprName(&'a ExprName),
|
||||
ExprList(&'a ExprList),
|
||||
ExprTuple(&'a ExprTuple),
|
||||
ExprSlice(&'a ExprSlice),
|
||||
ExceptHandlerExceptHandler(&'a ExceptHandlerExceptHandler),
|
||||
PatternMatchValue(&'a PatternMatchValue),
|
||||
PatternMatchSingleton(&'a PatternMatchSingleton),
|
||||
PatternMatchSequence(&'a PatternMatchSequence),
|
||||
PatternMatchMapping(&'a PatternMatchMapping),
|
||||
PatternMatchClass(&'a PatternMatchClass),
|
||||
PatternMatchStar(&'a PatternMatchStar),
|
||||
PatternMatchAs(&'a PatternMatchAs),
|
||||
PatternMatchOr(&'a PatternMatchOr),
|
||||
TypeIgnoreTypeIgnore(&'a TypeIgnoreTypeIgnore),
|
||||
Comprehension(&'a Comprehension),
|
||||
Arguments(&'a Arguments),
|
||||
Arg(&'a Arg),
|
||||
ArgWithDefault(&'a ArgWithDefault),
|
||||
Keyword(&'a Keyword),
|
||||
Alias(&'a Alias),
|
||||
WithItem(&'a WithItem),
|
||||
MatchCase(&'a MatchCase),
|
||||
Decorator(&'a Decorator),
|
||||
}
|
||||
|
||||
impl AnyNodeRef<'_> {
|
||||
|
|
|
@ -132,7 +132,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn body<U>(&mut self, stmts: &[Stmt<U>]) {
|
||||
fn body(&mut self, stmts: &[Stmt]) {
|
||||
self.indent_depth = self.indent_depth.saturating_add(1);
|
||||
for stmt in stmts {
|
||||
self.unparse_stmt(stmt);
|
||||
|
@ -184,13 +184,13 @@ impl<'a> Generator<'a> {
|
|||
self.buffer
|
||||
}
|
||||
|
||||
pub fn unparse_suite<U>(&mut self, suite: &Suite<U>) {
|
||||
pub fn unparse_suite(&mut self, suite: &Suite) {
|
||||
for stmt in suite {
|
||||
self.unparse_stmt(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn unparse_stmt<U>(&mut self, ast: &Stmt<U>) {
|
||||
pub(crate) fn unparse_stmt(&mut self, ast: &Stmt) {
|
||||
macro_rules! statement {
|
||||
($body:block) => {{
|
||||
self.newline();
|
||||
|
@ -467,7 +467,7 @@ impl<'a> Generator<'a> {
|
|||
});
|
||||
self.body(body);
|
||||
|
||||
let mut orelse_: &[Stmt<U>] = orelse;
|
||||
let mut orelse_: &[Stmt] = orelse;
|
||||
loop {
|
||||
if orelse_.len() == 1 && matches!(orelse_[0], Stmt::If(_)) {
|
||||
if let Stmt::If(ast::StmtIf {
|
||||
|
@ -718,7 +718,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_except_handler<U>(&mut self, ast: &ExceptHandler<U>, star: bool) {
|
||||
fn unparse_except_handler(&mut self, ast: &ExceptHandler, star: bool) {
|
||||
match ast {
|
||||
ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler {
|
||||
type_,
|
||||
|
@ -744,7 +744,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_pattern<U>(&mut self, ast: &Pattern<U>) {
|
||||
fn unparse_pattern(&mut self, ast: &Pattern) {
|
||||
match ast {
|
||||
Pattern::MatchValue(ast::PatternMatchValue {
|
||||
value,
|
||||
|
@ -831,7 +831,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_match_case<U>(&mut self, ast: &MatchCase<U>) {
|
||||
fn unparse_match_case(&mut self, ast: &MatchCase) {
|
||||
self.p("case ");
|
||||
self.unparse_pattern(&ast.pattern);
|
||||
if let Some(guard) = &ast.guard {
|
||||
|
@ -842,7 +842,7 @@ impl<'a> Generator<'a> {
|
|||
self.body(&ast.body);
|
||||
}
|
||||
|
||||
pub(crate) fn unparse_expr<U>(&mut self, ast: &Expr<U>, level: u8) {
|
||||
pub(crate) fn unparse_expr(&mut self, ast: &Expr, level: u8) {
|
||||
macro_rules! opprec {
|
||||
($opty:ident, $x:expr, $enu:path, $($var:ident($op:literal, $prec:ident)),*$(,)?) => {
|
||||
match $x {
|
||||
|
@ -1289,7 +1289,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_args<U>(&mut self, args: &Arguments<U>) {
|
||||
fn unparse_args(&mut self, args: &Arguments) {
|
||||
let mut first = true;
|
||||
for (i, arg_with_default) in args.posonlyargs.iter().chain(&args.args).enumerate() {
|
||||
self.p_delim(&mut first, ", ");
|
||||
|
@ -1314,7 +1314,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_arg<U>(&mut self, arg: &Arg<U>) {
|
||||
fn unparse_arg(&mut self, arg: &Arg) {
|
||||
self.p_id(&arg.arg);
|
||||
if let Some(ann) = &arg.annotation {
|
||||
self.p(": ");
|
||||
|
@ -1322,7 +1322,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_arg_with_default<U>(&mut self, arg_with_default: &ArgWithDefault<U>) {
|
||||
fn unparse_arg_with_default(&mut self, arg_with_default: &ArgWithDefault) {
|
||||
self.unparse_arg(&arg_with_default.def);
|
||||
if let Some(default) = &arg_with_default.default {
|
||||
self.p("=");
|
||||
|
@ -1330,7 +1330,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_comp<U>(&mut self, generators: &[Comprehension<U>]) {
|
||||
fn unparse_comp(&mut self, generators: &[Comprehension]) {
|
||||
for comp in generators {
|
||||
self.p(if comp.is_async {
|
||||
" async for "
|
||||
|
@ -1347,18 +1347,13 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_fstring_body<U>(&mut self, values: &[Expr<U>], is_spec: bool) {
|
||||
fn unparse_fstring_body(&mut self, values: &[Expr], is_spec: bool) {
|
||||
for value in values {
|
||||
self.unparse_fstring_elem(value, is_spec);
|
||||
}
|
||||
}
|
||||
|
||||
fn unparse_formatted<U>(
|
||||
&mut self,
|
||||
val: &Expr<U>,
|
||||
conversion: ConversionFlag,
|
||||
spec: Option<&Expr<U>>,
|
||||
) {
|
||||
fn unparse_formatted(&mut self, val: &Expr, conversion: ConversionFlag, spec: Option<&Expr>) {
|
||||
let mut generator = Generator::new(self.indent, self.quote, self.line_ending);
|
||||
generator.unparse_expr(val, precedence::FORMATTED_VALUE);
|
||||
let brace = if generator.buffer.starts_with('{') {
|
||||
|
@ -1384,7 +1379,7 @@ impl<'a> Generator<'a> {
|
|||
self.p("}");
|
||||
}
|
||||
|
||||
fn unparse_fstring_elem<U>(&mut self, expr: &Expr<U>, is_spec: bool) {
|
||||
fn unparse_fstring_elem(&mut self, expr: &Expr, is_spec: bool) {
|
||||
match expr {
|
||||
Expr::Constant(ast::ExprConstant { value, .. }) => {
|
||||
if let Constant::Str(s) = value {
|
||||
|
@ -1414,7 +1409,7 @@ impl<'a> Generator<'a> {
|
|||
self.p(&s);
|
||||
}
|
||||
|
||||
fn unparse_joinedstr<U>(&mut self, values: &[Expr<U>], is_spec: bool) {
|
||||
fn unparse_joinedstr(&mut self, values: &[Expr], is_spec: bool) {
|
||||
if is_spec {
|
||||
self.unparse_fstring_body(values, is_spec);
|
||||
} else {
|
||||
|
@ -1433,7 +1428,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_alias<U>(&mut self, alias: &Alias<U>) {
|
||||
fn unparse_alias(&mut self, alias: &Alias) {
|
||||
self.p_id(&alias.name);
|
||||
if let Some(asname) = &alias.asname {
|
||||
self.p(" as ");
|
||||
|
@ -1441,7 +1436,7 @@ impl<'a> Generator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn unparse_with_item<U>(&mut self, with_item: &WithItem<U>) {
|
||||
fn unparse_with_item(&mut self, with_item: &WithItem) {
|
||||
self.unparse_expr(&with_item.context_expr, precedence::MAX);
|
||||
if let Some(optional_vars) = &with_item.optional_vars {
|
||||
self.p(" as ");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue