]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Add flake8 pre-commit hook and apply fixes. 366/head
authorLukas Balaga <lukas.balaga@gmail.com>
Tue, 8 Mar 2016 05:15:37 +0000 (21:15 -0800)
committerLukas Balaga <lukas.balaga@gmail.com>
Tue, 8 Mar 2016 05:29:21 +0000 (21:29 -0800)
.pre-commit-config.yaml
babel/core.py
babel/messages/pofile.py
babel/numbers.py
babel/util.py
scripts/make-release.py
tests/messages/test_catalog.py
tests/test_core.py
tests/test_dates.py
tests/test_localedata.py
tox.ini

index f2263477941e939b1f3fd6860a6f3f2a60c98a38..1fd8b5cb572a2138e457ee1069d8cdcf4b384953 100644 (file)
@@ -1,17 +1,19 @@
 -   repo: https://github.com/pre-commit/pre-commit-hooks
     sha: 97b88d9610bcc03982ddac33caba98bb2b751f5f
     hooks:
-    -   id: trailing-whitespace
-    -   id: end-of-file-fixer
     -   id: autopep8-wrapper
         exclude: (docs/conf.py|tests/messages/data/)
+    -   id: check-added-large-files
     -   id: check-docstring-first
         exclude: (docs/conf.py)
     -   id: check-json
-    -   id: check-added-large-files
     -   id: check-yaml
     -   id: debug-statements
+    -   id: end-of-file-fixer
+    -   id: flake8
+        exclude: (docs/conf.py|babel/messages/__init__.py|babel/__init__.py|babel/_compat.py|tests/messages/data|scripts/import_cldr.py)
     -   id: name-tests-test
         args: ['--django']
         exclude: (tests/messages/data/)
     -   id: requirements-txt-fixer
+    -   id: trailing-whitespace
index 8764360ab7aec382acafba6d7bd5172f43823411..482e7ab96c99185170740565ef2d4ca2f99f0c9a 100644 (file)
@@ -469,7 +469,7 @@ class Locale(object):
         :type: `unicode`"""
         return self.get_display_name(Locale('en'))
 
-    #{ General Locale Display Names
+    # { General Locale Display Names
 
     @property
     def languages(self):
@@ -516,7 +516,7 @@ class Locale(object):
         """
         return self._data['variants']
 
-    #{ Number Formatting
+    # { Number Formatting
 
     @property
     def currencies(self):
