Skip to content

Commit d67a42a

Browse files
authored
Merge pull request #24 from hugovk/rm-eol
Drop support for EOL Python 2.6, 3.2 and 3.3
2 parents 2735a42 + 86f3029 commit d67a42a

13 files changed

+68
-129
lines changed

.travis.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: python
2+
cache: pip
3+
4+
# Supported CPython versions:
5+
# https://en.wikipedia.org/wiki/CPython#Version_history
6+
matrix:
7+
fast_finish: true
8+
include:
9+
- python: 3.7
10+
dist: xenial
11+
- python: 3.6
12+
- python: 3.5
13+
- python: 3.4
14+
- python: 2.7
15+
16+
install:
17+
- pip install -U pip
18+
- pip install -U tox-travis
19+
20+
script:
21+
- tox

create_py26_env.sh

-48
This file was deleted.

pathspec/compat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ def iterkeys(mapping):
3232
# Python 3.6+.
3333
from collections.abc import Collection as collection_type
3434
except ImportError:
35-
# Python 2.6 - 3.5.
35+
# Python 2.7 - 3.5.
3636
from collections import Container as collection_type

pathspec/pathspec.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def from_lines(cls, pattern_factory, lines):
6666
if isinstance(pattern_factory, string_types):
6767
pattern_factory = util.lookup_pattern(pattern_factory)
6868
if not callable(pattern_factory):
69-
raise TypeError("pattern_factory:{0!r} is not callable.".format(pattern_factory))
69+
raise TypeError("pattern_factory:{!r} is not callable.".format(pattern_factory))
7070

7171
if isinstance(lines, (bytes, unicode)):
72-
raise TypeError("lines:{0!r} is not an iterable.".format(lines))
72+
raise TypeError("lines:{!r} is not an iterable.".format(lines))
7373

7474
lines = [pattern_factory(line) for line in lines if line]
7575
return cls(lines)
@@ -107,7 +107,7 @@ def match_files(self, files, separators=None):
107107
:class:`str`).
108108
"""
109109
if isinstance(files, (bytes, unicode)):
110-
raise TypeError("files:{0!r} is not an iterable.".format(files))
110+
raise TypeError("files:{!r} is not an iterable.".format(files))
111111

112112
file_map = util.normalize_files(files, separators=separators)
113113
matched_files = util.match_files(self.patterns, iterkeys(file_map))

pathspec/pattern.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def match(self, files):
4242
Returns an :class:`~collections.abc.Iterable` yielding each matched
4343
file path (:class:`str`).
4444
"""
45-
raise NotImplementedError("{0}.{1} must override match().".format(self.__class__.__module__, self.__class__.__name__))
45+
raise NotImplementedError("{}.{} must override match().".format(self.__class__.__module__, self.__class__.__name__))
4646

4747

4848
class RegexPattern(Pattern):
@@ -79,7 +79,7 @@ def __init__(self, pattern, include=None):
7979
"""
8080

8181
if isinstance(pattern, (unicode, bytes)):
82-
assert include is None, "include:{0!r} must be null when pattern:{1!r} is a string.".format(include, pattern)
82+
assert include is None, "include:{!r} must be null when pattern:{!r} is a string.".format(include, pattern)
8383
regex, include = self.pattern_to_regex(pattern)
8484
# NOTE: Make sure to allow a null regular expression to be
8585
# returned for a null-operation.
@@ -94,10 +94,10 @@ def __init__(self, pattern, include=None):
9494
elif pattern is None:
9595
# NOTE: Make sure to allow a null pattern to be passed for a
9696
# null-operation.
97-
assert include is None, "include:{0!r} must be null when pattern:{1!r} is null.".format(include, pattern)
97+
assert include is None, "include:{!r} must be null when pattern:{!r} is null.".format(include, pattern)
9898

9999
else:
100-
raise TypeError("pattern:{0!r} is not a string, RegexObject, or None.".format(pattern))
100+
raise TypeError("pattern:{!r} is not a string, RegexObject, or None.".format(pattern))
101101

102102
super(RegexPattern, self).__init__(include)
103103
self.regex = regex

pathspec/patterns/gitwildmatch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def pattern_to_regex(cls, pattern):
4545
return_type = bytes
4646
pattern = pattern.decode(_BYTES_ENCODING)
4747
else:
48-
raise TypeError("pattern:{0!r} is not a unicode or byte string.".format(pattern))
48+
raise TypeError("pattern:{!r} is not a unicode or byte string.".format(pattern))
4949

5050
pattern = pattern.strip()
5151

pathspec/tests/test_gitwildmatch.py

+25-30
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66

77
import re
88
import sys
9-
10-
try:
11-
# Python 2.6.
12-
import unittest2 as unittest
13-
except ImportError:
14-
import unittest
9+
import unittest
1510

1611
import pathspec.patterns.gitwildmatch
1712
import pathspec.util
@@ -58,10 +53,10 @@ def test_01_absolute(self):
5853
'an/absolute/file/path/foo',
5954
'foo/an/absolute/file/path',
6055
]))
61-
self.assertEqual(results, set([
56+
self.assertEqual(results, {
6257
'an/absolute/file/path',
6358
'an/absolute/file/path/foo',
64-
]))
59+
})
6560

6661
def test_01_absolute_root(self):
6762
"""
@@ -98,13 +93,13 @@ def test_01_relative(self):
9893
'spam/foo',
9994
'foo/spam/bar',
10095
]))
101-
self.assertEqual(results, set([
96+
self.assertEqual(results, {
10297
'spam',
10398
'spam/',
10499
'foo/spam',
105100
'spam/foo',
106101
'foo/spam/bar',
107-
]))
102+
})
108103

