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
1=== modified file 'pocketlint/formatcheck.py'
2--- pocketlint/formatcheck.py 2012-02-02 13:32:30 +0000
3+++ pocketlint/formatcheck.py 2012-04-20 16:56:19 +0000
4@@ -73,6 +73,28 @@
5 This is here to work around some of the pyflakes problems.
6 '''
7
8+ def __init__(self, tree, file_path='(none)', text=None):
9+ self.text = text
10+ if self.text:
11+ self.text = self.text.split('\n')
12+ super(PocketLintPyFlakesChecker, self).__init__(
13+ tree=tree, filename=file_path)
14+
15+ @property
16+ def file_path(self):
17+ '''Alias for consistency with the rest of pocketlint.'''
18+ return self.filename
19+
20+ def report(self, messageClass, *args, **kwargs):
21+ '''Filter some errors not used in our project.'''
22+ line_no = args[0] - 1
23+
24+ # Ignore explicit pyflakes:ignore requests.
25+ if self.text and self.text[line_no].find('pyflakes:ignore') >= 0:
26+ return
27+
28+ self.messages.append(messageClass(self.file_path, *args, **kwargs))
29+
30 def NAME(self, node):
31 '''Locate name. Ignore WindowsErrors.'''
32 if node.id == 'WindowsError':
33@@ -513,7 +535,8 @@
34 message = '%s: %s' % (explanation, line.strip())
35 self.message(line_no, message, icon='error')
36 else:
37- warnings = PocketLintPyFlakesChecker(tree, self.file_path)
38+ warnings = PocketLintPyFlakesChecker(
39+ tree, file_path=self.file_path, text=self.text)
40 for warning in warnings.messages:
41 dummy, line_no, message = str(warning).split(':')
42 self.message(int(line_no), message.strip(), icon='error')
43
44=== modified file 'pocketlint/tests/test_python.py'
45--- pocketlint/tests/test_python.py 2012-01-29 21:24:20 +0000
46+++ pocketlint/tests/test_python.py 2012-04-20 16:56:19 +0000
47@@ -136,6 +136,17 @@
48 self.reporter.messages)
49 self.assertEqual(2, self.reporter.call_count)
50
51+ def test_pyflakes_ignore(self):
52+ pyflakes_ignore = (
53+ 'def something():\n'
54+ ' unused_variable = 1 # pyflakes:ignore\n'
55+ )
56+ self.reporter.call_count = 0
57+ checker = PythonChecker('bogus', pyflakes_ignore, self.reporter)
58+ checker.check_flakes()
59+ self.assertEqual([], self.reporter.messages)
60+ self.assertEqual(0, self.reporter.call_count)
61+
62
63 class TestPEP8(CheckerTestCase):
64 """Verify PEP8 integration."""

Subscribers

People subscribed via source and target branches

to all changes: