From 66f51babed216adbc4f11aaa715ca355cf88a867 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 28 Dec 2017 00:17:29 +0200 Subject: Drop EOL Python 2.6 and 3.3 --- .travis.yml | 8 -------- docs/dev.rst | 3 +-- setup.py | 3 +-- tox.ini | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9469c9..b819e3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,6 @@ cache: matrix: include: - - os: linux - python: 2.6 - - os: linux - python: 2.6 - env: - - CDECIMAL=m3-cdecimal - os: linux python: 2.7 - os: linux @@ -27,8 +21,6 @@ matrix: python: pypy - os: linux python: pypy3 - - os: linux - python: 3.3 - os: linux python: 3.4 - os: linux diff --git a/docs/dev.rst b/docs/dev.rst index afc8b12..0ff033f 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -30,9 +30,8 @@ Python Versions At the moment the following Python versions should be supported: -* Python 2.6 * Python 2.7 -* Python 3.3 and up +* Python 3.4 and up * PyPy tracking 2.7 and 3.2 and up While PyPy does not currently support 3.3, it does support traditional diff --git a/setup.py b/setup.py index 684c387..8e268e1 100755 --- a/setup.py +++ b/setup.py @@ -45,10 +45,8 @@ setup( 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -56,6 +54,7 @@ setup( 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Software Development :: Libraries :: Python Modules', ], + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', packages=['babel', 'babel.messages', 'babel.localtime'], include_package_data=True, install_requires=[ diff --git a/tox.ini b/tox.ini index b71dec7..ab73346 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27, pypy, py33, py34, py35, py36, pypy3, py26-cdecimal, py27-cdecimal +envlist = py27, pypy, py33, py34, py35, py36, pypy3, py27-cdecimal [testenv] deps = -- cgit v1.2.1 From 44f509c6ab67a1a7154d0ffbb8e626e80c3d32be Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 28 Dec 2017 00:25:54 +0200 Subject: Replace function call with set literal --- babel/languages.py | 2 +- babel/messages/catalog.py | 4 ++-- babel/messages/checkers.py | 6 +++--- babel/plural.py | 2 +- tests/messages/test_frontend.py | 30 +++++++++--------------------- tests/test_languages.py | 4 +++- tests/test_numbers.py | 2 +- tests/test_support.py | 2 +- 8 files changed, 21 insertions(+), 31 deletions(-) diff --git a/babel/languages.py b/babel/languages.py index 40f5d98..0513d00 100644 --- a/babel/languages.py +++ b/babel/languages.py @@ -26,7 +26,7 @@ def get_official_languages(territory, regional=False, de_facto=False): """ territory = str(territory).upper() - allowed_stati = set(("official",)) + allowed_stati = {"official"} if regional: allowed_stati.add("official_regional") if de_facto: diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index fd40058..93d0440 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -531,7 +531,7 @@ class Catalog(object): buf.append('%s: %s' % (name, value)) flags = set() if self.fuzzy: - flags |= set(['fuzzy']) + flags |= {'fuzzy'} yield Message(u'', '\n'.join(buf), flags=flags) for key in self._messages: yield self._messages[key] @@ -762,7 +762,7 @@ class Catalog(object): message.string = message.string[0] message.flags |= oldmsg.flags if fuzzy: - message.flags |= set([u'fuzzy']) + message.flags |= {u'fuzzy'} self[message.id] = message for message in template: diff --git a/babel/messages/checkers.py b/babel/messages/checkers.py index 24ecdcf..97e6e19 100644 --- a/babel/messages/checkers.py +++ b/babel/messages/checkers.py @@ -17,9 +17,9 @@ from babel._compat import string_types, izip #: list of format chars that are compatible to each other _string_format_compatibilities = [ - set(['i', 'd', 'u']), - set(['x', 'X']), - set(['f', 'F', 'g', 'G']) + {'i', 'd', 'u'}, + {'x', 'X'}, + {'f', 'F', 'g', 'G'} ] diff --git a/babel/plural.py b/babel/plural.py index a23f8b5..06f349e 100644 --- a/babel/plural.py +++ b/babel/plural.py @@ -241,7 +241,7 @@ def to_gettext(rule): """ rule = PluralRule.parse(rule) - used_tags = rule.tags | set([_fallback_tag]) + used_tags = rule.tags | {_fallback_tag} _compile = _GettextCompiler().compile _get_index = [tag for tag in _plural_tags if tag in used_tags].index diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 20904a3..3ac0ac3 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -1343,26 +1343,14 @@ def test_extract_keyword_args_384(split, arg_name): "extract -F babel-django.cfg --add-comments Translators: -o django232.pot %s ." % kwarg_text ) assert isinstance(cmdinst, extract_messages) - assert set(cmdinst.keywords.keys()) == set(( - '_', - 'dgettext', - 'dngettext', - 'gettext', - 'gettext_lazy', - 'gettext_noop', - 'N_', - 'ngettext', - 'ngettext_lazy', - 'npgettext', - 'npgettext_lazy', - 'pgettext', - 'pgettext_lazy', - 'ugettext', - 'ugettext_lazy', - 'ugettext_noop', - 'ungettext', - 'ungettext_lazy', - )) + assert set(cmdinst.keywords.keys()) == {'_', 'dgettext', 'dngettext', + 'gettext', 'gettext_lazy', + 'gettext_noop', 'N_', 'ngettext', + 'ngettext_lazy', 'npgettext', + 'npgettext_lazy', 'pgettext', + 'pgettext_lazy', 'ugettext', + 'ugettext_lazy', 'ugettext_noop', + 'ungettext', 'ungettext_lazy'} @pytest.mark.parametrize("kwarg,expected", [ @@ -1384,7 +1372,7 @@ def test_extract_distutils_keyword_arg_388(kwarg, expected): assert set(cmdinst.keywords.keys()) == set(expected) # Test the comma-separated comment argument while we're at it: - assert set(cmdinst.add_comments) == set(("Bar", "Foo")) + assert set(cmdinst.add_comments) == {"Bar", "Foo"} def test_update_catalog_boolean_args(): diff --git a/tests/test_languages.py b/tests/test_languages.py index 594149f..23af26d 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -11,4 +11,6 @@ def test_official_languages(): def test_get_language_info(): - assert set(get_territory_language_info("HU").keys()) == set(("hu", "en", "de", "ro", "hr", "sk", "sl")) + assert set(get_territory_language_info("HU").keys()) == {"hu", "en", "de", + "ro", "hr", "sk", + "sl"} diff --git a/tests/test_numbers.py b/tests/test_numbers.py index 48a260b..6cc6e43 100644 --- a/tests/test_numbers.py +++ b/tests/test_numbers.py @@ -177,7 +177,7 @@ def test_list_currencies(): list_currencies('yo!') assert excinfo.value.args[0] == "expected only letters, got 'yo!'" - assert list_currencies(locale='pa_Arab') == set(['PKR', 'INR', 'EUR']) + assert list_currencies(locale='pa_Arab') == {'PKR', 'INR', 'EUR'} assert list_currencies(locale='kok') == set([]) assert len(list_currencies()) == 296 diff --git a/tests/test_support.py b/tests/test_support.py index f2a99b7..6f9fb32 100644 --- a/tests/test_support.py +++ b/tests/test_support.py @@ -358,4 +358,4 @@ def test_catalog_merge_files(): t2._catalog["bar"] = "quux" t1.merge(t2) assert t1.files == ["pro.mo"] - assert set(t1._catalog.keys()) == set(('', 'foo', 'bar')) + assert set(t1._catalog.keys()) == {'', 'foo', 'bar'} -- cgit v1.2.1 From 2e6f6b9bd48f93a86dec5b317d4c2eb89a3a6301 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 28 Dec 2017 11:06:59 +0200 Subject: Remove redundant parentheses --- babel/dates.py | 4 ++-- babel/messages/catalog.py | 4 ++-- babel/messages/frontend.py | 2 +- tests/messages/test_catalog.py | 2 +- tests/messages/test_extract.py | 4 ++-- tests/messages/test_frontend.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/babel/dates.py b/babel/dates.py index d1fafe2..377dfeb 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -521,7 +521,7 @@ def get_timezone_location(dt_or_tzinfo=None, locale=LC_TIME, return_city=False): territory = 'ZZ' # invalid/unknown territory_name = locale.territories[territory] if not return_city and territory and len(get_global('territory_zones').get(territory, [])) == 1: - return region_format % (territory_name) + return region_format % territory_name # Otherwise, include the city in the output fallback_format = locale.zone_formats['fallback'] @@ -1303,7 +1303,7 @@ class DateTimeFormat(object): elif char == 'H': return self.value.hour elif char == 'h': - return (self.value.hour % 12 or 12) + return self.value.hour % 12 or 12 elif char == 'm': return self.value.minute elif char == 'a': diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index 93d0440..b293e3c 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -120,8 +120,8 @@ class Message(object): """Compare Messages, taking into account plural ids""" def values_to_compare(obj): if isinstance(obj, Message) and obj.pluralizable: - return (obj.id[0], obj.context or '') - return (obj.id, obj.context or '') + return obj.id[0], obj.context or '' + return obj.id, obj.context or '' return cmp(values_to_compare(self), values_to_compare(other)) def __gt__(self, other): diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index fb171e3..bee745a 100644 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -978,7 +978,7 @@ def parse_mapping(fileobj, filename=None): method = extractors[method] method_map[idx] = (pattern, method) - return (method_map, options_map) + return method_map, options_map def parse_keywords(strings=[]): diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py index 2d2880c..07ed724 100644 --- a/tests/messages/test_catalog.py +++ b/tests/messages/test_catalog.py @@ -101,7 +101,7 @@ class CatalogTestCase(unittest.TestCase): def test_update_message_changed_to_simple(self): cat = catalog.Catalog() - cat.add((u'foo' u'foos'), (u'Voh', u'Vöhs')) + cat.add(u'foo' u'foos', (u'Voh', u'Vöhs')) tmpl = catalog.Catalog() tmpl.add(u'foo') cat.update(tmpl) diff --git a/tests/messages/test_extract.py b/tests/messages/test_extract.py index 873439d..17b090f 100644 --- a/tests/messages/test_extract.py +++ b/tests/messages/test_extract.py @@ -178,7 +178,7 @@ msg2 = ngettext(\"\"\"elvis\"\"\", 'elvises', count) messages = list(extract.extract_python(buf, extract.DEFAULT_KEYWORDS.keys(), [], {})) - self.assertEqual([(1, '_', (u'pylons'), []), + self.assertEqual([(1, '_', u'pylons', []), (2, 'ngettext', (u'elvis', u'elvises', None), []), (3, 'ngettext', (u'elvis', u'elvises', None), [])], messages) @@ -350,7 +350,7 @@ n = ngettext('foo') self.assertEqual((None, u'hello', u'there'), messages[2][2]) self.assertEqual((None, None), messages[3][2]) self.assertEqual(None, messages[4][2]) - self.assertEqual(('foo'), messages[5][2]) + self.assertEqual('foo', messages[5][2]) def test_utf8_message(self): buf = BytesIO(u""" diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 3ac0ac3..10325fe 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -1140,7 +1140,7 @@ msgstr[2] "" assert not os.path.isfile(mo_file), 'Expected no file at %r' % mo_file self.assertEqual("""\ catalog %s is marked as fuzzy, skipping -""" % (po_file), sys.stderr.getvalue()) +""" % po_file, sys.stderr.getvalue()) def test_compile_fuzzy_catalog(self): po_file = self._po_file('de_DE') -- cgit v1.2.1 From 0c404b58b25f8e2e115d51fddd5d5716969af219 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 28 Dec 2017 11:12:01 +0200 Subject: Remove unused imports --- babel/numbers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/babel/numbers.py b/babel/numbers.py index 1f77bcd..73ff816 100644 --- a/babel/numbers.py +++ b/babel/numbers.py @@ -20,16 +20,16 @@ # - http://www.unicode.org/reports/tr35/ (Appendix G.6) import re from datetime import date as date_, datetime as datetime_ -from itertools import chain import warnings from babel.core import default_locale, Locale, get_global from babel._compat import decimal, string_types -from babel.localedata import locale_identifiers try: + # Python 2 long except NameError: + # Python 3 long = int -- cgit v1.2.1 From 05974ff14feda12a0d292a560313961796e69113 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 28 Dec 2017 11:13:50 +0200 Subject: Replace comparison with None with equality operator --- tests/test_localedata.py | 4 ++-- tests/test_numbers.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_localedata.py b/tests/test_localedata.py index 3599b21..5d6c800 100644 --- a/tests/test_localedata.py +++ b/tests/test_localedata.py @@ -108,12 +108,12 @@ def test_pi_support_not_frozen(): def test_locale_argument_acceptance(): # Testing None input. normalized_locale = localedata.normalize_locale(None) - assert normalized_locale == None + assert normalized_locale is None locale_exist = localedata.exists(None) assert locale_exist == False # # Testing list input. normalized_locale = localedata.normalize_locale(['en_us', None]) - assert normalized_locale == None + assert normalized_locale is None locale_exist = localedata.exists(['en_us', None]) assert locale_exist == False diff --git a/tests/test_numbers.py b/tests/test_numbers.py index 6cc6e43..2795b0f 100644 --- a/tests/test_numbers.py +++ b/tests/test_numbers.py @@ -206,13 +206,13 @@ def test_is_currency(): def test_normalize_currency(): assert normalize_currency('EUR') == 'EUR' assert normalize_currency('eUr') == 'EUR' - assert normalize_currency('FUU') == None - assert normalize_currency('') == None - assert normalize_currency(None) == None - assert normalize_currency(' EUR ') == None - assert normalize_currency(' ') == None - assert normalize_currency([]) == None - assert normalize_currency(set()) == None + assert normalize_currency('FUU') is None + assert normalize_currency('') is None + assert normalize_currency(None) is None + assert normalize_currency(' EUR ') is None + assert normalize_currency(' ') is None + assert normalize_currency([]) is None + assert normalize_currency(set()) is None def test_get_currency_name(): -- cgit v1.2.1 From 6126d3bb3be6d51f8676638f9475e0048c44a494 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 28 Dec 2017 11:39:20 +0200 Subject: Drop EOL Python 3.3 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ab73346..33d1ab8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, pypy, py33, py34, py35, py36, pypy3, py27-cdecimal +envlist = py27, pypy, py34, py35, py36, pypy3, py27-cdecimal [testenv] deps = -- cgit v1.2.1