Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formally drop Python 3.4 support #117

Merged
merged 3 commits into from
Aug 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ sudo: true

matrix:
include:
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
Expand Down
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 9 additions & 11 deletions backrefs/bre.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`."""
Expand Down Expand Up @@ -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):
Expand Down
13 changes: 3 additions & 10 deletions backrefs/uniprops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

UNICODE_RANGE = '\u0000-\U0010ffff'

PY35 = sys.version_info >= (3, 5)
PY37 = sys.version_info >= (3, 7)

POSIX = 0
Expand Down Expand Up @@ -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:]
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion backrefs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/src/markdown/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions requirements/flake8.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flake8
pydocstyle<4.0.0
flake8-docstrings
pep8-naming
flake8-mutable
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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',
Expand Down
14 changes: 6 additions & 8 deletions tests/test_bre.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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."""
Expand Down
38 changes: 8 additions & 30 deletions tests/test_uniprops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down
Binary file removed tools/unicodedata/5.2.0.zip
Binary file not shown.
Binary file removed tools/unicodedata/6.3.0.zip
Binary file not shown.
11 changes: 2 additions & 9 deletions tools/unidatadownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down Expand Up @@ -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')
Expand Down
50 changes: 17 additions & 33 deletions tools/unipropgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')

Expand All @@ -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:
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py27,py33,py34,py35,py36,py37,py38,
py27,py35,py36,py37,py38,
lint

[testenv]
Expand Down