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
This commit is contained in:
Akihiro Motoki 2020-01-27 02:43:48 +09:00
parent 5129d958fd
commit 8c2b51acc2
2 changed files with 6 additions and 6 deletions

View File

@ -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)

View File

@ -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