Update mako==1.3.3

This commit is contained in:
JonnyWong16 2024-04-18 12:59:09 -07:00
commit 6731a4cff0
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 40 additions and 8 deletions

View file

@ -5,4 +5,4 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php # the MIT License: http://www.opensource.org/licenses/mit-license.php
__version__ = "1.3.2" __version__ = "1.3.3"

View file

@ -838,13 +838,24 @@ class _GenerateRenderMethod:
text = node.text text = node.text
self.printer.writeline(text) self.printer.writeline(text)
children = node.get_children() children = node.get_children()
# this covers the three situations where we want to insert a pass:
# 1) a ternary control line with no children, # this covers the four situations where we want to insert a pass:
# 2) a primary control line with nothing but its own ternary # 1) a ternary control line with no children,
# and end control lines, and # 2) a primary control line with nothing but its own ternary
# 3) any control line with no content other than comments # and end control lines, and
if not children or ( # 3) any control line with no content other than comments
all( # 4) the first control block with no content other than comments
def _search_for_control_line():
for c in children:
if isinstance(c, parsetree.Comment):
continue
elif isinstance(c, parsetree.ControlLine):
return True
return False
if (
not children
or all(
isinstance(c, (parsetree.Comment, parsetree.ControlLine)) isinstance(c, (parsetree.Comment, parsetree.ControlLine))
for c in children for c in children
) )
@ -853,6 +864,7 @@ class _GenerateRenderMethod:
for c in children for c in children
if isinstance(c, parsetree.ControlLine) if isinstance(c, parsetree.ControlLine)
) )
or _search_for_control_line()
): ):
self.printer.writeline("pass") self.printer.writeline("pass")

View file

@ -90,6 +90,26 @@ class FindIdentifiers(_ast_util.NodeVisitor):
self._add_declared(node.name) self._add_declared(node.name)
self._visit_function(node, False) self._visit_function(node, False)
def visit_ListComp(self, node):
if self.in_function:
if not isinstance(node.elt, _ast.Name):
self.visit(node.elt)
for comp in node.generators:
self.visit(comp.iter)
else:
self.generic_visit(node)
visit_SetComp = visit_GeneratorExp = visit_ListComp
def visit_DictComp(self, node):
if self.in_function:
if not isinstance(node.key, _ast.Name):
self.visit(node.elt)
for comp in node.generators:
self.visit(comp.iter)
else:
self.generic_visit(node)
def _expand_tuples(self, args): def _expand_tuples(self, args):
for arg in args: for arg in args:
if isinstance(arg, _ast.Tuple): if isinstance(arg, _ast.Tuple):