Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prospector and fix some bugs #218

Merged
merged 27 commits into from
May 20, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c64bfca
Get rid of mutable default arguments
gsnedders Dec 3, 2015
c1c16ce
Avoid noisiness from pylint and the parser's set patterns
gsnedders Dec 4, 2015
2c3b64b
add pep8/flake8 config to get something useful happening with them
gsnedders May 20, 2016
8238648
Fix all the files outside of html5lib to flake8 cleanly
gsnedders May 20, 2016
de6bcf2
Fix incorrectly hidden flake8 errors
gsnedders May 20, 2016
0bd31c4
Get rid of type()-based type-check
gsnedders May 20, 2016
d440a83
Silence pytest unused-variable warnings
gsnedders May 20, 2016
5c1d8e2
Remove duplicate entry from constants.replacementCharacters
gsnedders May 20, 2016
1b86ccb
Remove gratuitious argument in sanitizer
gsnedders May 20, 2016
82d623b
Silence redefined-variable-type
gsnedders May 20, 2016
a017b88
Silence unused-argument
gsnedders May 20, 2016
e5d395c
Silence wrong-import-position
gsnedders May 20, 2016
b64df28
Change which way around we overwrite this for clarity's sake
gsnedders May 20, 2016
df0b2ba
Remove unused import
gsnedders May 20, 2016
742715d
Fix invalid_unicode_re on platforms supporting lone surrogates
gsnedders May 20, 2016
cd74ec7
Fix comment
gsnedders May 20, 2016
15e126f
Silence eval-used
gsnedders May 20, 2016
bfc278a
Silence bare-except
gsnedders May 20, 2016
b46fcdf
Silence too-many-nested-blocks
gsnedders May 20, 2016
6945bc4
Silence not-callable
gsnedders May 20, 2016
0c290e0
Kill long-dead finalText code
gsnedders May 20, 2016
da099dc
Silence a buggily output non-parent-init-called
gsnedders May 20, 2016
97427de
Fix indentation
gsnedders May 20, 2016
2afe09b
Make this in practice unreachable code work on Py2
gsnedders May 20, 2016
c0df867
Silence arguments-differ
gsnedders May 20, 2016
5dce4f2
Silence protected-access
gsnedders May 20, 2016
a2b8c11
Add prospector/pylint config for the sake of Landscape.
gsnedders Dec 4, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Silence pytest unused-variable warnings
  • Loading branch information
gsnedders committed May 20, 2016
commit d440a830fb75beafed838327c21e9a8a773c9743
2 changes: 1 addition & 1 deletion html5lib/ihatexml.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def coerceComment(self, data):

def coerceCharacters(self, data):
if self.replaceFormFeedCharacters:
for i in range(data.count("\x0C")):
for _ in range(data.count("\x0C")):
warnings.warn("Text cannot contain U+000C", DataLossWarning)
data = data.replace("\x0C", " ")
# Other non-xml characters
Expand Down
4 changes: 2 additions & 2 deletions html5lib/inputstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def readChunk(self, chunkSize=None):
return True

def characterErrorsUCS4(self, data):
for i in range(len(invalid_unicode_re.findall(data))):
for _ in range(len(invalid_unicode_re.findall(data))):
self.errors.append("invalid-codepoint")

def characterErrorsUCS2(self, data):
Expand Down Expand Up @@ -681,7 +681,7 @@ def getEncoding(self):
(b"<!", self.handleOther),
(b"<?", self.handleOther),
(b"<", self.handlePossibleStartTag))
for byte in self.data:
for _ in self.data:
keepParsing = True
for key, method in methodDispatch:
if self.data.matchBytes(key):
Expand Down
2 changes: 1 addition & 1 deletion html5lib/serializer/htmlserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def serialize(self, treewalker, encoding=None):
in_cdata = True
elif in_cdata:
self.serializeError("Unexpected child element of a CDATA element")
for (attr_namespace, attr_name), attr_value in token["data"].items():
for (_, attr_name), attr_value in token["data"].items():
# TODO: Add namespace support here
k = attr_name
v = attr_value
Expand Down
2 changes: 1 addition & 1 deletion html5lib/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def runPreScanEncodingTest(data, encoding):
def test_encoding():
for filename in get_data_files("encoding"):
tests = _TestData(filename, b"data", encoding=None)
for idx, test in enumerate(tests):
for test in tests:
yield (runParserEncodingTest, test[b'data'], test[b'encoding'])
yield (runPreScanEncodingTest, test[b'data'], test[b'encoding'])

Expand Down
2 changes: 1 addition & 1 deletion html5lib/tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@ def test_serializer():
for filename in get_data_files('serializer-testdata', '*.test', os.path.dirname(__file__)):
with open(filename) as fp:
tests = json.load(fp)
for index, test in enumerate(tests['tests']):
for test in tests['tests']:
yield runSerializerTest, test["input"], test["expected"], test.get("options", {})
2 changes: 1 addition & 1 deletion html5lib/tests/test_treewalkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_all_tokens():
{'type': 'EndTag', 'namespace': 'http:https://www.w3.org/1999/xhtml', 'name': 'body'},
{'type': 'EndTag', 'namespace': 'http:https://www.w3.org/1999/xhtml', 'name': 'html'}
]
for treeName, treeCls in sorted(treeTypes.items()):
for _, treeCls in sorted(treeTypes.items()):
if treeCls is None:
continue
p = html5parser.HTMLParser(tree=treeCls["builder"])
Expand Down
4 changes: 2 additions & 2 deletions html5lib/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ def attributeNameState(self):
if self.lowercaseAttrName:
self.currentToken["data"][-1][0] = (
self.currentToken["data"][-1][0].translate(asciiUpper2Lower))
for name, value in self.currentToken["data"][:-1]:
for name, _ in self.currentToken["data"][:-1]:
if self.currentToken["data"][-1][0] == name:
self.tokenQueue.append({"type": tokenTypes["ParseError"], "data":
"duplicate-attribute"})
Expand Down Expand Up @@ -1720,7 +1720,7 @@ def cdataSectionState(self):
# Deal with null here rather than in the parser
nullCount = data.count("\u0000")
if nullCount > 0:
for i in range(nullCount):
for _ in range(nullCount):
self.tokenQueue.append({"type": tokenTypes["ParseError"],
"data": "invalid-codepoint"})
data = data.replace("\u0000", "\uFFFD")
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treebuilders/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def getNameTuple(self):

nameTuple = property(getNameTuple)

class TreeBuilder(_base.TreeBuilder):
class TreeBuilder(_base.TreeBuilder): # pylint:disable=unused-variable
def documentClass(self):
self.dom = Dom.getDOMImplementation().createDocument(None, None, None)
return weakref.proxy(self)
Expand Down
4 changes: 2 additions & 2 deletions html5lib/treebuilders/etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def serializeElement(element, indent=0):

return "\n".join(rv)

def tostring(element):
def tostring(element): # pylint:disable=unused-variable
"""Serialize an element and its child nodes to a string"""
rv = []
filter = ihatexml.InfosetFilter()
Expand Down Expand Up @@ -307,7 +307,7 @@ def serializeElement(element):

return "".join(rv)

class TreeBuilder(_base.TreeBuilder):
class TreeBuilder(_base.TreeBuilder): # pylint:disable=unused-variable
documentClass = Document
doctypeClass = DocumentType
elementClass = Element
Expand Down
4 changes: 2 additions & 2 deletions html5lib/treewalkers/etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getETreeBuilder(ElementTreeImplementation):
ElementTree = ElementTreeImplementation
ElementTreeCommentType = ElementTree.Comment("asd").tag

class TreeWalker(_base.NonRecursiveTreeWalker):
class TreeWalker(_base.NonRecursiveTreeWalker): # pylint:disable=unused-variable
"""Given the particular ElementTree representation, this implementation,
to avoid using recursion, returns "nodes" as tuples with the following
content:
Expand All @@ -38,7 +38,7 @@ class TreeWalker(_base.NonRecursiveTreeWalker):
"""
def getNodeDetails(self, node):
if isinstance(node, tuple): # It might be the root Element
elt, key, parents, flag = node
elt, _, _, flag = node
if flag in ("text", "tail"):
return _base.TEXT, getattr(elt, flag)
else:
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treewalkers/genshistream.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __iter__(self):
yield token

def tokens(self, event, next):
kind, data, pos = event
kind, data, _ = event
if kind == START:
tag, attribs = data
name = tag.localname
Expand Down