1212"""
1313
1414from dataclasses import dataclass
15- from typing import Dict , Optional , Union
15+ from typing import Any , Dict , Optional , Union
1616
1717from sqlglot import exp
1818
@@ -88,7 +88,7 @@ def _classify_clause(key: str, parent_type: type) -> str:
8888# ---------------------------------------------------------------------------
8989
9090
91- def _dfs (node : exp .Expression ):
91+ def _dfs (node : exp .Expression ) -> Any :
9292 """Yield *node* and all its descendants in depth-first order.
9393
9494 :param node: Root expression node.
@@ -168,7 +168,7 @@ def add_column(self, name: str, clause: str) -> None:
168168 if clause :
169169 self .columns_dict .setdefault (clause , UniqueList ()).append (name )
170170
171- def add_alias (self , name : str , target , clause : str ) -> None :
171+ def add_alias (self , name : str , target : Any , clause : str ) -> None :
172172 """Record a column alias and its target expression."""
173173 self .alias_names .append (name )
174174 if clause :
@@ -335,7 +335,9 @@ def _is_star_inside_function(star: exp.Star) -> bool:
335335 # DFS walk
336336 # -------------------------------------------------------------------
337337
338- def _walk (self , node , clause : str = "" , depth : int = 0 ) -> None :
338+ def _walk (
339+ self , node : Optional [exp .Expression ], clause : str = "" , depth : int = 0
340+ ) -> None :
339341 """Depth-first walk of the AST in ``arg_types`` key order."""
340342 if node is None :
341343 return
@@ -346,7 +348,7 @@ def _walk(self, node, clause: str = "", depth: int = 0) -> None:
346348 if hasattr (node , "arg_types" ):
347349 self ._walk_children (node , clause , depth )
348350
349- def _walk_children (self , node , clause : str , depth : int ) -> None :
351+ def _walk_children (self , node : exp . Expression , clause : str , depth : int ) -> None :
350352 """Recurse into children of *node* in ``arg_types`` key order."""
351353 for key in node .arg_types :
352354 if key in _SKIP_KEYS :
@@ -360,7 +362,7 @@ def _walk_children(self, node, clause: str, depth: int) -> None:
360362 if not self ._process_child_key (node , key , child , new_clause , depth ):
361363 self ._recurse_child (child , new_clause , depth )
362364
363- def _dispatch_leaf (self , node , clause : str , depth : int ) -> bool :
365+ def _dispatch_leaf (self , node : exp . Expression , clause : str , depth : int ) -> bool :
364366 """Dispatch leaf-like AST nodes to their specialised handlers.
365367
366368 Returns ``True`` if handled (stop recursion), ``False`` to continue.
@@ -384,7 +386,7 @@ def _dispatch_leaf(self, node, clause: str, depth: int) -> bool:
384386 return False
385387
386388 def _process_child_key (
387- self , node , key : str , child , clause : str , depth : int
389+ self , node : exp . Expression , key : str , child : Any , clause : str , depth : int
388390 ) -> bool :
389391 """Handle special cases for SELECT expressions, INSERT schema, JOIN USING.
390392
@@ -401,7 +403,7 @@ def _process_child_key(
401403 return True
402404 return False
403405
404- def _recurse_child (self , child , clause : str , depth : int ) -> None :
406+ def _recurse_child (self , child : Any , clause : str , depth : int ) -> None :
405407 """Recursively walk a child value (single expression or list)."""
406408 if isinstance (child , list ):
407409 for item in child :
@@ -437,7 +439,7 @@ def _handle_insert_schema(self, node: exp.Insert) -> None:
437439 name = col_id .name if hasattr (col_id , "name" ) else str (col_id )
438440 self ._collector .add_column (name , "insert" )
439441
440- def _handle_join_using (self , child ) -> None :
442+ def _handle_join_using (self , child : Any ) -> None :
441443 """Extract column identifiers from a JOIN USING clause."""
442444 if isinstance (child , list ):
443445 for item in child :
@@ -473,7 +475,7 @@ def _handle_column(self, col: exp.Column, clause: str) -> None:
473475
474476 c .add_column (full , clause )
475477
476- def _handle_select_exprs (self , exprs , clause : str , depth : int ) -> None :
478+ def _handle_select_exprs (self , exprs : Any , clause : str , depth : int ) -> None :
477479 """Handle the expressions list of a SELECT clause."""
478480 if not isinstance (exprs , list ):
479481 return
0 commit comments