Merge lp:~adiroiban/pocket-lint/907742 into lp:pocket-lint

Proposed by Adi Roiban
Status: Merged
Merged at revision: 465
Proposed branch: lp:~adiroiban/pocket-lint/907742
Merge into: lp:pocket-lint
Diff against target: 64 lines (+35/-1)
2 files modified
pocketlint/formatcheck.py (+24/-1)
pocketlint/tests/test_python.py (+11/-0)
To merge this branch: bzr merge lp:~adiroiban/pocket-lint/907742
Reviewer Review Type Date Requested Status
Curtis Hovey code Approve
Adi Roiban (community) Abstain
Review via email: mp+102882@code.launchpad.net

Description of the change

Hi,

This is my merge proposal for this bug.

I know that users should not be encouraged to ignore pyflakes messages ... but sometimes I just want to shoot myself in the foot without pyflakes complaining about it.

The ignore is valid only for Python and only for pyflakes messages.

Not sure if this should be a general python ignore and have # pocket-lint:ignore

Cheers,
Adi

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

I can merge this after some variable names are made consistent with the module:
    s/filename='(none)'/file_page='(none)'/
    s/line_nr/line_no/

review: Needs Fixing (code)
lp:~adiroiban/pocket-lint/907742 updated
466. By Adi Roiban

Use line_no and file_path to be consistent with the module.

467. By Adi Roiban

Addapt pyflakeschecker.

Revision history for this message
Adi Roiban (adiroiban) wrote :

Hi,

Thanks for the comment.
I have updated and push the changes required for using line_no and file_path.

Adi

review: Needs Resubmitting
lp:~adiroiban/pocket-lint/907742 updated
468. By Adi Roiban

Use file_path instead of file_name.

Revision history for this message
Adi Roiban (adiroiban) :
review: Abstain
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you. I have merged this.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'pocketlint/formatcheck.py'
--- pocketlint/formatcheck.py 2012-02-02 13:32:30 +0000
+++ pocketlint/formatcheck.py 2012-04-20 16:56:19 +0000
@@ -73,6 +73,28 @@
73 This is here to work around some of the pyflakes problems.73 This is here to work around some of the pyflakes problems.
74 '''74 '''
7575
76 def __init__(self, tree, file_path='(none)', text=None):
77 self.text = text
78 if self.text:
79 self.text = self.text.split('\n')
80 super(PocketLintPyFlakesChecker, self).__init__(
81 tree=tree, filename=file_path)
82
83 @property
84 def file_path(self):
85 '''Alias for consistency with the rest of pocketlint.'''
86 return self.filename
87
88 def report(self, messageClass, *args, **kwargs):
89 '''Filter some errors not used in our project.'''
90 line_no = args[0] - 1
91
92 # Ignore explicit pyflakes:ignore requests.
93 if self.text and self.text[line_no].find('pyflakes:ignore') >= 0:
94 return
95
96 self.messages.append(messageClass(self.file_path, *args, **kwargs))
97
76 def NAME(self, node):98 def NAME(self, node):
77 '''Locate name. Ignore WindowsErrors.'''99 '''Locate name. Ignore WindowsErrors.'''
78 if node.id == 'WindowsError':100 if node.id == 'WindowsError':
@@ -513,7 +535,8 @@
513 message = '%s: %s' % (explanation, line.strip())535 message = '%s: %s' % (explanation, line.strip())
514 self.message(line_no, message, icon='error')536 self.message(line_no, message, icon='error')
515 else:537 else:
516 warnings = PocketLintPyFlakesChecker(tree, self.file_path)538 warnings = PocketLintPyFlakesChecker(
539 tree, file_path=self.file_path, text=self.text)
517 for warning in warnings.messages:540 for warning in warnings.messages:
518 dummy, line_no, message = str(warning).split(':')541 dummy, line_no, message = str(warning).split(':')
519 self.message(int(line_no), message.strip(), icon='error')542 self.message(int(line_no), message.strip(), icon='error')
520543
=== modified file 'pocketlint/tests/test_python.py'
--- pocketlint/tests/test_python.py 2012-01-29 21:24:20 +0000
+++ pocketlint/tests/test_python.py 2012-04-20 16:56:19 +0000
@@ -136,6 +136,17 @@
136 self.reporter.messages)136 self.reporter.messages)
137 self.assertEqual(2, self.reporter.call_count)137 self.assertEqual(2, self.reporter.call_count)
138138
139 def test_pyflakes_ignore(self):
140 pyflakes_ignore = (
141 'def something():\n'
142 ' unused_variable = 1 # pyflakes:ignore\n'
143 )
144 self.reporter.call_count = 0
145 checker = PythonChecker('bogus', pyflakes_ignore, self.reporter)
146 checker.check_flakes()
147 self.assertEqual([], self.reporter.messages)
148 self.assertEqual(0, self.reporter.call_count)
149
139150
140class TestPEP8(CheckerTestCase):151class TestPEP8(CheckerTestCase):
141 """Verify PEP8 integration."""152 """Verify PEP8 integration."""

Subscribers

People subscribed via source and target branches

to all changes: