Skip to content

Commit 54ccf68

Browse files
authored
Upgrade syntax to Python 3 using pyupgrade (#787)
1 parent b4ba452 commit 54ccf68

23 files changed

+94
-105
lines changed

docs/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
master_doc = 'index'
3838

3939
# General information about the project.
40-
project = u'django-pipeline'
41-
copyright = u'2011-2014, Timothée Peignier'
40+
project = 'django-pipeline'
41+
copyright = '2011-2014, Timothée Peignier'
4242

4343
# The version info for the project you're documenting, acts as replacement for
4444
# |version| and |release|, also used in various other places throughout the
@@ -175,8 +175,8 @@
175175
# Grouping the document tree into LaTeX files. List of tuples
176176
# (source start file, target name, title, author, documentclass [howto/manual]).
177177
latex_documents = [
178-
('index', 'django-pipeline.tex', u'Pipeline Documentation',
179-
u'Timothée Peignier', 'manual'),
178+
('index', 'django-pipeline.tex', 'Pipeline Documentation',
179+
'Timothée Peignier', 'manual'),
180180
]
181181

182182
# The name of an image file (relative to this directory) to place at the top of
@@ -208,6 +208,6 @@
208208
# One entry per manual page. List of tuples
209209
# (source start file, name, description, authors, manual section).
210210
man_pages = [
211-
('index', 'django-pipeline', u'Pipeline Documentation',
212-
[u'Timothée Peignier'], 1)
211+
('index', 'django-pipeline', 'Pipeline Documentation',
212+
['Timothée Peignier'], 1)
213213
]

pipeline/collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pipeline.finders import PipelineFinder
99

1010

11-
class Collector(object):
11+
class Collector:
1212
request = None
1313

1414
def __init__(self, storage=None):

pipeline/compilers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pipeline.utils import set_std_streams_blocking, to_class
1414

1515

16-
class Compiler(object):
16+
class Compiler:
1717
def __init__(self, storage=None, verbose=False):
1818
if storage is None:
1919
storage = staticfiles_storage
@@ -56,7 +56,7 @@ def _compile(input_path):
5656
return list(executor.map(_compile, paths))
5757

5858

59-
class CompilerBase(object):
59+
class CompilerBase:
6060
def __init__(self, verbose, storage):
6161
self.verbose = verbose
6262
self.storage = storage

pipeline/compressors/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
FONT_EXTS = ['.ttf', '.otf', '.woff']
3535

3636

37-
class Compressor(object):
37+
class Compressor:
3838
asset_contents = {}
3939

4040
def __init__(self, storage=None, verbose=False):
@@ -90,7 +90,7 @@ def compile_templates(self, paths):
9090
contents = re.sub("\r?\n", "\\\\n", contents)
9191
contents = re.sub("'", "\\'", contents)
9292
name = self.template_name(path, base_path)
93-
compiled.append("%s['%s'] = %s('%s');\n" % (
93+
compiled.append("{}['{}'] = {}('{}');\n".format(
9494
namespace,
9595
name,
9696
settings.TEMPLATE_FUNC,
@@ -101,7 +101,7 @@ def compile_templates(self, paths):
101101
else:
102102
compiler = ""
103103
return "\n".join([
104-
"%(namespace)s = %(namespace)s || {};" % {'namespace': namespace},
104+
"{namespace} = {namespace} || {{}};".format(namespace=namespace),
105105
compiler,
106106
''.join(compiled)
107107
])
@@ -118,7 +118,7 @@ def template_name(self, path, base):
118118
path = os.path.basename(path)
119119
if path == base:
120120
base = os.path.dirname(path)
121-
name = re.sub(r"^%s[\/\\]?(.*)%s$" % (
121+
name = re.sub(r"^{}[\/\\]?(.*){}$".format(
122122
re.escape(base), re.escape(settings.TEMPLATE_EXT)
123123
), r"\1", path)
124124
return re.sub(r"[\/\\]", settings.TEMPLATE_SEPARATOR, name)
@@ -228,7 +228,7 @@ def read_text(self, path):
228228
return force_str(content)
229229

230230

231-
class CompressorBase(object):
231+
class CompressorBase:
232232
def __init__(self, verbose):
233233
self.verbose = verbose
234234

pipeline/compressors/terser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
from pipeline.compressors import SubProcessCompressor
42
from pipeline.conf import settings
53

pipeline/exceptions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
class PipelineException(Exception):
42
pass
53

@@ -10,7 +8,7 @@ class PackageNotFound(PipelineException):
108

119
class CompilerError(PipelineException):
1210
def __init__(self, msg, command=None, error_output=None):
13-
super(CompilerError, self).__init__(msg)
11+
super().__init__(msg)
1412

1513
self.command = command
1614
self.error_output = error_output.strip()

pipeline/finders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PipelineFinder(BaseStorageFinder):
1818

1919
def find(self, path, all=False):
2020
if not settings.PIPELINE_ENABLED:
21-
return super(PipelineFinder, self).find(path, all)
21+
return super().find(path, all)
2222
else:
2323
return []
2424

@@ -60,7 +60,7 @@ def list(self, *args):
6060
return []
6161

6262

63-
class PatternFilterMixin(object):
63+
class PatternFilterMixin:
6464
ignore_patterns = []
6565

6666
def get_ignored_patterns(self):
@@ -69,7 +69,7 @@ def get_ignored_patterns(self):
6969
def list(self, ignore_patterns):
7070
if ignore_patterns:
7171
ignore_patterns = ignore_patterns + self.get_ignored_patterns()
72-
return super(PatternFilterMixin, self).list(ignore_patterns)
72+
return super().list(ignore_patterns)
7373

7474

7575
class AppDirectoriesFinder(PatternFilterMixin, DjangoAppDirectoriesFinder):

pipeline/forms.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .packager import Packager
99

1010

11-
class PipelineFormMediaProperty(object):
11+
class PipelineFormMediaProperty:
1212
"""A property that converts Pipeline packages to lists of files.
1313
1414
This is used behind the scenes for any Media classes that subclass
@@ -122,7 +122,7 @@ def __new__(cls, name, bases, attrs):
122122
type:
123123
The new class.
124124
"""
125-
new_class = super(PipelineFormMediaMetaClass, cls).__new__(
125+
new_class = super().__new__(
126126
cls, name, bases, attrs)
127127

128128
# If we define any packages, we'll need to use our special
@@ -158,15 +158,15 @@ def _get_css_files(cls, extra_files):
158158
packager = Packager()
159159
css_packages = getattr(cls, 'css_packages', {})
160160

161-
return dict(
162-
(media_target,
163-
cls._get_media_files(packager=packager,
164-
media_packages=media_packages,
165-
media_type='css',
166-
extra_files=extra_files.get(media_target,
167-
[])))
161+
return {
162+
media_target: cls._get_media_files(
163+
packager=packager,
164+
media_packages=media_packages,
165+
media_type='css',
166+
extra_files=extra_files.get(media_target, []),
167+
)
168168
for media_target, media_packages in css_packages.items()
169-
)
169+
}
170170

171171
def _get_js_files(cls, extra_files):
172172
"""Return all JavaScript files from the Media class.
@@ -229,7 +229,7 @@ def _get_media_files(cls, packager, media_packages, media_type,
229229
return source_files
230230

231231

232-
class PipelineFormMedia(object, metaclass=PipelineFormMediaMetaClass):
232+
class PipelineFormMedia(metaclass=PipelineFormMediaMetaClass):
233233
"""Base class for form or widget Media classes that use Pipeline packages.
234234
235235
Forms or widgets that need custom CSS or JavaScript media on a page can

pipeline/jinja2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class PipelineExtension(PipelineMixin, Extension):
11-
tags = set(['stylesheet', 'javascript'])
11+
tags = {'stylesheet', 'javascript'}
1212

1313
def parse(self, parser):
1414
tag = next(parser.stream)

pipeline/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class MinifyHTMLMiddleware(MiddlewareMixin):
1010
def __init__(self, *args, **kwargs):
11-
super(MinifyHTMLMiddleware, self).__init__(*args, **kwargs)
11+
super().__init__(*args, **kwargs)
1212
if not settings.PIPELINE_ENABLED:
1313
raise MiddlewareNotUsed
1414

0 commit comments

Comments
 (0)