109104
def test_01_relative_nested(self):
110105
"""
@@ -129,10 +124,10 @@ def test_01_relative_nested(self):
129124
'foo/spam/bar',
130125
'bar/foo/spam',
131126
]))
132-
self.assertEqual(results, set([
127+
self.assertEqual(results, {
133128
'foo/spam',
134129
'foo/spam/bar',
135-
]))
130+
})
136131

137132
def test_02_comment(self):
138133
"""
@@ -181,7 +176,7 @@ def test_03_child_double_asterisk(self):
181176
'spam/bar',
182177
'foo/spam/bar',
183178
]))
184-
self.assertEqual(results, set(['spam/bar']))
179+
self.assertEqual(results, {'spam/bar'})
185180

186181
def test_03_inner_double_asterisk(self):
187182
"""
@@ -208,11 +203,11 @@ def test_03_inner_double_asterisk(self):
208203
'left/bar/right/foo',
209204
'foo/left/bar/right',
210205
]))
211-
self.assertEqual(results, set([
206+
self.assertEqual(results, {
212207
'left/bar/right',
213208
'left/foo/bar/right',
214209
'left/bar/right/foo',
215-
]))
210+
})
216211

217212
def test_03_only_double_asterisk(self):
218213
"""
@@ -240,10 +235,10 @@ def test_03_parent_double_asterisk(self):
240235
'foo/spam',
241236
'foo/spam/bar',
242237
]))
243-
self.assertEqual(results, set([
238+
self.assertEqual(results, {
244239
'foo/spam',
245240
'foo/spam/bar',
246-
]))
241+
})
247242

248243
def test_04_infix_wildcard(self):
249244
"""
@@ -269,13 +264,13 @@ def test_04_infix_wildcard(self):
269264
'foo-hello-bar/b',
270265
'a/foo-hello-bar/b',
271266
]))
272-
self.assertEqual(results, set([
267+
self.assertEqual(results, {
273268
'foo--bar',
274269
'foo-hello-bar',
275270
'a/foo-hello-bar',
276271
'foo-hello-bar/b',
277272
'a/foo-hello-bar/b',
278-
]))
273+
})
279274

280275
def test_04_postfix_wildcard(self):
281276
"""
@@ -301,13 +296,13 @@ def test_04_postfix_wildcard(self):
301296
'foo/~temp-bar',
302297
'foo/~temp-bar/baz',
303298
]))
304-
self.assertEqual(results, set([
299+
self.assertEqual(results, {
305300
'~temp-',
306301
'~temp-foo',
307302
'~temp-foo/bar',
308303
'foo/~temp-bar',
309304
'foo/~temp-bar/baz',
310-
]))
305+
})
311306

312307
def test_04_prefix_wildcard(self):
313308
"""
@@ -331,12 +326,12 @@ def test_04_prefix_wildcard(self):
331326
'foo/bar.py',
332327
'foo/bar.py/baz',
333328
]))
334-
self.assertEqual(results, set([
329+
self.assertEqual(results, {
335330
'bar.py',
336331
'bar.py/',
337332
'foo/bar.py',
338333
'foo/bar.py/baz',
339-
]))
334+
})
340335

341336
def test_05_directory(self):
342337
"""
@@ -363,11 +358,11 @@ def test_05_directory(self):
363358
'foo/dir/bar',
364359
'dir',
365360
]))
366-
self.assertEqual(results, set([
361+
self.assertEqual(results, {
367362
'dir/',
368363
'foo/dir/',
369364
'foo/dir/bar',
370-
]))
365+
})
371366

