Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f90ee80

Browse filesBrowse files
committed
remove six
1 parent 29d3072 commit f90ee80
Copy full SHA for f90ee80

24 files changed

+47
-100
lines changed

‎debug-info.py

Copy file name to clipboardExpand all lines: debug-info.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"maxsize": sys.maxsize
1212
}
1313

14-
search_modules = ["chardet", "genshi", "html5lib", "lxml", "six"]
14+
search_modules = ["chardet", "genshi", "html5lib", "lxml"]
1515
found_modules = []
1616

1717
for m in search_modules:

‎html5lib/_inputstream.py

Copy file name to clipboardExpand all lines: html5lib/_inputstream.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
from six import text_type
3-
from six.moves import http_client, urllib
2+
import http.client
3+
import urllib.response
44

55
import codecs
66
import re
@@ -124,10 +124,10 @@ def _readFromBuffer(self, bytes):
124124
def HTMLInputStream(source, **kwargs):
125125
# Work around Python bug #20007: read(0) closes the connection.
126126
# http://bugs.python.org/issue20007
127-
if (isinstance(source, http_client.HTTPResponse) or
127+
if (isinstance(source, http.client.HTTPResponse) or
128128
# Also check for addinfourl wrapping HTTPResponse
129129
(isinstance(source, urllib.response.addbase) and
130-
isinstance(source.fp, http_client.HTTPResponse))):
130+
isinstance(source.fp, http.client.HTTPResponse))):
131131
isUnicode = False
132132
elif hasattr(source, "read"):
133133
isUnicode = isinstance(source.read(0), text_type)

‎html5lib/_tokenizer.py

Copy file name to clipboardExpand all lines: html5lib/_tokenizer.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
from six import unichr as chr
3-
42
from collections import deque, OrderedDict
53
from sys import version_info
64

‎html5lib/_trie/py.py

Copy file name to clipboardExpand all lines: html5lib/_trie/py.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from six import text_type
2-
31
from bisect import bisect_left
42

53
from ._base import Trie as ABCTrie
64

75

86
class Trie(ABCTrie):
97
def __init__(self, data):
10-
if not all(isinstance(x, text_type) for x in data.keys()):
8+
if not all(isinstance(x, str) for x in data.keys()):
119
raise TypeError("All keys must be strings")
1210

1311
self._data = data

‎html5lib/_utils.py

Copy file name to clipboardExpand all lines: html5lib/_utils.py
+3-11Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33

44
from collections.abc import Mapping
55

6-
from six import text_type, PY3
7-
8-
if PY3:
9-
import xml.etree.ElementTree as default_etree
10-
else:
11-
try:
12-
import xml.etree.ElementTree as default_etree
13-
except ImportError:
14-
import xml.etree.ElementTree as default_etree
6+
import xml.etree.ElementTree as default_etree
157

168

