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

Drop support for EOL Python 2.6, 3.2 and 3.3 #24

Merged
merged 5 commits into from Dec 1, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions .travis.yml
@@ -0,0 +1,21 @@
language: python
cache: pip

# Supported CPython versions:
# https://en.wikipedia.org/wiki/CPython#Version_history
matrix:
fast_finish: true
include:
- python: 3.7
dist: xenial
- python: 3.6
- python: 3.5
- python: 3.4
- python: 2.7

install:
- pip install -U pip
- pip install -U tox-travis

script:
- tox
48 changes: 0 additions & 48 deletions create_py26_env.sh

This file was deleted.

2 changes: 1 addition & 1 deletion pathspec/compat.py
Expand Up @@ -32,5 +32,5 @@ def iterkeys(mapping):
# Python 3.6+.
from collections.abc import Collection as collection_type
except ImportError:
# Python 2.6 - 3.5.
# Python 2.7 - 3.5.
from collections import Container as collection_type
6 changes: 3 additions & 3 deletions pathspec/pathspec.py
Expand Up @@ -66,10 +66,10 @@ def from_lines(cls, pattern_factory, lines):
if isinstance(pattern_factory, string_types):
pattern_factory = util.lookup_pattern(pattern_factory)
if not callable(pattern_factory):
raise TypeError("pattern_factory:{0!r} is not callable.".format(pattern_factory))
raise TypeError("pattern_factory:{!r} is not callable.".format(pattern_factory))

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

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

file_map = util.normalize_files(files, separators=separators)
matched_files = util.match_files(self.patterns, iterkeys(file_map))
Expand Down
8 changes: 4 additions & 4 deletions pathspec/pattern.py
Expand Up @@ -42,7 +42,7 @@ def match(self, files):
Returns an :class:`~collections.abc.Iterable` yielding each matched
file path (:class:`str`).
"""
raise NotImplementedError("{0}.{1} must override match().".format(self.__class__.__module__, self.__class__.__name__))
raise NotImplementedError("{}.{} must override match().".format(self.__class__.__module__, self.__class__.__name__))


class RegexPattern(Pattern):
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, pattern, include=None):
"""

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

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

super(RegexPattern, self).__init__(include)
self.regex = regex
Expand Down
2 changes: 1 addition & 1 deletion pathspec/patterns/gitwildmatch.py
Expand Up @@ -45,7 +45,7 @@ def pattern_to_regex(cls, pattern):
return_type = bytes
pattern = pattern.decode(_BYTES_ENCODING)
else:
raise TypeError("pattern:{0!r} is not a unicode or byte string.".format(pattern))
raise TypeError("pattern:{!r} is not a unicode or byte string.".format(pattern))

pattern = pattern.strip()

Expand Down
55 changes: 25 additions & 30 deletions pathspec/tests/test_gitwildmatch.py
Expand Up @@ -6,12 +6,7 @@

import re
import sys

try:
# Python 2.6.
import unittest2 as unittest
except ImportError:
import unittest
import unittest

import pathspec.patterns.gitwildmatch
import pathspec.util
Expand Down Expand Up @@ -58,10 +53,10 @@ def test_01_absolute(self):
'an/absolute/file/path/foo',
'foo/an/absolute/file/path',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'an/absolute/file/path',
'an/absolute/file/path/foo',
]))
})

def test_01_absolute_root(self):
"""
Expand Down Expand Up @@ -98,13 +93,13 @@ def test_01_relative(self):
'spam/foo',
'foo/spam/bar',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'spam',
'spam/',
'foo/spam',
'spam/foo',
'foo/spam/bar',
]))
})

def test_01_relative_nested(self):
"""
Expand All @@ -129,10 +124,10 @@ def test_01_relative_nested(self):
'foo/spam/bar',
'bar/foo/spam',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'foo/spam',
'foo/spam/bar',
]))
})

def test_02_comment(self):
"""
Expand Down Expand Up @@ -181,7 +176,7 @@ def test_03_child_double_asterisk(self):
'spam/bar',
'foo/spam/bar',
]))
self.assertEqual(results, set(['spam/bar']))
self.assertEqual(results, {'spam/bar'})

def test_03_inner_double_asterisk(self):
"""
Expand All @@ -208,11 +203,11 @@ def test_03_inner_double_asterisk(self):
'left/bar/right/foo',
'foo/left/bar/right',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'left/bar/right',
'left/foo/bar/right',
'left/bar/right/foo',
]))
})

