diff options
| author | Andreas Jaeger <aj@suse.com> | 2020-04-01 19:47:23 +0200 |
|---|---|---|
| committer | Andreas Jaeger <aj@suse.com> | 2020-04-01 21:42:41 +0200 |
| commit | 1456d8b6f9f86d974459685091f143f0a0b4b345 (patch) | |
| tree | 9354c6ff0913063d4800ee564b01b4976ef94a82 /kolla | |
| parent | 69f74554671a49c75bebeeed9d83816ffbd7efec (diff) | |
| download | kolla-1456d8b6f9f86d974459685091f143f0a0b4b345.tar.gz kolla-1456d8b6f9f86d974459685091f143f0a0b4b345.zip | |
Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.
Fix problems found by updated hacking version.
Update local hacking checks for new flake8.
Remove hacking and friends from lower-constraints, they are not
needed in installations.
Change-Id: I67e5ca24c550163c218fb06692de0b7c528d8318
Diffstat (limited to 'kolla')
| -rw-r--r-- | kolla/hacking/checks.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/kolla/hacking/checks.py b/kolla/hacking/checks.py index a8df07097..64e322786 100644 --- a/kolla/hacking/checks.py +++ b/kolla/hacking/checks.py @@ -12,6 +12,7 @@ import re +from hacking import core mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])") @@ -22,12 +23,13 @@ UNDERSCORE_IMPORT_FILES = [] string_translation = re.compile(r"[^_]*_\(\s*('|\")") translated_log = re.compile( r"(.)*LOG\.(audit|error|info|warn|warning|critical|exception)" - "\(\s*_\(\s*('|\")") + r"\(\s*_\(\s*('|\")") underscore_import_check = re.compile(r"(.)*import _(.)*") # We need this for cases where they have created their own _ function. custom_underscore_check = re.compile(r"(.)*_\s*=\s*(.)*") +@core.flake8ext def check_explicit_underscore_import(logical_line, filename): """Check for explicit import of the _ function @@ -50,6 +52,7 @@ def check_explicit_underscore_import(logical_line, filename): yield(0, "D703: Found use of _() without explicit import of _!") +@core.flake8ext def no_log_warn(logical_line): """Disallow 'LOG.warn(' @@ -63,13 +66,8 @@ def no_log_warn(logical_line): yield (0, msg) +@core.flake8ext def no_mutable_default_args(logical_line): msg = "K301: Method's default argument shouldn't be mutable!" if mutable_default_args.match(logical_line): yield (0, msg) - - -def factory(register): - register(check_explicit_underscore_import) - register(no_mutable_default_args) - register(no_log_warn) |
