Fix pyflakes-bypass for PyFlakes 0.7

Don't make assumptions about argument types, get the line number from the
message object.

Fixes bug #1171420

Change-Id: Id0b1b254a1561941dea8ab5bb23aea1f936e7f0b
This commit is contained in:
Zane Bitter 2013-04-22 18:24:56 +02:00
parent 4ce8855fbc
commit 78f0da46f2

View File

@ -3,11 +3,11 @@ from pyflakes.checker import Checker
def report_with_bypass(self, messageClass, *args, **kwargs):
text_lineno = args[0] - 1
message = messageClass(self.filename, *args, **kwargs)
with open(self.filename, 'r') as code:
if code.readlines()[text_lineno].find('pyflakes_bypass') >= 0:
if 'pyflakes_bypass' in code.readlines()[message.lineno - 1]:
return
self.messages.append(messageClass(self.filename, *args, **kwargs))
self.messages.append(message)
# monkey patch checker to support bypass
Checker.report = report_with_bypass