372367
def test_06_registered(self):
373368
"""
@@ -411,7 +406,7 @@ def test_07_match_bytes_and_bytes(self):
411406
"""
412407
pattern = GitWildMatchPattern(b'*.py')
413408
results = set(pattern.match([b'a.py']))
414-
self.assertEqual(results, set([b'a.py']))
409+
self.assertEqual(results, {b'a.py'})
415410

416411
def test_07_match_bytes_and_bytes_complete(self):
417412
"""
@@ -421,7 +416,7 @@ def test_07_match_bytes_and_bytes_complete(self):
421416
escaped = b"".join(b"\\" + encoded[i:i+1] for i in range(len(encoded)))
422417
pattern = GitWildMatchPattern(escaped)
423418
results = set(pattern.match([encoded]))
424-
self.assertEqual(results, set([encoded]))
419+
self.assertEqual(results, {encoded})
425420

426421
@unittest.skipIf(sys.version_info[0] >= 3, "Python 3 is strict")
427422
def test_07_match_bytes_and_unicode(self):
@@ -430,7 +425,7 @@ def test_07_match_bytes_and_unicode(self):
430425
"""
431426
pattern = GitWildMatchPattern(b'*.py')
432427
results = set(pattern.match(['a.py']))
433-
self.assertEqual(results, set(['a.py']))
428+
self.assertEqual(results, {'a.py'})
434429

435430
@unittest.skipIf(sys.version_info[0] == 2, "Python 2 is lenient")
436431
def test_07_match_bytes_and_unicode_fail(self):
@@ -449,7 +444,7 @@ def test_07_match_unicode_and_bytes(self):
449444
"""
450445
pattern = GitWildMatchPattern('*.py')
451446
results = set(pattern.match([b'a.py']))
452-
self.assertEqual(results, set([b'a.py']))
447+
self.assertEqual(results, {b'a.py'})
453448

454449
@unittest.skipIf(sys.version_info[0] == 2, "Python 2 is lenient")
455450
def test_07_match_unicode_and_bytes_fail(self):
@@ -467,4 +462,4 @@ def test_07_match_unicode_and_unicode(self):
467462
"""
468463
pattern = GitWildMatchPattern('*.py')
469464
results = set(pattern.match(['a.py']))
470-
self.assertEqual(results, set(['a.py']))
465+
self.assertEqual(results, {'a.py'})

pathspec/tests/test_pathspec.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
This script tests ``PathSpec``.
44
"""
55

6-
try:
7-
import unittest2 as unittest
8-
except ImportError:
9-
import unittest
6+
import unittest
107

118
import pathspec
129

@@ -33,11 +30,11 @@ def test_01_current_dir_paths(self):
3330
'./src/test2/b.txt',
3431
'./src/test2/c/c.txt',
3532
]))
36-
self.assertEqual(results, set([
33+
self.assertEqual(results, {
3734
'./src/test2/a.txt',
3835
'./src/test2/b.txt',
3936
'./src/test2/c/c.txt',
40-
]))
37+
})
4138

4239
def test_01_match_files(self):
4340
"""
@@ -77,11 +74,11 @@ def test_01_windows_current_dir_paths(self):
7774
'.\\src\\test2\\b.txt',
7875
'.\\src\\test2\\c\\c.txt',
7976
], separators=('\\',)))
80-
self.assertEqual(results, set([
77+
self.assertEqual(results, {
8178
'.\\src\\test2\\a.txt',
8279
'.\\src\\test2\\b.txt',
8380
'.\\src\\test2\\c\\c.txt',
84-
]))
81+
})
8582

8683
def test_01_windows_paths(self):
8784
"""
@@ -99,11 +96,11 @@ def test_01_windows_paths(self):
9996
'src\\test2\\b.txt',
10097
'src\\test2\\c\\c.txt',
10198
], separators=('\\',)))
102-
self.assertEqual(results, set([
99+
self.assertEqual(results, {
103100
'src\\test2\\a.txt',
104101
'src\\test2\\b.txt',
105102
'src\\test2\\c\\c.txt',
106-
]))
103+
})
107104

108105
def test_02_eq(self):
109106
"""

0 commit comments

Comments
 (0)