From 73f8127b0f3f094e63f30f06e96c11ca51811090 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Tue, 17 Jul 2012 15:24:39 +0200 Subject: [PATCH] Fix PEP8 errors reported by the new flake8 version (except E128, which we ignore for the time being) --- .travis.yml | 2 +- compressor/base.py | 2 +- compressor/contrib/jinja2ext.py | 2 +- compressor/templatetags/compress.py | 3 +-- compressor/tests/test_templatetags.py | 19 ++++++++----------- compressor/utils/stringformat.py | 3 +-- docs/conf.py | 7 ++++--- setup.py | 20 ++++++++------------ 8 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa68024..3fdc535 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - pip install -e . - pip install -r requirements/tests.txt Django==$DJANGO before_script: - - flake8 compressor --ignore=E501 + - flake8 compressor --ignore=E501,E128 script: - make test env: diff --git a/compressor/base.py b/compressor/base.py index d8c3634..e5b3404 100644 --- a/compressor/base.py +++ b/compressor/base.py @@ -113,7 +113,7 @@ class Compressor(object): return fd.read() except IOError, e: raise UncompressableFileError("IOError while processing " - "'%s': %s" % (filename, e)) + "'%s': %s" % (filename, e)) except UnicodeDecodeError, e: raise UncompressableFileError("UnicodeDecodeError while " "processing '%s' with " diff --git a/compressor/contrib/jinja2ext.py b/compressor/contrib/jinja2ext.py index ae4f731..baf76d5 100644 --- a/compressor/contrib/jinja2ext.py +++ b/compressor/contrib/jinja2ext.py @@ -19,7 +19,7 @@ class CompressorExtension(CompressorMixin, Extension): if args[0].value not in self.compressors: raise TemplateSyntaxError('compress kind may be one of: %s' % (', '.join(self.compressors.keys())), - lineno) + lineno) if parser.stream.skip_if('comma'): modearg = parser.parse_expression() # Allow mode to be defined as jinja2 name node diff --git a/compressor/templatetags/compress.py b/compressor/templatetags/compress.py index 47863ab..1a12198 100644 --- a/compressor/templatetags/compress.py +++ b/compressor/templatetags/compress.py @@ -91,8 +91,7 @@ class CompressorMixin(object): # Take a shortcut if we really don't have anything to do if ((not settings.COMPRESS_ENABLED and - not settings.COMPRESS_PRECOMPILERS) - and not forced): + not settings.COMPRESS_PRECOMPILERS) and not forced): return self.get_original_content(context) context['compressed'] = {'name': getattr(self, 'name', None)} diff --git a/compressor/tests/test_templatetags.py b/compressor/tests/test_templatetags.py index bafc521..f476893 100644 --- a/compressor/tests/test_templatetags.py +++ b/compressor/tests/test_templatetags.py @@ -219,10 +219,9 @@ class PrecompilerTemplatetagTestCase(TestCase): {% endcompress %}""" - out = '\n'.join([ - script(src="/media/CACHE/js/one.95cfb869eead.js"), - script(scripttype="", src="/media/js/one.js"), - script(src="/media/CACHE/js/one.81a2cd965815.js")]) + out = '\n'.join([script(src="/media/CACHE/js/one.95cfb869eead.js"), + script(scripttype="", src="/media/js/one.js"), + script(src="/media/CACHE/js/one.81a2cd965815.js")]) self.assertEqual(out, render(template, self.context)) finally: @@ -239,9 +238,8 @@ class PrecompilerTemplatetagTestCase(TestCase): {% endcompress %}""" - out = ''.join([ - '', - '']) + out = ''.join(['', + '']) self.assertEqual(out, render(template, self.context)) finally: @@ -259,10 +257,9 @@ class PrecompilerTemplatetagTestCase(TestCase): {% endcompress %}""" - out = ''.join([ - '', - '', - '']) + out = ''.join(['', + '', + '']) self.assertEqual(out, render(template, self.context)) finally: settings.COMPRESS_ENABLED = self.old_enabled diff --git a/compressor/utils/stringformat.py b/compressor/utils/stringformat.py index 812df04..0cfba86 100644 --- a/compressor/utils/stringformat.py +++ b/compressor/utils/stringformat.py @@ -61,8 +61,7 @@ def _strformat(value, format_spec=""): # TODO: thousand separator pass try: - if ((is_numeric and conversion == 's') or - (not is_integer and conversion in set('cdoxX'))): + if ((is_numeric and conversion == 's') or (not is_integer and conversion in set('cdoxX'))): raise ValueError if conversion == 'c': conversion = 's' diff --git a/docs/conf.py b/docs/conf.py index 4ed02a2..ffa6243 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,7 +11,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import sys +import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -182,8 +183,8 @@ htmlhelp_basename = 'django-compressordoc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'django-compressor.tex', u'Django Compressor Documentation', - u'Django Compressor authors', 'manual'), + ('index', 'django-compressor.tex', u'Django Compressor Documentation', + u'Django Compressor authors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/setup.py b/setup.py index 79eefad..a5deb25 100644 --- a/setup.py +++ b/setup.py @@ -32,12 +32,11 @@ standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', # Note: you may want to copy this into your setup.py file verbatim, as # you can't import this from another package, when you don't know if # that package is installed yet. -def find_package_data( - where='.', package='', - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): +def find_package_data(where='.', package='', + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -74,8 +73,7 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -84,8 +82,7 @@ def find_package_data( break if bad_name: continue - if (os.path.isfile(os.path.join(fn, '__init__.py')) - and not prefix): + if (os.path.isfile(os.path.join(fn, '__init__.py')) and not prefix): if not package: new_package = name else: @@ -97,8 +94,7 @@ def find_package_data( # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, (