From 70707e2fc7d57ea9b4e332fe19ec43c671e812a3 Mon Sep 17 00:00:00 2001 From: sanjeevholla26 Date: Sat, 7 Sep 2024 10:32:11 +0530 Subject: [PATCH] Refs #35738 -- Refactored code to meet the standards. --- django/template/base.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/django/template/base.py b/django/template/base.py index bc272c9c7f..12cfa1eb22 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -54,7 +54,6 @@ import inspect import logging import re import warnings -from django.utils.deprecation import RemovedInDjango61Warning from enum import Enum from django.template.context import BaseContext @@ -65,6 +64,7 @@ from django.utils.safestring import SafeData, SafeString, mark_safe from django.utils.text import get_text_list, smart_split, unescape_string_literal from django.utils.timezone import template_localtime from django.utils.translation import gettext_lazy, pgettext_lazy +from django.utils.deprecation import RemovedInDjango61Warning from .exceptions import TemplateSyntaxError @@ -488,7 +488,9 @@ class Parser: token, "Empty variable tag on line %d" % token.lineno ) try: - filter_expression = self.compile_filter(token.contents, token.lineno) + filter_expression = self.compile_filter( + token.contents, token.lineno + ) except TemplateSyntaxError as e: raise self.error(token, e) var_node = VariableNode(filter_expression) @@ -700,7 +702,9 @@ class FilterExpression: filter_name = match["filter_name"] args = [] if constant_arg := match["constant_arg"]: - args.append((False, Variable(constant_arg, self.lineno).resolve({}))) + args.append( + (False, Variable(constant_arg, self.lineno).resolve({})) + ) elif var_arg := match["var_arg"]: args.append((True, Variable(var_arg, self.lineno))) filter_func = parser.find_filter(filter_name) @@ -857,7 +861,7 @@ class Variable: f"Double-dot lookup (e.g., '{{{{ {var} }}}}') in template {engine.current_template_name}[{self.lineno}] " "is deprecated.", RemovedInDjango61Warning, - stacklevel=2 + stacklevel=2, ) def resolve(self, context):