BOM-2374
Run Pyupgrade on edxmako.
This commit is contained in:
@@ -5,6 +5,7 @@ Configuration for the edxmako Django application.
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.conf import settings
|
||||
|
||||
from . import add_lookup, clear_lookups
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Mako(BaseEngine):
|
||||
"""
|
||||
params = params.copy()
|
||||
options = params.pop('OPTIONS').copy()
|
||||
super(Mako, self).__init__(params) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().__init__(params)
|
||||
self.context_processors = options.pop('context_processors', [])
|
||||
self.namespace = options.pop('namespace', 'main')
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.template import Engine, engines, TemplateDoesNotExist
|
||||
from django.template import Engine, TemplateDoesNotExist, engines
|
||||
from django.template.loaders.app_directories import Loader as AppDirectoriesLoader
|
||||
from django.template.loaders.filesystem import Loader as FilesystemLoader
|
||||
|
||||
@@ -14,7 +14,7 @@ from openedx.core.lib.tempdir import mkdtemp_clean
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MakoLoader(object):
|
||||
class MakoLoader:
|
||||
"""
|
||||
This is a Django loader object which will load the template as a
|
||||
Mako template if the first line is "## mako". It is based off Loader
|
||||
|
||||
@@ -6,9 +6,9 @@ Set up lookup paths for mako templates.
|
||||
import contextlib
|
||||
import hashlib
|
||||
import os
|
||||
import six
|
||||
|
||||
import pkg_resources
|
||||
import six
|
||||
from django.conf import settings
|
||||
from mako.exceptions import TopLevelLookupException
|
||||
from mako.lookup import TemplateLookup
|
||||
@@ -19,7 +19,7 @@ from openedx.core.lib.cache_utils import request_cached
|
||||
from . import LOOKUP
|
||||
|
||||
|
||||
class TopLevelTemplateURI(six.text_type):
|
||||
class TopLevelTemplateURI(str):
|
||||
"""
|
||||
A marker class for template URIs used to signal the template lookup infrastructure that the template corresponding
|
||||
to the URI should be looked up straight in the standard edx-platform location instead of trying to locate an
|
||||
@@ -34,7 +34,7 @@ class DynamicTemplateLookup(TemplateLookup):
|
||||
for adding directories progressively.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DynamicTemplateLookup, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().__init__(*args, **kwargs)
|
||||
self.__original_module_directory = self.template_args['module_directory']
|
||||
|
||||
def __repr__(self):
|
||||
@@ -74,7 +74,7 @@ class DynamicTemplateLookup(TemplateLookup):
|
||||
that template lookup skips the current theme and looks up the built-in template in standard locations.
|
||||
"""
|
||||
# Make requested uri relative to the calling uri.
|
||||
relative_uri = super(DynamicTemplateLookup, self).adjust_uri(uri, relativeto) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
relative_uri = super().adjust_uri(uri, relativeto)
|
||||
# Is the calling template (relativeto) which is including or inheriting current template (uri)
|
||||
# located inside a theme?
|
||||
if relativeto != strip_site_theme_templates_path(relativeto):
|
||||
@@ -99,7 +99,7 @@ class DynamicTemplateLookup(TemplateLookup):
|
||||
else:
|
||||
try:
|
||||
# Try to find themed template, i.e. see if current theme overrides the template
|
||||
template = super(DynamicTemplateLookup, self).get_template(get_template_path_with_theme(uri)) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
template = super().get_template(get_template_path_with_theme(uri))
|
||||
except TopLevelLookupException:
|
||||
template = self._get_toplevel_template(uri)
|
||||
|
||||
@@ -110,7 +110,7 @@ class DynamicTemplateLookup(TemplateLookup):
|
||||
Lookup a default/toplevel template, ignoring current theme.
|
||||
"""
|
||||
# Strip off the prefix path to theme and look in default template dirs.
|
||||
return super(DynamicTemplateLookup, self).get_template(strip_site_theme_templates_path(uri)) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
return super().get_template(strip_site_theme_templates_path(uri))
|
||||
|
||||
|
||||
def clear_lookups(namespace):
|
||||
|
||||
@@ -21,8 +21,8 @@ Methods for creating RequestContext for using with Mako templates.
|
||||
|
||||
from crum import get_current_request
|
||||
from django.template import RequestContext
|
||||
|
||||
from edx_django_utils.cache import RequestCache
|
||||
|
||||
from openedx.core.lib.request_utils import safe_get_host
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ from django.conf import settings
|
||||
from django.template import Context, engines, Origin
|
||||
from edx_django_utils.cache import RequestCache
|
||||
from mako.template import Template as MakoTemplate
|
||||
from six import text_type
|
||||
|
||||
from . import Engines, LOOKUP
|
||||
from .request_context import get_template_request_context
|
||||
@@ -122,4 +121,4 @@ class Template(object):
|
||||
"""
|
||||
for key in KEY_CSRF_TOKENS:
|
||||
if key in context_dictionary:
|
||||
context_dictionary[key] = text_type(context_dictionary[key])
|
||||
context_dictionary[key] = str(context_dictionary[key])
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# lint-amnesty, pylint: disable=cyclic-import, missing-module-docstring
|
||||
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import ddt
|
||||
from django.conf import settings
|
||||
@@ -10,7 +11,6 @@ from django.test.client import RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from edx_django_utils.cache import RequestCache
|
||||
from mock import Mock, patch
|
||||
|
||||
from common.djangoapps.edxmako import LOOKUP, add_lookup
|
||||
from common.djangoapps.edxmako.request_context import get_template_request_context
|
||||
@@ -139,7 +139,7 @@ class MakoRequestContextTest(TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(MakoRequestContextTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
super().setUp()
|
||||
self.user = UserFactory.create()
|
||||
self.url = "/"
|
||||
self.request = RequestFactory().get(self.url)
|
||||
|
||||
Reference in New Issue
Block a user