179
__all__ = ["default_etree", "MethodDispatcher", "isSurrogatePair",
@@ -27,10 +19,10 @@
2719
# escapes.
2820
try:
2921
_x = eval('"\\uD800"') # pylint:disable=eval-used
30-
if not isinstance(_x, text_type):
22+
if not isinstance(_x, str):
3123
# We need this with u"" because of http://bugs.jython.org/issue2039
3224
_x = eval('u"\\uD800"') # pylint:disable=eval-used
33-
assert isinstance(_x, text_type)
25+
assert isinstance(_x, str)
3426
except Exception:
3527
supports_lone_surrogates = False
3628
else:

‎html5lib/filters/lint.py

Copy file name to clipboardExpand all lines: html5lib/filters/lint.py
+14-16Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
from six import text_type
3-
42
from . import base
53
from ..constants import namespaces, voidElements
64

@@ -32,9 +30,9 @@ def __iter__(self):
3230
if type in ("StartTag", "EmptyTag"):
3331
namespace = token["namespace"]
3432
name = token["name"]
35-
assert namespace is None or isinstance(namespace, text_type)
33+
assert namespace is None or isinstance(namespace, str)
3634
assert namespace != ""
37-
assert isinstance(name, text_type)
35+
assert isinstance(name, str)
3836
assert name != ""
3937
assert isinstance(token["data"], dict)
4038
if (not namespace or namespace == namespaces["html"]) and name in voidElements:
@@ -44,18 +42,18 @@ def __iter__(self):
4442
if type == "StartTag" and self.require_matching_tags:
4543
open_elements.append((namespace, name))
4644
for (namespace, name), value in token["data"].items():
47-
assert namespace is None or isinstance(namespace, text_type)
45+
assert namespace is None or isinstance(namespace, str)
4846
assert namespace != ""
49-
assert isinstance(name, text_type)
47+
assert isinstance(name, str)
5048
assert name != ""
51-
assert isinstance(value, text_type)
49+
assert isinstance(value, str)
5250

5351
elif type == "EndTag":
5452
namespace = token["namespace"]
5553
name = token["name"]
56-
assert namespace is None or isinstance(namespace, text_type)
54+
assert namespace is None or isinstance(namespace, str)
5755
assert namespace != ""
58-
assert isinstance(name, text_type)
56+
assert isinstance(name, str)
5957
assert name != ""
6058
if (not namespace or namespace == namespaces["html"]) and name in voidElements:
6159
assert False, "Void element reported as EndTag token: %(tag)s" % {"tag": name}
@@ -65,26 +63,26 @@ def __iter__(self):
6563

6664
elif type == "Comment":
6765
data = token["data"]
68-
assert isinstance(data, text_type)
66+
assert isinstance(data, str)
6967

7068
elif type in ("Characters", "SpaceCharacters"):
7169
data = token["data"]
72-
assert isinstance(data, text_type)
70+
assert isinstance(data, str)
7371
assert data != ""
7472
if type == "SpaceCharacters":
7573
assert data.strip(spaceCharacters) == ""
7674

7775
elif type == "Doctype":
7876
name = token["name"]
79-
assert name is None or isinstance(name, text_type)
80-
assert token["publicId"] is None or isinstance(name, text_type)
81-
assert token["systemId"] is None or isinstance(name, text_type)
77+
assert name is None or isinstance(name, str)
78+
assert token["publicId"] is None or isinstance(name, str)
79+
assert token["systemId"] is None or isinstance(name, str)
8280

8381
elif type == "Entity":
84-
assert isinstance(token["name"], text_type)
82+
assert isinstance(token["name"], str)
8583

8684
elif type == "SerializerError":
87-
assert isinstance(token["data"], text_type)
85+
assert isinstance(token["data"], str)
8886

8987
else:
9088
assert False, "Unknown token type: %(type)s" % {"type": type}

‎html5lib/filters/sanitizer.py

Copy file name to clipboardExpand all lines: html5lib/filters/sanitizer.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
import re
1111
import warnings
12+
from urllib.parse import urlparse
1213
from xml.sax.saxutils import escape, unescape
1314

14-
from six.moves import urllib_parse as urlparse
15-
1615
from . import base
1716
from ..constants import namespaces, prefixes
1817

@@ -845,7 +844,7 @@ def allowed_token(self, token):
845844
# remove replacement characters from unescaped characters
846845
val_unescaped = val_unescaped.replace("\ufffd", "")
847846
try:
848-
uri = urlparse.urlparse(val_unescaped)
847+
uri = urlparse(val_unescaped)
849848
except ValueError:
850849
uri = None
851850
del attrs[attr]

‎html5lib/html5parser.py

Copy file name to clipboardExpand all lines: html5lib/html5parser.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from six import viewkeys
2-
31
from . import _inputstream
42
from . import _tokenizer
53

@@ -2773,7 +2771,7 @@ def processEndTag(self, token):
27732771

27742772

27752773
def adjust_attributes(token, replacements):
2776-
needs_adjustment = viewkeys(token['data']) & viewkeys(replacements)
2774+
needs_adjustment = token['data'].keys() & replacements.keys()
27772775
if needs_adjustment:
27782776
token['data'] = type(token['data'])((replacements.get(k, k), v)
27792777
for k, v in token['data'].items())

‎html5lib/serializer.py

Copy file name to clipboardExpand all lines: html5lib/serializer.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from six import text_type
2-
31
import re
42

53
from codecs import register_error, xmlcharrefreplace_errors
@@ -221,14 +219,14 @@ def __init__(self, **kwargs):
221219
self.strict = False
222220

223221
def encode(self, string):
224-
assert isinstance(string, text_type)
222+
assert isinstance(string, str)
225223
if self.encoding:
226224
return string.encode(self.encoding, "htmlentityreplace")
227225
else:
228226
return string
229227

230228
def encodeStrict(self, string):
231-
assert isinstance(string, text_type)
229+
assert isinstance(string, str)
232230
if self.encoding:
233231
return string.encode(self.encoding, "strict")
234232
else:

‎html5lib/tests/test_meta.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_meta.py
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
import six
31
from unittest.mock import Mock
42

53
from . import support
@@ -26,11 +24,7 @@ def test_errorMessage():
2624
r = support.errorMessage(input, expected, actual)
2725

2826
# Assertions!
29-
if six.PY2:
30-
assert b"Input:\n1\nExpected:\n2\nReceived\n3\n" == r
31-
else:
32-
assert six.PY3
33-
assert "Input:\n1\nExpected:\n2\nReceived\n3\n" == r
27+
assert "Input:\n1\nExpected:\n2\nReceived\n3\n" == r
3428

3529
assert input.__repr__.call_count == 1
3630
assert expected.__repr__.call_count == 1

‎html5lib/tests/test_parser2.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_parser2.py
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
from six import PY2, text_type
3-
41
import io
52

63
from . import support # noqa
@@ -73,11 +70,6 @@ def test_debug_log():
7370
('dataState', 'InBodyPhase', 'InBodyPhase', 'processEndTag', {'name': 'p', 'type': 'EndTag'}),
7471
('dataState', 'InBodyPhase', 'InBodyPhase', 'processCharacters', {'type': 'Characters'})]
7572

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

