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

Fix ignore-names option initialization #111

Merged
merged 2 commits into from Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
@@ -1,6 +1,11 @@
Changes
=======

0.8.2 - 2019-02-04
------------------

* Fix a problem with ``ignore-names`` option initialization.

0.8.1 - 2019-02-04
------------------

Expand Down
23 changes: 12 additions & 11 deletions src/pep8ext_naming.py
Expand Up @@ -12,7 +12,7 @@
except ImportError:
from flake8.util import ast, iter_child_nodes

__version__ = '0.8.1'
__version__ = '0.8.2'

PYTHON_VERSION = sys.version_info[:3]
PY2 = PYTHON_VERSION[0] == 2
Expand Down Expand Up @@ -83,6 +83,15 @@ class _FunctionType(object):
METHOD = 'method'


_default_ignore_names = [
'setUp',
'tearDown',
'setUpClass',
'tearDownClass',
'setUpTestData',
'failureException',
'longMessage',
'maxDiff']
_default_classmethod_decorators = ['classmethod']
_default_staticmethod_decorators = ['staticmethod']

Expand All @@ -102,15 +111,7 @@ class NamingChecker(object):
version = __version__
decorator_to_type = _build_decorator_to_type(
_default_classmethod_decorators, _default_staticmethod_decorators)
ignore_names = [
'setUp',
'tearDown',
'setUpClass',
'tearDownClass',
'setUpTestData',
'failureException',
'longMessage',
'maxDiff']
ignore_names = frozenset(_default_ignore_names)

def __init__(self, tree, filename):
self.visitors = BaseASTCheck._checks
Expand All @@ -120,7 +121,7 @@ def __init__(self, tree, filename):
@classmethod
def add_options(cls, parser):
options.register(parser, '--ignore-names',
default=cls.ignore_names,
default=_default_ignore_names,
action='store',
type='string',
parse_from_config=True,
Expand Down
3 changes: 3 additions & 0 deletions testsuite/N801.py
@@ -1,4 +1,7 @@
#: N801
class notok(object):
pass
#: Okay(--ignore-names=notok)
class notok(object):
pass
#: N801
Expand Down
7 changes: 7 additions & 0 deletions testsuite/N802.py
Expand Up @@ -17,6 +17,9 @@ def go_od_():
def _go_od_():
pass
#: N802:1:5
def NotOK():
pass
#: Okay(--ignore-names=NotOK)
def NotOK():
pass
#: Okay
Expand All @@ -35,6 +38,10 @@ class ClassName(object):
def __method__(self):
pass
#: N802
class ClassName(object):
def notOk(self):
pass
#: Okay(--ignore-names=notOk)
class ClassName(object):
def notOk(self):
pass
Expand Down
3 changes: 3 additions & 0 deletions testsuite/N806.py
Expand Up @@ -22,6 +22,9 @@ def test2():
class Foo(object):
def test3(self):
Bad = 3
#: Okay(--ignore-names=Bad)
def test():
Bad = 1
#: Okay
def good():
global Bad
Expand Down
3 changes: 3 additions & 0 deletions testsuite/N807.py
Expand Up @@ -35,6 +35,9 @@ class ClassName(object):
def method(self):
def __bad():
pass
#: Okay(--ignore-names=__bad)
def __bad():
pass
#: Okay
def __dir__():
pass
Expand Down
3 changes: 3 additions & 0 deletions testsuite/N815.py
Expand Up @@ -19,3 +19,6 @@ class C:
#: N815
class C:
mixed_Case = 0
#: Okay(--ignore-names=mixed_Case)
class C:
mixed_Case = 0
2 changes: 2 additions & 0 deletions testsuite/N816.py
Expand Up @@ -18,3 +18,5 @@
C6 = 0
#: Okay
C_6 = 0.
#: Okay(--ignore-names=mixedCase)
mixedCase = 0