From 05c7a6f2b4a8c5450c59283e852490f015d4cdd6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 11 Oct 2022 10:04:11 +0200 Subject: [PATCH 1/2] Bump Flake8 to fix AttributeError: 'EntryPoints' object has no attribute 'get' on Python 3.7 --- requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-test.txt b/requirements-test.txt index 57f8f617..8c0ca7c7 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,7 @@ -r requirements.txt tox>=3.15.1,<4 -flake8>=3.8.1,<3.9 +flake8>=3.8.1,<6 pytest>=4.6.10,<5 ; python_version < '3' pytest>=5.4.2,<7 ; python_version >= '3' coverage>=5.1,<6 From 04c0e800a6933ba53288196a8790b3d1c433acde Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 11 Oct 2022 10:14:24 +0200 Subject: [PATCH 2/2] Fix new Flake8 errors --- html5lib/_inputstream.py | 2 +- html5lib/serializer.py | 4 ++-- html5lib/tests/test_serializer.py | 2 +- html5lib/treebuilders/etree.py | 4 ++-- html5lib/treewalkers/etree.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/html5lib/_inputstream.py b/html5lib/_inputstream.py index 0207dd21..a93b5a4e 100644 --- a/html5lib/_inputstream.py +++ b/html5lib/_inputstream.py @@ -324,7 +324,7 @@ def charsUntil(self, characters, opposite=False): except KeyError: if __debug__: for c in characters: - assert(ord(c) < 128) + assert ord(c) < 128 regex = "".join(["\\x%02x" % ord(c) for c in characters]) if not opposite: regex = "^%s" % regex diff --git a/html5lib/serializer.py b/html5lib/serializer.py index c66df683..a171ac1c 100644 --- a/html5lib/serializer.py +++ b/html5lib/serializer.py @@ -222,14 +222,14 @@ def __init__(self, **kwargs): self.strict = False def encode(self, string): - assert(isinstance(string, text_type)) + assert isinstance(string, text_type) if self.encoding: return string.encode(self.encoding, "htmlentityreplace") else: return string def encodeStrict(self, string): - assert(isinstance(string, text_type)) + assert isinstance(string, text_type) if self.encoding: return string.encode(self.encoding, "strict") else: diff --git a/html5lib/tests/test_serializer.py b/html5lib/tests/test_serializer.py index bce62459..a2be0be5 100644 --- a/html5lib/tests/test_serializer.py +++ b/html5lib/tests/test_serializer.py @@ -74,7 +74,7 @@ def _convertAttrib(self, attribs): attrs = {} for attrib in attribs: name = (attrib["namespace"], attrib["name"]) - assert(name not in attrs) + assert name not in attrs attrs[name] = attrib["value"] return attrs diff --git a/html5lib/treebuilders/etree.py b/html5lib/treebuilders/etree.py index 086bed4e..0b745081 100644 --- a/html5lib/treebuilders/etree.py +++ b/html5lib/treebuilders/etree.py @@ -108,7 +108,7 @@ def removeChild(self, node): node.parent = None def insertText(self, data, insertBefore=None): - if not(len(self._element)): + if not len(self._element): if not self._element.text: self._element.text = "" self._element.text += data @@ -201,7 +201,7 @@ def testSerializer(element): rv = [] def serializeElement(element, indent=0): - if not(hasattr(element, "tag")): + if not hasattr(element, "tag"): element = element.getroot() if element.tag == "": if element.get("publicId") or element.get("systemId"): diff --git a/html5lib/treewalkers/etree.py b/html5lib/treewalkers/etree.py index 44653372..411a1d45 100644 --- a/html5lib/treewalkers/etree.py +++ b/html5lib/treewalkers/etree.py @@ -37,7 +37,7 @@ def getNodeDetails(self, node): else: node = elt - if not(hasattr(node, "tag")): + if not hasattr(node, "tag"): node = node.getroot() if node.tag in ("DOCUMENT_ROOT", "DOCUMENT_FRAGMENT"):