1- # Copyright (C) 2018, 2020, 2023 Rocky Bernstein <rocky@gnu.org>
1+ # Copyright (C) 2018, 2020, 2023, 2026 Rocky Bernstein <rocky@gnu.org>
22#
33# This program is free software: you can redistribute it and/or modify
44# it under the terms of the GNU General Public License as published by
1313# You should have received a copy of the GNU General Public License
1414# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515import sys
16+ from typing import Any
1617
1718
18- def maybe_show_asm (showasm , tokens ) :
19+ def maybe_show_asm (showasm : Any , tokens : list ) -> None :
1920 """
2021 Show the asm based on the showasm flag (or file object), writing to the
2122 appropriate stream depending on the type of the flag.
@@ -32,15 +33,15 @@ def maybe_show_asm(showasm, tokens):
3233 stream .write ("\n " )
3334
3435
35- def maybe_show_tree (walker , ast ) :
36+ def maybe_show_tree (walker , tree ) -> None :
3637 """
37- Show the ast based on the showast flag (or file object), writing to the
38+ Show the tree based on the tree flag (or file object), writing to the
3839 appropriate stream depending on the type of the flag.
3940
4041 :param show_tree: Flag which determines whether the parse tree is
4142 written to sys.stdout or not. (It is also to pass a file
4243 like object, into which the ast will be written).
43- :param ast : The ast to show.
44+ :param tree : The tree to show.
4445 """
4546 if walker .showast :
4647 if hasattr (walker .showast , "write" ):
@@ -51,14 +52,15 @@ def maybe_show_tree(walker, ast):
5152 isinstance (walker .showast , dict )
5253 and walker .showast .get ("after" , False )
5354 and hasattr (walker , "str_with_template" )
55+ and walker .str_with_template
5456 ):
55- walker .str_with_template (ast )
57+ walker .str_with_template (tree )
5658 else :
57- stream .write (str (ast ))
59+ stream .write (str (tree ))
5860 stream .write ("\n " )
5961
6062
61- def maybe_show_tree_param_default (show_tree , name , default ):
63+ def maybe_show_tree_param_default (show_tree , name : str , default ):
6264 """
6365 Show a function parameter with default for an grammar-tree based on the show_tree flag
6466 (or file object), writing to the appropriate stream depending on the type
0 commit comments