Skip to content

Commit f375ba8

Browse files
committed
Remove six
1 parent 2f1d6e0 commit f375ba8

25 files changed

+13
-52
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cache: pip
1010

1111
env:
1212
global:
13-
- TOXENV=base,optional,six19-optional
13+
- TOXENV=base,optional
1414

1515
install:
1616
- pip install tox

debug-info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"maxsize": sys.maxsize
1111
}
1212

13-
search_modules = ["chardet", "genshi", "html5lib", "lxml", "six"]
13+
search_modules = ["chardet", "genshi", "html5lib", "lxml"]
1414
found_modules = []
1515

1616
for m in search_modules:

html5lib/_inputstream.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from six import text_type
2-
from six.moves import http_client, urllib
3-
41
import codecs
2+
import http.client
53
import re
4+
import urllib
65
from io import BytesIO, StringIO
76

87
import webencodings
@@ -123,10 +122,10 @@ def _readFromBuffer(self, bytes):
123122
def HTMLInputStream(source, **kwargs):
124123
# Work around Python bug #20007: read(0) closes the connection.
125124
# http://bugs.python.org/issue20007
126-
if (isinstance(source, http_client.HTTPResponse) or
125+
if (isinstance(source, http.client.HTTPResponse) or
127126
# Also check for addinfourl wrapping HTTPResponse
128127
(isinstance(source, urllib.response.addbase) and
129-
isinstance(source.fp, http_client.HTTPResponse))):
128+
isinstance(source.fp, http.client.HTTPResponse))):
130129
isUnicode = False
131130
elif hasattr(source, "read"):
132131
isUnicode = isinstance(source.read(0), str)

html5lib/_tokenizer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from six import unichr as chr
2-
31
from collections import deque, OrderedDict
42
from sys import version_info
53

html5lib/_trie/py.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from six import text_type
21

32
from bisect import bisect_left
43

html5lib/_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from collections.abc import Mapping
44

5-
from six import text_type, PY3
65

76
import xml.etree.ElementTree as default_etree
87

html5lib/filters/lint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from six import text_type
21

32
from . import base
43
from ..constants import namespaces, voidElements

html5lib/filters/sanitizer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
import re
1111
import warnings
1212
from xml.sax.saxutils import escape, unescape
13-
14-
from six.moves import urllib_parse as urlparse
13+
import urllib.parse
1514

1615
from . import base
1716
from ..constants import namespaces, prefixes
@@ -837,7 +836,7 @@ def allowed_token(self, token):
837836
# remove replacement characters from unescaped characters
838837
val_unescaped = val_unescaped.replace("\ufffd", "")
839838
try:
840-
uri = urlparse.urlparse(val_unescaped)
839+
uri = urllib.parse.urlparse(val_unescaped)
841840
except ValueError:
842841
uri = None
843842
del attrs[attr]

html5lib/html5parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from six import with_metaclass, viewkeys
21

32
import types
43

html5lib/serializer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from six import text_type
21

32
import re
43

html5lib/tests/test_meta.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import six
21
from unittest.mock import Mock
32

43
from . import support
@@ -25,7 +24,6 @@ def test_errorMessage():
2524
r = support.errorMessage(input, expected, actual)
2625

2726
# Assertions!
28-
assert six.PY3
2927
assert "Input:\n1\nExpected:\n2\nReceived\n3\n" == r
3028

3129
assert input.__repr__.call_count == 1

html5lib/tests/test_parser2.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from six import PY2, text_type
2-
31
import io
42

53
from . import support # noqa
@@ -73,11 +71,6 @@ def test_debug_log():
7371
('dataState', 'InBodyPhase', 'InBodyPhase', 'processEndTag', {'name': 'p', 'type': 'EndTag'}),
7472
('dataState', 'InBodyPhase', 'InBodyPhase', 'processCharacters', {'type': 'Characters'})]
7573

76-
if PY2:
77-
for i, log in enumerate(expected):
78-
log = [x.encode("ascii") if isinstance(x, str) else x for x in log]
79-
expected[i] = tuple(log)
80-
8174
assert parser.log == expected
8275

8376

html5lib/tests/test_stream.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from . import support # noqa
22

33
import codecs
4+
import http.client
45
import sys
6+
import urllib
57
from io import BytesIO, StringIO
68

