diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3299b87..cf0503c 100644 --- a/CHANGELOG.rst +++ b/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 ------------------ diff --git a/src/pep8ext_naming.py b/src/pep8ext_naming.py index 630b2c6..0d770d5 100644 --- a/src/pep8ext_naming.py +++ b/src/pep8ext_naming.py @@ -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 @@ -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'] @@ -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 @@ -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, diff --git a/testsuite/N801.py b/testsuite/N801.py index fb29990..b2e9fb2 100644 --- a/testsuite/N801.py +++ b/testsuite/N801.py @@ -1,4 +1,7 @@ #: N801 +class notok(object): + pass +#: Okay(--ignore-names=notok) class notok(object): pass #: N801 diff --git a/testsuite/N802.py b/testsuite/N802.py index c609423..5cd959f 100644 --- a/testsuite/N802.py +++ b/testsuite/N802.py @@ -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 @@ -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 diff --git a/testsuite/N806.py b/testsuite/N806.py index f6a2385..f71c8fc 100644 --- a/testsuite/N806.py +++ b/testsuite/N806.py @@ -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 diff --git a/testsuite/N807.py b/testsuite/N807.py index f9d8c38..9b7dc12 100644 --- a/testsuite/N807.py +++ b/testsuite/N807.py @@ -35,6 +35,9 @@ class ClassName(object): def method(self): def __bad(): pass +#: Okay(--ignore-names=__bad) +def __bad(): + pass #: Okay def __dir__(): pass diff --git a/testsuite/N815.py b/testsuite/N815.py index 43a3bfd..ec4e4d8 100644 --- a/testsuite/N815.py +++ b/testsuite/N815.py @@ -19,3 +19,6 @@ class C: #: N815 class C: mixed_Case = 0 +#: Okay(--ignore-names=mixed_Case) +class C: + mixed_Case = 0 diff --git a/testsuite/N816.py b/testsuite/N816.py index 70d416f..6536bad 100644 --- a/testsuite/N816.py +++ b/testsuite/N816.py @@ -18,3 +18,5 @@ C6 = 0 #: Okay C_6 = 0. +#: Okay(--ignore-names=mixedCase) +mixedCase = 0