def test_03_only_double_asterisk(self):
"""
Expand Down Expand Up @@ -240,10 +235,10 @@ def test_03_parent_double_asterisk(self):
'foo/spam',
'foo/spam/bar',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'foo/spam',
'foo/spam/bar',
]))
})

def test_04_infix_wildcard(self):
"""
Expand All @@ -269,13 +264,13 @@ def test_04_infix_wildcard(self):
'foo-hello-bar/b',
'a/foo-hello-bar/b',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'foo--bar',
'foo-hello-bar',
'a/foo-hello-bar',
'foo-hello-bar/b',
'a/foo-hello-bar/b',
]))
})

def test_04_postfix_wildcard(self):
"""
Expand All @@ -301,13 +296,13 @@ def test_04_postfix_wildcard(self):
'foo/~temp-bar',
'foo/~temp-bar/baz',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'~temp-',
'~temp-foo',
'~temp-foo/bar',
'foo/~temp-bar',
'foo/~temp-bar/baz',
]))
})

def test_04_prefix_wildcard(self):
"""
Expand All @@ -331,12 +326,12 @@ def test_04_prefix_wildcard(self):
'foo/bar.py',
'foo/bar.py/baz',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'bar.py',
'bar.py/',
'foo/bar.py',
'foo/bar.py/baz',
]))
})

def test_05_directory(self):
"""
Expand All @@ -363,11 +358,11 @@ def test_05_directory(self):
'foo/dir/bar',
'dir',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'dir/',
'foo/dir/',
'foo/dir/bar',
]))
})

def test_06_registered(self):
"""
Expand Down Expand Up @@ -411,7 +406,7 @@ def test_07_match_bytes_and_bytes(self):
"""
pattern = GitWildMatchPattern(b'*.py')
results = set(pattern.match([b'a.py']))
self.assertEqual(results, set([b'a.py']))
self.assertEqual(results, {b'a.py'})

def test_07_match_bytes_and_bytes_complete(self):
"""
Expand All @@ -421,7 +416,7 @@ def test_07_match_bytes_and_bytes_complete(self):
escaped = b"".join(b"\\" + encoded[i:i+1] for i in range(len(encoded)))
pattern = GitWildMatchPattern(escaped)
results = set(pattern.match([encoded]))
self.assertEqual(results, set([encoded]))
self.assertEqual(results, {encoded})

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

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

@unittest.skipIf(sys.version_info[0] == 2, "Python 2 is lenient")
def test_07_match_unicode_and_bytes_fail(self):
Expand All @@ -467,4 +462,4 @@ def test_07_match_unicode_and_unicode(self):
"""
pattern = GitWildMatchPattern('*.py')
results = set(pattern.match(['a.py']))
self.assertEqual(results, set(['a.py']))
self.assertEqual(results, {'a.py'})
17 changes: 7 additions & 10 deletions pathspec/tests/test_pathspec.py
Expand Up @@ -3,10 +3,7 @@
This script tests ``PathSpec``.
"""

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest

import pathspec

Expand All @@ -33,11 +30,11 @@ def test_01_current_dir_paths(self):
'./src/test2/b.txt',
'./src/test2/c/c.txt',
]))
self.assertEqual(results, set([
self.assertEqual(results, {
'./src/test2/a.txt',
'./src/test2/b.txt',
'./src/test2/c/c.txt',
]))
})

def test_01_match_files(self):
"""
Expand Down Expand Up @@ -77,11 +74,11 @@ def test_01_windows_current_dir_paths(self):
'.\\src\\test2\\b.txt',
'.\\src\\test2\\c\\c.txt',
], separators=('\\',)))
self.assertEqual(results, set([
self.assertEqual(results, {
'.\\src\\test2\\a.txt',
'.\\src\\test2\\b.txt',
'.\\src\\test2\\c\\c.txt',
]))
})

def test_01_windows_paths(self):
"""
Expand All @@ -99,11 +96,11 @@ def test_01_windows_paths(self):
'src\\test2\\b.txt',
'src\\test2\\c\\c.txt',
], separators=('\\',)))
self.assertEqual(results, set([
self.assertEqual(results, {
'src\\test2\\a.txt',
'src\\test2\\b.txt',
'src\\test2\\c\\c.txt',
]))
})

def test_02_eq(self):
"""
Expand Down