mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-31 03:55:09 +00:00 
			
		
		
		
	Remove AstNode and AnyNode (#15479)
				
					
				
			While looking into potential AST optimizations, I noticed the `AstNode` trait and `AnyNode` type aren't used anywhere in Ruff or Red Knot. It looks like they might be historical artifacts of previous ways of consuming AST nodes? - `AstNode::cast`, `AstNode::cast_ref`, and `AstNode::can_cast` are not used anywhere. - Since `cast_ref` isn't needed anymore, the `Ref` associated type isn't either. This is a pure refactoring, with no intended behavior changes.
This commit is contained in:
		
							parent
							
								
									8e3633f55a
								
							
						
					
					
						commit
						98ef564170
					
				
					 24 changed files with 52 additions and 5349 deletions
				
			
		|  | @ -1,6 +1,5 @@ | |||
| use ruff_formatter::{format_args, write, FormatContext, FormatError}; | ||||
| use ruff_python_ast::StmtWith; | ||||
| use ruff_python_ast::{AstNode, WithItem}; | ||||
| use ruff_python_ast::{StmtWith, WithItem}; | ||||
| use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; | ||||
| use ruff_text_size::{Ranged, TextRange}; | ||||
| 
 | ||||
|  | @ -36,7 +35,7 @@ impl FormatNodeRule<StmtWith> for FormatStmtWith { | |||
|         //     ...
 | ||||
|         // ```
 | ||||
|         let comments = f.context().comments().clone(); | ||||
|         let dangling_comments = comments.dangling(with_stmt.as_any_node_ref()); | ||||
|         let dangling_comments = comments.dangling(with_stmt); | ||||
|         let partition_point = dangling_comments.partition_point(|comment| { | ||||
|             with_stmt | ||||
|                 .items | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Douglas Creager
						Douglas Creager