mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-30 07:08:07 +00:00
New Singleton
enum for PatternMatchSingleton
node (#8063)
## Summary This PR adds a new `Singleton` enum for the `PatternMatchSingleton` node. Earlier the node was using the `Constant` enum but the value for this pattern can only be either `None`, `True` or `False`. With the coming PR to remove the `Constant`, this node required a new type to fill in. This also has the benefit of narrowing the type down to only the possible values for the node as evident by the removal of `unreachable`. ## Test Plan Update the AST snapshots and run `cargo test`.
This commit is contained in:
parent
ee7d445ef5
commit
78bbf6d403
10 changed files with 70 additions and 28 deletions
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
Alias, Arguments, BoolOp, CmpOp, Comprehension, Constant, Decorator, ElifElseClause,
|
||||
ExceptHandler, Expr, Keyword, MatchCase, Mod, Operator, Parameter, ParameterWithDefault,
|
||||
Parameters, Pattern, PatternArguments, PatternKeyword, Stmt, TypeParam, TypeParams, UnaryOp,
|
||||
WithItem,
|
||||
Parameters, Pattern, PatternArguments, PatternKeyword, Singleton, Stmt, TypeParam, TypeParams,
|
||||
UnaryOp, WithItem,
|
||||
};
|
||||
use crate::{AnyNodeRef, AstNode};
|
||||
|
||||
|
@ -44,6 +44,9 @@ pub trait PreorderVisitor<'a> {
|
|||
#[inline]
|
||||
fn visit_constant(&mut self, _constant: &'a Constant) {}
|
||||
|
||||
#[inline]
|
||||
fn visit_singleton(&mut self, _singleton: &'a Singleton) {}
|
||||
|
||||
#[inline]
|
||||
fn visit_bool_op(&mut self, bool_op: &'a BoolOp) {
|
||||
walk_bool_op(self, bool_op);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue