diff options
| author | Adam Johnson <me@adamj.eu> | 2022-04-27 07:10:21 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-05-18 05:57:28 +0200 |
| commit | 4e73d8c04d15f9cbae067249c7ff39dec9d66eb1 (patch) | |
| tree | e6a0ecc29d4bde203e3baa359639909bf9f25b29 /django/template/base.py | |
| parent | 4a5753fb0af28967c9ad6a5be8966cdbd933ad64 (diff) | |
Avoided parallel assignment in template classes.
Diffstat (limited to 'django/template/base.py')
| -rw-r--r-- | django/template/base.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/django/template/base.py b/django/template/base.py index e83db6185c..4762d20516 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -307,7 +307,8 @@ class Token: The line number the token appears on in the template source. This is used for traceback information and gettext files. """ - self.token_type, self.contents = token_type, contents + self.token_type = token_type + self.contents = contents self.lineno = lineno self.position = position @@ -671,13 +672,12 @@ class FilterExpression: "%s|%s|%s" % (token[:upto], token[upto:start], token[start:]) ) if var_obj is None: - var, constant = match["var"], match["constant"] - if constant: + if constant := match["constant"]: try: var_obj = Variable(constant).resolve({}) except VariableDoesNotExist: var_obj = None - elif var is None: + elif (var := match["var"]) is None: raise TemplateSyntaxError( "Could not find variable at start of %s." % token ) @@ -686,10 +686,9 @@ class FilterExpression: else: filter_name = match["filter_name"] args = [] - constant_arg, var_arg = match["constant_arg"], match["var_arg"] - if constant_arg: + if constant_arg := match["constant_arg"]: args.append((False, Variable(constant_arg).resolve({}))) - elif var_arg: + elif var_arg := match["var_arg"]: args.append((True, Variable(var_arg))) filter_func = parser.find_filter(filter_name) self.args_check(filter_name, filter_func, args) |
