diff --git a/README.rst b/README.rst index 979becf..6fc1b3f 100644 --- a/README.rst +++ b/README.rst @@ -129,13 +129,3 @@ register. Such as: [hacking] local-check-factory = nova.tests.hacking.factory - -In addition, hacking provides a flake8 option to specify the -``local-check-factory`` on the CLI. When specified via CLI with -the ``--local-check-factory`` option to flake8, the specified -factory takes precedence over ``tox.ini`` and the local checks -from ``tox.ini`` are not used. - -For example, via CLI (any check specified in ``tox.ini`` are ignored):: - - flake8 --local-check-factory mypkg.warn_checks --exit-zero diff --git a/hacking/core.py b/hacking/core.py index a5bacb6..338f81f 100644 --- a/hacking/core.py +++ b/hacking/core.py @@ -145,29 +145,20 @@ class ProxyChecks(GlobalCheck): name = 'ProxyChecker' @classmethod - def parse_options(cls, options): + def add_options(cls, parser): # We're looking for local checks, so we need to include the local # dir in the search path sys.path.append('.') - local_check_fact = options.factory or CONF.get('local-check-factory') - if not options.factory: - # local factory on CLI trumps everything else - local_check = CONF.get_multiple('local-check', default=[]) - for check_path in set(local_check): - if check_path.strip(): - checker = pbr.util.resolve_name(check_path) - pep8.register_check(checker) + local_check = CONF.get_multiple('local-check', default=[]) + for check_path in set(local_check): + if check_path.strip(): + checker = pbr.util.resolve_name(check_path) + pep8.register_check(checker) + local_check_fact = CONF.get('local-check-factory') if local_check_fact: factory = pbr.util.resolve_name(local_check_fact) factory(pep8.register_check) sys.path.pop() - - @classmethod - def add_options(cls, parser): - # allow local check factory to be specified as CLI option to flake8 - # in which case its used as the sole source of checks - parser.add_option('--local-check-factory', action='store', - type='string', dest='factory') diff --git a/hacking/tests/test_local.py b/hacking/tests/test_local.py index 6be7d9a..e4dcc23 100644 --- a/hacking/tests/test_local.py +++ b/hacking/tests/test_local.py @@ -14,10 +14,8 @@ # limitations under the License. from flake8 import engine -import mock import pep8 -from hacking import core import hacking.tests @@ -36,11 +34,3 @@ class HackingTestCase(hacking.tests.TestCase): report=report) checker.check_all() self.assertIn("L100", report.counters) - - @mock.patch.object(core, 'CONF') - def test_local_check_factory_cli_option(self, mock_conf): - mock_opts = mock.Mock() - mock_opts.factory = 'mypkg.factory' - self.assertRaises( - ImportError, core.ProxyChecks.parse_options, mock_opts) - self.assertFalse(mock_conf.called)