mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 12:16:43 +00:00
[ruff] Autogenerate TypeParam nodes (#21028)
This commit is contained in:
parent
40148d7b11
commit
2c9433796a
37 changed files with 320 additions and 302 deletions
|
|
@ -605,10 +605,27 @@ fields = [{ name = "patterns", type = "Pattern*" }]
|
|||
[TypeParam]
|
||||
doc = "See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param)"
|
||||
|
||||
[TypeParam.nodes]
|
||||
TypeParamTypeVar = {}
|
||||
TypeParamTypeVarTuple = {}
|
||||
TypeParamParamSpec = {}
|
||||
[TypeParam.nodes.TypeParamTypeVar]
|
||||
doc = "See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar)"
|
||||
fields = [
|
||||
{ name = "name", type = "Identifier" },
|
||||
{ name = "bound", type = "Box<Expr>?" },
|
||||
{ name = "default", type = "Box<Expr>?" },
|
||||
]
|
||||
|
||||
[TypeParam.nodes.TypeParamTypeVarTuple]
|
||||
doc = "See also [TypeVarTuple](https://docs.python.org/3/library/ast.html#ast.TypeVarTuple)"
|
||||
fields = [
|
||||
{ name = "name", type = "Identifier" },
|
||||
{ name = "default", type = "Box<Expr>?" },
|
||||
]
|
||||
|
||||
[TypeParam.nodes.TypeParamParamSpec]
|
||||
doc = "See also [ParamSpec](https://docs.python.org/3/library/ast.html#ast.ParamSpec)"
|
||||
fields = [
|
||||
{ name = "name", type = "Identifier" },
|
||||
{ name = "default", type = "Box<Expr>?" },
|
||||
]
|
||||
|
||||
[ungrouped.nodes]
|
||||
InterpolatedStringFormatSpec = {}
|
||||
|
|
|
|||
93
crates/ruff_python_ast/src/generated.rs
generated
93
crates/ruff_python_ast/src/generated.rs
generated
|
|
@ -9713,6 +9713,37 @@ pub struct PatternMatchOr {
|
|||
pub patterns: Vec<Pattern>,
|
||||
}
|
||||
|
||||
/// See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct TypeParamTypeVar {
|
||||
pub node_index: crate::AtomicNodeIndex,
|
||||
pub range: ruff_text_size::TextRange,
|
||||
pub name: crate::Identifier,
|
||||
pub bound: Option<Box<Expr>>,
|
||||
pub default: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
/// See also [TypeVarTuple](https://docs.python.org/3/library/ast.html#ast.TypeVarTuple)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct TypeParamTypeVarTuple {
|
||||
pub node_index: crate::AtomicNodeIndex,
|
||||
pub range: ruff_text_size::TextRange,
|
||||
pub name: crate::Identifier,
|
||||
pub default: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
/// See also [ParamSpec](https://docs.python.org/3/library/ast.html#ast.ParamSpec)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct TypeParamParamSpec {
|
||||
pub node_index: crate::AtomicNodeIndex,
|
||||
pub range: ruff_text_size::TextRange,
|
||||
pub name: crate::Identifier,
|
||||
pub default: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
impl ModModule {
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
|
|
@ -10778,3 +10809,65 @@ impl PatternMatchOr {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeParamTypeVar {
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
V: SourceOrderVisitor<'a> + ?Sized,
|
||||
{
|
||||
let TypeParamTypeVar {
|
||||
name,
|
||||
bound,
|
||||
default,
|
||||
range: _,
|
||||
node_index: _,
|
||||
} = self;
|
||||
visitor.visit_identifier(name);
|
||||
|
||||
if let Some(bound) = bound {
|
||||
visitor.visit_expr(bound);
|
||||
}
|
||||
|
||||
if let Some(default) = default {
|
||||
visitor.visit_expr(default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeParamTypeVarTuple {
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
V: SourceOrderVisitor<'a> + ?Sized,
|
||||
{
|
||||
let TypeParamTypeVarTuple {
|
||||
name,
|
||||
default,
|
||||
range: _,
|
||||
node_index: _,
|
||||
} = self;
|
||||
visitor.visit_identifier(name);
|
||||
|
||||
if let Some(default) = default {
|
||||
visitor.visit_expr(default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeParamParamSpec {
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
V: SourceOrderVisitor<'a> + ?Sized,
|
||||
{
|
||||
let TypeParamParamSpec {
|
||||
name,
|
||||
default,
|
||||
range: _,
|
||||
node_index: _,
|
||||
} = self;
|
||||
visitor.visit_identifier(name);
|
||||
|
||||
if let Some(default) = default {
|
||||
visitor.visit_expr(default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -506,67 +506,6 @@ impl ast::TypeParams {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::TypeParamTypeVar {
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
V: SourceOrderVisitor<'a> + ?Sized,
|
||||
{
|
||||
let ast::TypeParamTypeVar {
|
||||
bound,
|
||||
default,
|
||||
name,
|
||||
range: _,
|
||||
node_index: _,
|
||||
} = self;
|
||||
|
||||
visitor.visit_identifier(name);
|
||||
if let Some(expr) = bound {
|
||||
visitor.visit_expr(expr);
|
||||
}
|
||||
if let Some(expr) = default {
|
||||
visitor.visit_expr(expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::TypeParamTypeVarTuple {
|
||||
#[inline]
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
V: SourceOrderVisitor<'a> + ?Sized,
|
||||
{
|
||||
let ast::TypeParamTypeVarTuple {
|
||||
range: _,
|
||||
node_index: _,
|
||||
name,
|
||||
default,
|
||||
} = self;
|
||||
visitor.visit_identifier(name);
|
||||
if let Some(expr) = default {
|
||||
visitor.visit_expr(expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::TypeParamParamSpec {
|
||||
#[inline]
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
V: SourceOrderVisitor<'a> + ?Sized,
|
||||
{
|
||||
let ast::TypeParamParamSpec {
|
||||
range: _,
|
||||
node_index: _,
|
||||
name,
|
||||
default,
|
||||
} = self;
|
||||
visitor.visit_identifier(name);
|
||||
if let Some(expr) = default {
|
||||
visitor.visit_expr(expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::FString {
|
||||
pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V)
|
||||
where
|
||||
|
|
|
|||
|
|
@ -2892,37 +2892,6 @@ impl TypeParam {
|
|||
}
|
||||
}
|
||||
|
||||
/// See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct TypeParamTypeVar {
|
||||
pub range: TextRange,
|
||||
pub node_index: AtomicNodeIndex,
|
||||
pub name: Identifier,
|
||||
pub bound: Option<Box<Expr>>,
|
||||
pub default: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
/// See also [ParamSpec](https://docs.python.org/3/library/ast.html#ast.ParamSpec)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct TypeParamParamSpec {
|
||||
pub range: TextRange,
|
||||
pub node_index: AtomicNodeIndex,
|
||||
pub name: Identifier,
|
||||
pub default: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
/// See also [TypeVarTuple](https://docs.python.org/3/library/ast.html#ast.TypeVarTuple)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
pub struct TypeParamTypeVarTuple {
|
||||
pub range: TextRange,
|
||||
pub node_index: AtomicNodeIndex,
|
||||
pub name: Identifier,
|
||||
pub default: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
/// See also [decorator](https://docs.python.org/3/library/ast.html#ast.decorator)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "get-size", derive(get_size2::GetSize))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue