diff --git a/.travis.yml b/.travis.yml index d01afd4..3934f10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,6 @@ sudo: true matrix: include: - - python: 3.4 - env: TOXENV=py34 - python: 3.5 env: TOXENV=py35 - python: 3.6 diff --git a/appveyor.yml b/appveyor.yml index 2be627d..37ea51c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,15 +2,13 @@ build: false environment: matrix: - - PYTHON: "C:/Python34" - TOXENV: "py34" - PYTHON: "C:/Python35" TOXENV: "py35" - PYTHON: "C:/Python36" TOXENV: "py36" - PYTHON: "C:/Python37" TOXENV: "py37" - - PYTHON: "C:/Python36" + - PYTHON: "C:/Python37" TOXENV: "lint" init: diff --git a/backrefs/bre.py b/backrefs/bre.py index 82264bd..6fa15c7 100644 --- a/backrefs/bre.py +++ b/backrefs/bre.py @@ -35,10 +35,10 @@ __all__ = ( "expand", "expandf", "search", "match", "fullmatch", "split", "findall", "finditer", "sub", "subf", - "subn", "subfn", "purge", "escape", "DEBUG", "I", "IGNORECASE", "L", "LOCALE", "M", "MULTILINE", + "subn", "subfn", "purge", "escape", "fullmatch", "DEBUG", "I", "IGNORECASE", "L", "LOCALE", "M", "MULTILINE", "S", "DOTALL", "U", "UNICODE", "X", "VERBOSE", "compile", "compile_search", "compile_replace", "Bre", "ReplaceTemplate", "A", "ASCII" -) + (("fullmatch",) if _util.PY34 else tuple()) +) # Expose some common re flags and methods to # save having to import re and backrefs libraries @@ -265,11 +265,10 @@ def match(self, string, *args, **kwargs): return self._pattern.match(string, *args, **kwargs) - if _util.PY34: - def fullmatch(self, string, *args, **kwargs): - """Apply `fullmatch`.""" + def fullmatch(self, string, *args, **kwargs): + """Apply `fullmatch`.""" - return self._pattern.fullmatch(string, *args, **kwargs) + return self._pattern.fullmatch(string, *args, **kwargs) def split(self, string, *args, **kwargs): """Apply `split`.""" @@ -387,12 +386,11 @@ def match(pattern, string, *args, **kwargs): return _re.match(_apply_search_backrefs(pattern, flags), string, *args, **kwargs) -if _util.PY34: - def fullmatch(pattern, string, *args, **kwargs): - """Apply `fullmatch` after applying backrefs.""" +def fullmatch(pattern, string, *args, **kwargs): + """Apply `fullmatch` after applying backrefs.""" - flags = args[2] if len(args) > 2 else kwargs.get('flags', 0) - return _re.fullmatch(_apply_search_backrefs(pattern, flags), string, *args, **kwargs) + flags = args[2] if len(args) > 2 else kwargs.get('flags', 0) + return _re.fullmatch(_apply_search_backrefs(pattern, flags), string, *args, **kwargs) def split(pattern, string, *args, **kwargs): diff --git a/backrefs/uniprops/__init__.py b/backrefs/uniprops/__init__.py index 386587c..cf93027 100644 --- a/backrefs/uniprops/__init__.py +++ b/backrefs/uniprops/__init__.py @@ -5,7 +5,6 @@ UNICODE_RANGE = '\u0000-\U0010ffff' -PY35 = sys.version_info >= (3, 5) PY37 = sys.version_info >= (3, 7) POSIX = 0 @@ -168,12 +167,8 @@ def get_hangul_syllable_type_property(value, is_bytes=False): def get_indic_positional_category_property(value, is_bytes=False): """Get `INDIC POSITIONAL/MATRA CATEGORY` property.""" - if PY35: - obj = unidata.ascii_indic_positional_category if is_bytes else unidata.unicode_indic_positional_category - alias_key = 'indicpositionalcategory' - else: - obj = unidata.ascii_indic_matra_category if is_bytes else unidata.unicode_indic_matra_category - alias_key = 'indicmatracategory' + obj = unidata.ascii_indic_positional_category if is_bytes else unidata.unicode_indic_positional_category + alias_key = 'indicpositionalcategory' if value.startswith('^'): negated = value[1:] @@ -502,9 +497,7 @@ def get_unicode_property(value, prop=None, is_bytes=False): return get_age_property(value, is_bytes) elif prop == 'eastasianwidth': return get_east_asian_width_property(value, is_bytes) - elif PY35 and prop == 'indicpositionalcategory': - return get_indic_positional_category_property(value, is_bytes) - elif not PY35 and prop == 'indicmatracategory': + elif prop == 'indicpositionalcategory': return get_indic_positional_category_property(value, is_bytes) elif prop == 'indicsyllabiccategory': return get_indic_syllabic_category_property(value, is_bytes) diff --git a/backrefs/util.py b/backrefs/util.py index 2dc9bc4..486f934 100644 --- a/backrefs/util.py +++ b/backrefs/util.py @@ -7,7 +7,6 @@ import sys import warnings -PY34 = (3, 4) <= sys.version_info PY36 = (3, 6) <= sys.version_info PY37 = (3, 7) <= sys.version_info diff --git a/docs/src/markdown/changelog.md b/docs/src/markdown/changelog.md index 56882f9..2bbfc59 100644 --- a/docs/src/markdown/changelog.md +++ b/docs/src/markdown/changelog.md @@ -3,6 +3,7 @@ ## 4.2.0 - **NEW**: Deprecate the **search** references `\l`, `\L`, `\c`, and `\C`. The POSIX alternatives (which these were shortcuts for) should be used instead: `[[:lower:]]`, `[[:^lower:]]`, `[:upper:]]`, and `[[:^upper:]]` respectively. +- **NEW**: Formally drop support for Python 3.4. ## 4.1.1 diff --git a/requirements/flake8.txt b/requirements/flake8.txt index 93069a3..1a9355f 100644 --- a/requirements/flake8.txt +++ b/requirements/flake8.txt @@ -1,4 +1,5 @@ flake8 +pydocstyle<4.0.0 flake8-docstrings pep8-naming flake8-mutable diff --git a/setup.py b/setup.py index 918697e..614c59f 100644 --- a/setup.py +++ b/setup.py @@ -96,7 +96,7 @@ def get_description(): setup( name='backrefs', version=VER, - python_requires=">=3.4", + python_requires=">=3.5", keywords='regex re', description='A wrapper around re and regex that adds additional back references.', long_description=get_description(), @@ -116,7 +116,6 @@ def get_description(): 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', diff --git a/tests/test_bre.py b/tests/test_bre.py index dabd0d8..b2e51ac 100644 --- a/tests/test_bre.py +++ b/tests/test_bre.py @@ -12,7 +12,6 @@ import copy import warnings -PY34_PLUS = (3, 4) <= sys.version_info PY36_PLUS = (3, 6) <= sys.version_info PY37_PLUS = (3, 7) <= sys.version_info @@ -1180,7 +1179,7 @@ def test_grapheme_cluster(self): bre.findall(r"\X{3}", "a\xE0a\u0300e\xE9e\u0301"), ['a\xe0a\u0300', 'e\xe9e\u0301'] ) - # self.assertEqual(regex.findall(r"\X", "\r\r\n\u0301A\u0301"), ['\r', '\r\n', '\u0301', 'A\u0301']) + # `self.assertEqual(regex.findall(r"\X", "\r\r\n\u0301A\u0301"), ['\r', '\r\n', '\u0301', 'A\u0301'])` self.assertEqual(bre.search(r'\X$', 'ab\u2103').group(), '\u2103') def test_replace_unicode_name_ascii_range(self): @@ -2380,13 +2379,12 @@ def test_match(self): def test_fullmatch(self): """Test that `fullmatch` works.""" - if PY34_PLUS: - m = bre.fullmatch(r'This is a test for match!', "This is a test for match!") - self.assertTrue(m is not None) + m = bre.fullmatch(r'This is a test for match!', "This is a test for match!") + self.assertTrue(m is not None) - p = bre.compile(r'This is a test for match!') - m = p.fullmatch("This is a test for match!") - self.assertTrue(m is not None) + p = bre.compile(r'This is a test for match!') + m = p.fullmatch("This is a test for match!") + self.assertTrue(m is not None) def test_search(self): """Test that `search` works.""" diff --git a/tests/test_uniprops.py b/tests/test_uniprops.py index 8092904..18c4569 100644 --- a/tests/test_uniprops.py +++ b/tests/test_uniprops.py @@ -4,8 +4,6 @@ import sys from backrefs import uniprops -PY34 = (3, 4) <= sys.version_info -PY35 = (3, 5) <= sys.version_info PY37 = (3, 7) <= sys.version_info @@ -75,26 +73,14 @@ def test_inverse_bidi(self): def test_bidi_paired_bracket_type(self): """Test `bidi paired bracket type` Category.""" - if PY34: - result = uniprops.get_unicode_property('o', 'bpt') - self.assertEqual(result, uniprops.unidata.unicode_bidi_paired_bracket_type['o']) - else: - with self.assertRaises(ValueError) as e: - uniprops.get_unicode_property('o', 'bpt') - - self.assertTrue(str(e), 'Invalid Unicode property!') + result = uniprops.get_unicode_property('o', 'bpt') + self.assertEqual(result, uniprops.unidata.unicode_bidi_paired_bracket_type['o']) def test_inverse_bidi_paired_bracket_type(self): """Test inverse `bidi paired bracket type` Category.""" - if PY34: - result = uniprops.get_unicode_property('^o', 'bpt') - self.assertEqual(result, uniprops.unidata.unicode_bidi_paired_bracket_type['^o']) - else: - with self.assertRaises(ValueError) as e: - uniprops.get_unicode_property('^o', 'bpt') - - self.assertTrue(str(e), 'Invalid Unicode property!') + result = uniprops.get_unicode_property('^o', 'bpt') + self.assertEqual(result, uniprops.unidata.unicode_bidi_paired_bracket_type['^o']) def test_decompostion(self): """Test `decomposition type` Category.""" @@ -135,22 +121,14 @@ def test_inverse_eastasianwidth(self): def test_indicpositionalcategory(self): """Test `indic positional/matra category` Category.""" - if PY35: - result = uniprops.get_unicode_property('top', 'inpc') - self.assertEqual(result, uniprops.unidata.unicode_indic_positional_category['top']) - else: - result = uniprops.get_unicode_property('top', 'inmc') - self.assertEqual(result, uniprops.unidata.unicode_indic_matra_category['top']) + result = uniprops.get_unicode_property('top', 'inpc') + self.assertEqual(result, uniprops.unidata.unicode_indic_positional_category['top']) def test_inverse_indicpositionalcategory(self): """Test inverse `indic positional/matra category` Category.""" - if PY35: - result = uniprops.get_unicode_property('^top', 'inpc') - self.assertEqual(result, uniprops.unidata.unicode_indic_positional_category['^top']) - else: - result = uniprops.get_unicode_property('^top', 'inmc') - self.assertEqual(result, uniprops.unidata.unicode_indic_matra_category['^top']) + result = uniprops.get_unicode_property('^top', 'inpc') + self.assertEqual(result, uniprops.unidata.unicode_indic_positional_category['^top']) def test_indicsylabiccategory(self): """Test `indic syllabic category` Category.""" diff --git a/tools/unicodedata/5.2.0.zip b/tools/unicodedata/5.2.0.zip deleted file mode 100644 index f23760c..0000000 Binary files a/tools/unicodedata/5.2.0.zip and /dev/null differ diff --git a/tools/unicodedata/6.3.0.zip b/tools/unicodedata/6.3.0.zip deleted file mode 100644 index 741af7b..0000000 Binary files a/tools/unicodedata/6.3.0.zip and /dev/null differ diff --git a/tools/unidatadownload.py b/tools/unidatadownload.py index 9f0f12a..7311309 100644 --- a/tools/unidatadownload.py +++ b/tools/unidatadownload.py @@ -8,8 +8,6 @@ __version__ = '2.2.0' -PY34 = sys.version_info >= (3, 4) -PY35 = sys.version_info >= (3, 5) PY37 = sys.version_info >= (3, 7) HOME = os.path.dirname(os.path.abspath(__file__)) @@ -72,14 +70,9 @@ def download_unicodedata(version, output=HOME, no_zip=False): ] files.append('ScriptExtensions.txt') - if PY35: - files.append('IndicPositionalCategory.txt') - else: - files.append('IndicMatraCategory.txt') + files.append('IndicPositionalCategory.txt') files.append('IndicSyllabicCategory.txt') - - if PY34: - files.append('BidiBrackets.txt') + files.append('BidiBrackets.txt') if PY37: files.append('VerticalOrientation.txt') diff --git a/tools/unipropgen.py b/tools/unipropgen.py index ca53b2f..cdf8504 100644 --- a/tools/unipropgen.py +++ b/tools/unipropgen.py @@ -16,8 +16,6 @@ GROUP_ESCAPES = frozenset([ord(x) for x in '-&[\\]^|~']) # Compatibility -PY34 = sys.version_info >= (3, 4) -PY35 = sys.version_info >= (3, 5) PY37 = sys.version_info >= (3, 7) UNICODE_RANGE = (0x0000, 0x10FFFF) @@ -974,12 +972,9 @@ def gen_properties(output, ascii_props=False, append=False): files['scx'] = os.path.join(output, 'scriptextensions.py') files['insc'] = os.path.join(output, 'indicsyllabiccategory.py') - if PY34: - files['bpt'] = os.path.join(output, 'bidipairedbrackettype.py') - if PY35: - files['inpc'] = os.path.join(output, 'indicpositionalcategory.py') - else: - files['inmc'] = os.path.join(output, 'indicmatracategory.py') + files['bpt'] = os.path.join(output, 'bidipairedbrackettype.py') + files['inpc'] = os.path.join(output, 'indicpositionalcategory.py') + if PY37: files['vo'] = os.path.join(output, 'verticalorientation.py') @@ -998,12 +993,9 @@ def gen_properties(output, ascii_props=False, append=False): ] categories.append('scriptextensions') categories.append('indicsyllabiccategory') - if PY34: - categories.append('bidipairedbrackettype') - if PY35: - categories.append('indicpositionalcategory') - else: - categories.append('indicmatracategory') + categories.append('bidipairedbrackettype') + categories.append('indicpositionalcategory') + if PY37: categories.append('verticalorientation') if ascii_props: @@ -1055,13 +1047,11 @@ def gen_properties(output, ascii_props=False, append=False): # Generate Unicode bidi classes print('Building: Bidi Classes') gen_bidi(files['bc'], ascii_props, append, prefix) - - if PY34: - print('Building: Bidi Paired Bracket Type') - gen_enum( - 'BidiBrackets.txt', 'bidi_paired_bracket_type', files['bpt'], notexplicit='n', - field=2, ascii_props=ascii_props, append=append, prefix=prefix - ) + print('Building: Bidi Paired Bracket Type') + gen_enum( + 'BidiBrackets.txt', 'bidi_paired_bracket_type', files['bpt'], notexplicit='n', + field=2, ascii_props=ascii_props, append=append, prefix=prefix + ) # Generate Unicode binary print('Building: Binary') @@ -1104,18 +1094,12 @@ def gen_properties(output, ascii_props=False, append=False): ascii_props=ascii_props, append=append, prefix=prefix ) - if PY35: - print('Building: Indic Positional Category') - gen_enum( - 'IndicPositionalCategory.txt', 'indic_positional_category', files['inpc'], notexplicit='na', - ascii_props=ascii_props, append=append, prefix=prefix - ) - else: - print('Building: Indic Matra Category') - gen_enum( - 'IndicMatraCategory.txt', 'indic_matra_category', files['inmc'], notexplicit='na', - ascii_props=ascii_props, append=append, prefix=prefix - ) + print('Building: Indic Positional Category') + gen_enum( + 'IndicPositionalCategory.txt', 'indic_positional_category', files['inpc'], notexplicit='na', + ascii_props=ascii_props, append=append, prefix=prefix + ) + print('Building: Indic Syllabic Category') gen_enum( 'IndicSyllabicCategory.txt', 'indic_syllabic_category', files['insc'], notexplicit='other', diff --git a/tox.ini b/tox.ini index 2ee74cb..d381312 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py27,py33,py34,py35,py36,py37,py38, + py27,py35,py36,py37,py38, lint [testenv]