Merge "Add hacking check to ban eventlet imports"
This commit is contained in:
@@ -31,6 +31,10 @@ underscore_import_check = re.compile(r"(.)*import _(.)*")
|
||||
custom_underscore_check = re.compile(r"(.)*_\s*=\s*(.)*")
|
||||
|
||||
|
||||
# I319: eventlet import not allowed
|
||||
_eventlet_re = re.compile(r"\b(import|from)\s+eventlet\b")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_explicit_underscore_import(logical_line, filename):
|
||||
"""Check for explicit import of the _ function
|
||||
@@ -52,3 +56,10 @@ def check_explicit_underscore_import(logical_line, filename):
|
||||
elif (translated_log.match(logical_line)
|
||||
or string_translation.match(logical_line)):
|
||||
yield (0, "N323: Found use of _() without explicit import of _!")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_eventlet_imports(logical_line):
|
||||
"""Check for eventlet imports."""
|
||||
if _eventlet_re.search(logical_line):
|
||||
yield 0, "I319: eventlet import not allowed"
|
||||
|
2
tox.ini
2
tox.ini
@@ -180,8 +180,10 @@ per-file-ignores =
|
||||
|
||||
[flake8:local-plugins]
|
||||
# [N323] Found use of _() without explicit import of _!
|
||||
# [I319] eventlet import not allowed
|
||||
extension =
|
||||
N323 = checks:check_explicit_underscore_import
|
||||
I319 = checks:no_eventlet_imports
|
||||
paths = ./ironic/hacking/
|
||||
|
||||
[hacking]
|
||||
|
Reference in New Issue
Block a user