Skip to content

Commit c10df71

Browse files
committed
fixup! Fix more flake8 issues.
1 parent 5b3cb35 commit c10df71

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

html5lib/treebuilders/etree_lxml.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
fullTree = True
3030
tag_regexp = re.compile("{([^}]*)}(.*)")
3131

32+
comment_type = etree.Comment("asd").tag
33+
3234

3335
class DocumentType(object):
3436
def __init__(self, name, publicId, systemId):
@@ -86,7 +88,7 @@ def serializeElement(element, indent=0):
8688
rv.append("#document-fragment")
8789
for next_element in element:
8890
serializeElement(next_element, indent + 2)
89-
elif isinstance(element.tag, etree.Comment):
91+
elif element.tag == comment_type:
9092
rv.append("|%s<!-- %s -->" % (' ' * indent, element.text))
9193
if hasattr(element, "tail") and element.tail:
9294
rv.append("|%s\"%s\"" % (' ' * indent, element.tail))
@@ -149,7 +151,7 @@ def serializeElement(element):
149151
rv.append(dtd_str)
150152
serializeElement(element.getroot())
151153

152-
elif isinstance(element.tag, etree.Comment):
154+
elif element.tag == comment_type:
153155
rv.append("<!--%s-->" % (element.text,))
154156

155157
else:
@@ -301,7 +303,7 @@ def insertCommentInitial(self, data, parent=None):
301303

302304
def insertCommentMain(self, data, parent=None):
303305
if (parent == self.document and
304-
isinstance(self.document._elementTree.getroot()[-1].tag, etree.Comment)):
306+
self.document._elementTree.getroot()[-1].tag == comment_type):
305307
warnings.warn("lxml cannot represent adjacent comments beyond the root elements", DataLossWarning)
306308
super(TreeBuilder, self).insertComment(data, parent)
307309

0 commit comments

Comments
 (0)