diff --git a/ironic/hacking/checks.py b/ironic/hacking/checks.py index 57a3cbfe8d..7df8908593 100644 --- a/ironic/hacking/checks.py +++ b/ironic/hacking/checks.py @@ -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" diff --git a/tox.ini b/tox.ini index e85c2e28e5..409ed317c1 100644 --- a/tox.ini +++ b/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]