From 80984bd29667e5365e728a7f9a94e2a93a1c27f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:01:09 -0700 Subject: [PATCH] Bump mako from 1.3.2 to 1.3.3 (#2303) * Bump mako from 1.3.2 to 1.3.3 Bumps [mako](https://github.com/sqlalchemy/mako) from 1.3.2 to 1.3.3. - [Release notes](https://github.com/sqlalchemy/mako/releases) - [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES) - [Commits](https://github.com/sqlalchemy/mako/commits) --- updated-dependencies: - dependency-name: mako dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update mako==1.3.3 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci] --- lib/mako/__init__.py | 2 +- lib/mako/codegen.py | 26 +++++++++++++++++++------- lib/mako/pyparser.py | 20 ++++++++++++++++++++ requirements.txt | 2 +- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/lib/mako/__init__.py b/lib/mako/__init__.py index d022cf82..5811e68c 100644 --- a/lib/mako/__init__.py +++ b/lib/mako/__init__.py @@ -5,4 +5,4 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php -__version__ = "1.3.2" +__version__ = "1.3.3" diff --git a/lib/mako/codegen.py b/lib/mako/codegen.py index ce6f83aa..b9fea937 100644 --- a/lib/mako/codegen.py +++ b/lib/mako/codegen.py @@ -838,13 +838,24 @@ class _GenerateRenderMethod: text = node.text self.printer.writeline(text) children = node.get_children() - # this covers the three situations where we want to insert a pass: - # 1) a ternary control line with no children, - # 2) a primary control line with nothing but its own ternary - # and end control lines, and - # 3) any control line with no content other than comments - if not children or ( - all( + + # this covers the four situations where we want to insert a pass: + # 1) a ternary control line with no children, + # 2) a primary control line with nothing but its own ternary + # and end control lines, and + # 3) any control line with no content other than comments + # 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)) for c in children ) @@ -853,6 +864,7 @@ class _GenerateRenderMethod: for c in children if isinstance(c, parsetree.ControlLine) ) + or _search_for_control_line() ): self.printer.writeline("pass") diff --git a/lib/mako/pyparser.py b/lib/mako/pyparser.py index 9b63dc33..b25ef6e4 100644 --- a/lib/mako/pyparser.py +++ b/lib/mako/pyparser.py @@ -90,6 +90,26 @@ class FindIdentifiers(_ast_util.NodeVisitor): self._add_declared(node.name) 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): for arg in args: if isinstance(arg, _ast.Tuple): diff --git a/requirements.txt b/requirements.txt index af94378a..8d9ca973 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ importlib-metadata==7.1.0 importlib-resources==6.4.0 git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois IPy==1.01 -Mako==1.3.2 +Mako==1.3.3 MarkupSafe==2.1.5 musicbrainzngs==0.7.1 packaging==24.0