Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitd12331e

Browse files
committed
Fix more flake8 issues.
It turns out flake8's behaviour differs between Python 2 and Python 3because of the changes between the two, so run it on both on Travis.
1 parenta8b40b2 commitd12331e

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

‎.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ matrix:
1414
exclude:
1515
-python:"2.7"
1616
env:USE_OPTIONAL=false
17+
-python:"3.3"
18+
env:USE_OPTIONAL=false
1719
include:
1820
-python:"2.7"
1921
env:USE_OPTIONAL=false FLAKE=true
22+
-python:"3.3"
23+
env:USE_OPTIONAL=false FLAKE=true
2024

2125
before_install:
2226
-git submodule update --init --recursive

‎html5lib/tests/tokenizertotree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def main(out_path):
2525

2626
defrun_file(filename,out_path):
2727
try:
28-
tests_data=json.load(file(filename))
28+
tests_data=json.load(open(filename,"r"))
2929
exceptValueError:
3030
sys.stderr.write("Failed to load %s\n"%filename)
3131
return

‎html5lib/tokenizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__importabsolute_import,division,unicode_literals
22

33
try:
4-
chr=unichr
4+
chr=unichr# flake8: noqa
55
exceptNameError:
66
pass
77

‎html5lib/treebuilders/etree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def tostring(element):
259259
filter=ihatexml.InfosetFilter()
260260

261261
defserializeElement(element):
262-
iftype(element)==type(ElementTree.ElementTree):
262+
ifisinstance(element,ElementTree.ElementTree):
263263
element=element.getroot()
264264

265265
ifelement.tag=="<!DOCTYPE>":

‎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
classDocumentType(object):
3436
def__init__(self,name,publicId,systemId):
@@ -86,7 +88,7 @@ def serializeElement(element, indent=0):
8688
rv.append("#document-fragment")
8789
fornext_elementinelement:
8890
serializeElement(next_element,indent+2)
89-
eliftype(element.tag)==type(etree.Comment):
91+
elifelement.tag==comment_type:
9092
rv.append("|%s<!-- %s -->"% (' '*indent,element.text))
9193
ifhasattr(element,"tail")andelement.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-
eliftype(element.tag)==type(etree.Comment):
154+
elifelement.tag==comment_type:
153155
rv.append("<!--%s-->"% (element.text,))
154156

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

302304
definsertCommentMain(self,data,parent=None):
303305
if (parent==self.documentand
304-
type(self.document._elementTree.getroot()[-1].tag)==type(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)

[8]ページ先頭

©2009-2025 Movatter.jp