79
import pytest
810

9-
import six
10-
from six.moves import http_client, urllib
11-
1211
from html5lib._inputstream import (BufferedStream, HTMLInputStream,
1312
HTMLUnicodeInputStream, HTMLBinaryInputStream)
1413
from html5lib._utils import supports_lone_surrogates
@@ -189,7 +188,7 @@ def makefile(self, _mode, _bufsize=None):
189188
# pylint:disable=unused-argument
190189
return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")
191190

192-
source = http_client.HTTPResponse(FakeSocket())
191+
source = http.client.HTTPResponse(FakeSocket())
193192
source.begin()
194193
stream = HTMLInputStream(source)
195194
assert stream.charsUntil(" ") == "Text"
@@ -200,15 +199,12 @@ def test_python_issue_20007_b():
200199
Make sure we have a work-around for Python bug #20007
201200
http://bugs.python.org/issue20007
202201
"""
203-
if six.PY2:
204-
return
205-
206202
class FakeSocket:
207203
def makefile(self, _mode, _bufsize=None):
208204
# pylint:disable=unused-argument
209205
return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")
210206

211-
source = http_client.HTTPResponse(FakeSocket())
207+
source = http.client.HTTPResponse(FakeSocket())
212208
source.begin()
213209
wrapped = urllib.response.addinfourl(source, source.msg, "http://example.com")
214210
stream = HTMLInputStream(wrapped)

html5lib/tests/test_tokenizer2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import io
22

3-
from six import unichr, text_type
43

54
from html5lib._tokenizer import HTMLTokenizer
65
from html5lib.constants import tokenTypes

html5lib/tests/test_treewalkers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import itertools
22
import sys
33

4-
from six import unichr, text_type
54
import pytest
65

76
try:

html5lib/tests/tokenizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55

66
import pytest
7-
from six import unichr
87

98
from html5lib._tokenizer import HTMLTokenizer
109
from html5lib import constants, _utils

html5lib/treebuilders/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from six import text_type
21

32
from ..constants import scopingElements, tableInsertModeElements, namespaces
43

html5lib/treebuilders/etree.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# pylint:disable=protected-access
22

3-
from six import text_type
43

54
import re
65

html5lib/treebuilders/etree_lxml.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from .. import _ihatexml
2424

2525
import lxml.etree as etree
26-
from six import PY3, binary_type
2726

2827

2928
fullTree = True
@@ -203,8 +202,6 @@ def _coerceKey(self, key):
203202

204203
def __getitem__(self, key):
205204
value = self._element._element.attrib[self._coerceKey(key)]
206-
if not PY3 and isinstance(value, bytes):
207-
value = value.decode("ascii")
208205
return value
209206

210207
def __setitem__(self, key, value):

html5lib/treewalkers/etree.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections import OrderedDict
22
import re
33

4-
from six import string_types
54

65
from . import base
76
from .._utils import moduleFactoryFactory

html5lib/treewalkers/etree_lxml.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from six import text_type
21

32
from collections import OrderedDict
43

requirements-install.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/bin/bash -ex
22

3-
if [[ $SIX_VERSION ]]; then
4-
pip install six==$SIX_VERSION
5-
fi
6-
73
pip install -r requirements-test.txt
84

95
if [[ $USE_OPTIONAL == "true" ]]; then

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
six>=1.9
21
webencodings

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def default_environment():
9898
maintainer_email='james@hoppipolla.co.uk',
9999
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
100100
install_requires=[
101-
'six>=1.9',
102101
'webencodings',
103102
],
104103
python_requires=">=3.6",

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{36,37,38,py3}-{base,six19,optional}
2+
envlist = py{36,37,38,py3}-{base,optional}
33

44
[testenv]
55
deps =
@@ -11,7 +11,6 @@ passenv =
1111
PYTEST_COMMAND # this is maintained so one can, e.g., PYTEST_COMMAND="coverage run -m pytest"
1212
COVERAGE_RUN_OPTIONS
1313
commands =
14-
six19: pip install six==1.9
1514
{env:PYTEST_COMMAND:{envbindir}/py.test} {posargs}
1615
flake8 {toxinidir}
1716

0 commit comments

Comments
 (0)