From 8c2b51acc219c5ddba746219ed3bd01e5dc2a4fb Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Mon, 27 Jan 2020 02:43:48 +0900 Subject: [PATCH] flake8: Ensure local check in hacking 2.0.0 local-check-factory support was dropped in hacking 2.0.0. The release notes of hacking 2.0.0 [1] suggests to use flake8's native local plugin support [2]. This commit follows it. [1] https://docs.openstack.org/releasenotes/hacking/unreleased.html#relnotes-2-0-0 [2] https://flake8.pycqa.org/en/3.7.0/user/configuration.html#using-local-plugins Change-Id: Ie19630a58d7b4ce735007b8abdd6ebac85d60946 --- horizon/hacking/checks.py | 7 +++---- tox.ini | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/horizon/hacking/checks.py b/horizon/hacking/checks.py index 4a61166f8e..60872bcbf4 100644 --- a/horizon/hacking/checks.py +++ b/horizon/hacking/checks.py @@ -15,6 +15,8 @@ import re +from hacking import core + """ Guidelines for writing new hacking checks - Use only for Horizon specific tests. OpenStack general tests @@ -31,11 +33,8 @@ Guidelines for writing new hacking checks mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])") +@core.flake8ext def no_mutable_default_args(logical_line): msg = "M322: Method's default argument shouldn't be mutable!" if mutable_default_args.match(logical_line): yield (0, msg) - - -def factory(register): - register(no_mutable_default_args) diff --git a/tox.ini b/tox.ini index 4bf1a423c3..52a4902694 100644 --- a/tox.ini +++ b/tox.ini @@ -184,8 +184,9 @@ max_line_length = 80 import-order-style = pep8 application-import-names = horizon,openstack_dashboard -[hacking] -local-check-factory = horizon.hacking.checks.factory +[flake8:local-plugins] +extension = + M322 = horizon.hacking.checks:no_mutable_default_args [doc8] # File extensions to check