Merge "flake8: Ensure local check in hacking 2.0.0"
This commit is contained in:
commit
ddb9a8219e
@ -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)
|
||||
|
5
tox.ini
5
tox.ini
@ -186,8 +186,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user