@@ -605,7 +605,7 @@ class Locale(object):
         """
         return self._data['scientific_formats']
 
-    #{ Calendar Information and Date Formatting
+    # { Calendar Information and Date Formatting
 
     @property
     def periods(self):
index 00a21f49f9fbe834897e7e9b28a58ad880a9176d..a775ec049afa5a0d0f9277828c42963153e69d5c 100644 (file)
@@ -339,7 +339,7 @@ def normalize(string, prefix='', width=76):
     if lines and not lines[-1]:
         del lines[-1]
         lines[-1] += '\n'
-    return u'""\n' + u'\n'.join([(prefix + escape(l)) for l in lines])
+    return u'""\n' + u'\n'.join([(prefix + escape(line)) for line in lines])
 
 
 def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False,
index c4a2b20310da68a99ad444172a3d75439bd1913f..3ab366cccb14cdd8c4eec1934f80a6dd8e9926d5 100644 (file)
@@ -676,7 +676,6 @@ class NumberPattern(object):
             value += ('0' * (min - len(value)))
         if max == 0 or (min == 0 and int(value) == 0):
             return ''
-        width = len(value)
         while len(value) > min and value[-1] == '0':
             value = value[:-1]
         return get_decimal_symbol(locale) + value
index c0a94172c5dc36c27f3680f7c8074c8c5c3e6074..aeb9a5fab0293a17fe3ffcc8b33da83a152c12be 100644 (file)
@@ -15,6 +15,8 @@ import os
 import re
 import textwrap
 from babel._compat import izip, imap
+import pytz as _pytz
+from babel import localtime
 
 missing = object()
 
@@ -261,9 +263,6 @@ class FixedOffsetTimezone(tzinfo):
         return ZERO
 
 
-import pytz as _pytz
-from babel import localtime
-
 # Export the localtime functionality here because that's
 # where it was in the past.
 UTC = _pytz.utc
index a695da2e90f784f1fb950f96c5e45eb2d5a6eb49..7477ad387d2aff83f4e984faa92145e39e2518de 100755 (executable)
@@ -26,7 +26,6 @@ def parse_changelog():
             match = re.search('^Version\s+(.*)', line.strip())
             if match is None:
                 continue
-            length = len(match.group(1))
             version = match.group(1).strip()
             if lineiter.next().count('-') != len(match.group(0)):
                 continue
index 5194a783acb911cff944835d513c12c7be451c1f..f16a4dcb7746ba2c57dbebc2a7cd0558e058513e 100644 (file)
@@ -456,7 +456,7 @@ def test_catalog_update():
     assert msg3.string == (u'Salat', u'Salate')
     assert msg3.locations == [('util.py', 42)]
 
-    assert not 'head' in cat
+    assert 'head' not in cat
     assert list(cat.obsolete.values())[0].id == 'head'
 
     cat.update(template, update_header_comment=True)
index b9de4cbe6fcde799df135206ec2158c64da92073..29081f0797a0615e7774cc2ab7ce722961f331ba 100644 (file)
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://babel.edgewall.org/log/.
 
-import doctest
-import unittest
 import pytest
 
-from babel import core, Locale
+from babel import core
 from babel.core import default_locale, Locale
 
 
@@ -41,7 +39,7 @@ def test_locale_comparison():
     assert en_US == en_US_2
     assert en_US != fi_FI
     assert not (en_US != en_US_2)
-    assert None != en_US
+    assert en_US is not None
     assert en_US != bad_en_US
     assert fi_FI != bad_en_US
 
index ca1faf0a94c1f14c3ec712f6dd6af0fdb994d15c..d99baf30857fe4fd2924a88e79b2557ee2add602 100644 (file)
@@ -13,7 +13,6 @@
 
 import calendar
 from datetime import date, datetime, time, timedelta
-import types
 import unittest
 
 from pytz import timezone
@@ -161,7 +160,7 @@ class DateTimeFormatTestCase(unittest.TestCase):
         self.assertEqual('4', fmt['c'])  # friday is first day of week
 
     def test_pattern_day_of_week(self):
-        dt = datetime(2016,2,6)
+        dt = datetime(2016, 2, 6)
         fmt = dates.DateTimeFormat(dt, locale='en_US')
         self.assertEqual('7', fmt['c'])
         self.assertEqual('Sat', fmt['ccc'])
@@ -185,7 +184,6 @@ class DateTimeFormatTestCase(unittest.TestCase):
         self.assertEqual('6', fmt['e'])
         self.assertEqual('06', fmt['ee'])
 
-
     def test_fractional_seconds(self):
         t = time(8, 3, 9, 799)
         fmt = dates.DateTimeFormat(t, locale='en_US')
index d0d92f61cfe965fdaea035da9f0b465e4be46b79..6a41ac2adefa6f8a83aa1ae70a65974cdc5c04f1 100644 (file)
@@ -11,7 +11,6 @@
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://babel.edgewall.org/log/.
 
-import doctest
 import unittest
 import random
 from operator import methodcaller
diff --git a/tox.ini b/tox.ini
index 0fa957a737fd648cf291efc221809dd9d3148b21..812561da7623742690947805f2119b6f78bc57af 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@ whitelist_externals = make
 commands = make clean-cldr test
 
 [pep8]
-ignore = E501,E731
+ignore = E501,E731,W503
 
 [flake8]
-ignore = E501,E731
+ignore = E501,E731,W503