Skip to content

Commit 8d65869

Browse files
committed
Fix issue with --select and flake8 extensions; issue #216
1 parent bbea542 commit 8d65869

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ Changelog
22
=========
33

44

5+
1.x (unreleased)
6+
----------------
7+
8+
* Fix ignoring too many checks when ``--select`` is used with codes
9+
declared in a flake8 extension. (Issue #216)
10+
11+
512
1.4.6 (2013-07-02)
613
------------------
714

pep8.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
700 statements
4646
900 syntax error
4747
"""
48-
__version__ = '1.4.6'
48+
__version__ = '1.4.7a0'
4949

5050
import os
5151
import sys
@@ -1678,6 +1678,9 @@ def ignore_code(self, code):
16781678
return False. Else, if 'options.ignore' contains a prefix of
16791679
the error code, return True.
16801680
"""
1681+
if len(code) < 4 and any(s.startswith(code)
1682+
for s in self.options.select):
1683+
return False
16811684
return (code.startswith(self.options.ignore) and
16821685
not code.startswith(self.options.select))
16831686

testsuite/test_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ def parse_argv(argstring):
219219
self.assertFalse(pep8style.ignore_code('W191'))
220220
self.assertTrue(pep8style.ignore_code('E241'))
221221

222+
pep8style = pep8.StyleGuide(select=('F401',), paths=[E11])
223+
self.assertEqual(pep8style.options.select, ('F401',))
224+
self.assertEqual(pep8style.options.ignore, ('',))
225+
self.assertFalse(pep8style.ignore_code('F'))
226+
self.assertFalse(pep8style.ignore_code('F401'))
227+
self.assertTrue(pep8style.ignore_code('F402'))
228+
222229
def test_styleguide_excluded(self):
223230
pep8style = pep8.StyleGuide(paths=[E11])
224231

0 commit comments

Comments
 (0)