summaryrefslogtreecommitdiff
path: root/mako/pyparser.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2021-09-13 23:09:06 +0200
committerFederico Caselli <cfederico87@gmail.com>2021-10-23 11:11:48 +0200
commita1d70afb5974125a1a65f590418c7c371bbdb3e6 (patch)
tree0f4d4ef4170e963aa6784a222e192d16ba753e21 /mako/pyparser.py
parent09cf4f68a7f7f63c2f249d61d7cc6600afe12c1a (diff)
downloadmako-workflow_test_initial_1_2.tar.gz
- remove python 2 support - add github workflows - remove disable unicode - cleanup compat file - modernize setup - use pep517 Change-Id: Ic38dbf478046cec5d0815b468f0c235b4ea5e20c
Diffstat (limited to 'mako/pyparser.py')
-rw-r--r--mako/pyparser.py51
1 files changed, 17 insertions, 34 deletions
diff --git a/mako/pyparser.py b/mako/pyparser.py
index b16672d..b441132 100644
--- a/mako/pyparser.py
+++ b/mako/pyparser.py
@@ -20,20 +20,12 @@ from mako import exceptions
from mako import util
from mako.compat import arg_stringname
-if compat.py3k:
- # words that cannot be assigned to (notably
- # smaller than the total keys in __builtins__)
- reserved = set(["True", "False", "None", "print"])
+# words that cannot be assigned to (notably
+# smaller than the total keys in __builtins__)
+reserved = set(["True", "False", "None", "print"])
- # the "id" attribute on a function node
- arg_id = operator.attrgetter("arg")
-else:
- # words that cannot be assigned to (notably
- # smaller than the total keys in __builtins__)
- reserved = set(["True", "False", "None"])
-
- # the "id" attribute on a function node
- arg_id = operator.attrgetter("id")
+# the "id" attribute on a function node
+arg_id = operator.attrgetter("arg")
util.restore__ast(_ast)
@@ -85,18 +77,16 @@ class FindIdentifiers(_ast_util.NodeVisitor):
self.visit(n)
self.in_assign_targets = in_a
- if compat.py3k:
-
- # ExceptHandler is in Python 2, but this block only works in
- # Python 3 (and is required there)
+ # ExceptHandler is in Python 2, but this block only works in
+ # Python 3 (and is required there)
- def visit_ExceptHandler(self, node):
- if node.name is not None:
- self._add_declared(node.name)
- if node.type is not None:
- self.visit(node.type)
- for statement in node.body:
- self.visit(statement)
+ def visit_ExceptHandler(self, node):
+ if node.name is not None:
+ self._add_declared(node.name)
+ if node.type is not None:
+ self.visit(node.type)
+ for statement in node.body:
+ self.visit(statement)
def visit_Lambda(self, node, *args):
self._visit_function(node, True)
@@ -215,25 +205,18 @@ class ParseFunc(_ast_util.NodeVisitor):
if node.args.vararg:
argnames.append(arg_stringname(node.args.vararg))
- if compat.py2k:
- # kw-only args don't exist in Python 2
- kwargnames = []
- else:
- kwargnames = [arg_id(arg) for arg in node.args.kwonlyargs]
+ kwargnames = [arg_id(arg) for arg in node.args.kwonlyargs]
if node.args.kwarg:
kwargnames.append(arg_stringname(node.args.kwarg))
self.listener.argnames = argnames
self.listener.defaults = node.args.defaults # ast
self.listener.kwargnames = kwargnames
- if compat.py2k:
- self.listener.kwdefaults = []
- else:
- self.listener.kwdefaults = node.args.kw_defaults
+ self.listener.kwdefaults = node.args.kw_defaults
self.listener.varargs = node.args.vararg
self.listener.kwargs = node.args.kwarg
-class ExpressionGenerator(object):
+class ExpressionGenerator:
def __init__(self, astnode):
self.generator = _ast_util.SourceGenerator(" " * 4)
self.generator.visit(astnode)