8375

‎html5lib/tests/test_stream.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_stream.py
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import pytest
99

10-
import six
11-
from six.moves import http_client, urllib
10+
import http.client
11+
import urllib.response
1212

1313
from html5lib._inputstream import (BufferedStream, HTMLInputStream,
1414
HTMLUnicodeInputStream, HTMLBinaryInputStream)
@@ -190,7 +190,7 @@ def makefile(self, _mode, _bufsize=None):
190190
# pylint:disable=unused-argument
191191
return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")
192192

193-
source = http_client.HTTPResponse(FakeSocket())
193+
source = http.client.HTTPResponse(FakeSocket())
194194
source.begin()
195195
stream = HTMLInputStream(source)
196196
assert stream.charsUntil(" ") == "Text"
@@ -201,15 +201,12 @@ def test_python_issue_20007_b():
201201
Make sure we have a work-around for Python bug #20007
202202
http://bugs.python.org/issue20007
203203
"""
204-
if six.PY2:
205-
return
206-
207204
class FakeSocket:
208205
def makefile(self, _mode, _bufsize=None):
209206
# pylint:disable=unused-argument
210207
return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")
211208

212-
source = http_client.HTTPResponse(FakeSocket())
209+
source = http.client.HTTPResponse(FakeSocket())
213210
source.begin()
214211
wrapped = urllib.response.addinfourl(source, source.msg, "http://example.com")
215212
stream = HTMLInputStream(wrapped)

‎html5lib/tests/test_tokenizer2.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_tokenizer2.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
import io
33

4-
from six import unichr, text_type
5-
64
from html5lib._tokenizer import HTMLTokenizer
75
from html5lib.constants import tokenTypes
86

@@ -15,7 +13,7 @@ def ignore_parse_errors(toks):
1513

1614
def test_maintain_attribute_order():
1715
# generate loads to maximize the chance a hash-based mutation will occur
18-
attrs = [(unichr(x), text_type(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
16+
attrs = [(chr(x), str(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
1917
stream = io.StringIO("<span " + " ".join("%s='%s'" % (x, i) for x, i in attrs) + ">")
2018

2119
toks = HTMLTokenizer(stream)
@@ -48,7 +46,7 @@ def test_duplicate_attribute():
4846

4947
def test_maintain_duplicate_attribute_order():
5048
# generate loads to maximize the chance a hash-based mutation will occur
51-
attrs = [(unichr(x), text_type(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
49+
attrs = [(chr(x), str(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
5250
stream = io.StringIO("<span " + " ".join("%s='%s'" % (x, i) for x, i in attrs) + " a=100>")
5351

5452
toks = HTMLTokenizer(stream)

‎html5lib/tests/test_treewalkers.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_treewalkers.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import itertools
33
import sys
44

5-
from six import unichr, text_type
65
import pytest
76

87
try:
@@ -150,7 +149,7 @@ def test_maintain_attribute_order(treeName):
150149
pytest.skip("Treebuilder not loaded")
151150

152151
# generate loads to maximize the chance a hash-based mutation will occur
153-
attrs = [(unichr(x), text_type(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
152+
attrs = [(chr(x), str(i)) for i, x in enumerate(range(ord('a'), ord('z')))]
154153
data = "<span " + " ".join("%s='%s'" % (x, i) for x, i in attrs) + ">"
155154

156155
parser = html5parser.HTMLParser(tree=treeAPIs["builder"])

‎html5lib/tests/tokenizer.py

Copy file name to clipboardExpand all lines: html5lib/tests/tokenizer.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66

77
import pytest
8-
from six import unichr
98

109
from html5lib._tokenizer import HTMLTokenizer
1110
from html5lib import constants, _utils
@@ -145,15 +144,15 @@ def repl(m):
145144
low = int(m.group(2), 16)
146145
if 0xD800 <= high <= 0xDBFF and 0xDC00 <= low <= 0xDFFF:
147146
cp = ((high - 0xD800) << 10) + (low - 0xDC00) + 0x10000
148-
return unichr(cp)
147+
return chr(cp)
149148
else:
150-
return unichr(high) + unichr(low)
149+
return chr(high) + chr(low)
151150
else:
152-
return unichr(int(m.group(1), 16))
151+
return chr(int(m.group(1), 16))
153152
try:
154153
return _surrogateRe.sub(repl, inp)
155154
except ValueError:
156-
# This occurs when unichr throws ValueError, which should
155+
# This occurs when chr throws ValueError, which should
157156
# only be for a lone-surrogate.
158157
if _utils.supports_lone_surrogates:
159158
raise

‎html5lib/treebuilders/base.py

Copy file name to clipboardExpand all lines: html5lib/treebuilders/base.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from six import text_type
2-
31
from ..constants import scopingElements, tableInsertModeElements, namespaces
42

53
# The scope markers are inserted when entering object elements,
@@ -199,7 +197,7 @@ def elementInScope(self, target, variant=None):
199197
# match any node with that name
200198
exactNode = hasattr(target, "nameTuple")
201199
if not exactNode:
202-
if isinstance(target, text_type):
200+
if isinstance(target, str):
203201
target = (namespaces["html"], target)
204202
assert isinstance(target, tuple)
205203

@@ -322,7 +320,7 @@ def _setInsertFromTable(self, value):
322320

323321
def insertElementNormal(self, token):
324322
name = token["name"]
325-
assert isinstance(name, text_type), "Element %s not unicode" % name
323+
assert isinstance(name, str), "Element %s not unicode" % name
326324
namespace = token.get("namespace", self.defaultNamespace)
327325
element = self.elementClass(name, namespace)
328326
element.attributes = token["data"]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.