Add hacking check to ban eventlet imports
Ironic has fully removed its usage of eventlet. This change introduces a new hacking check to ban any new eventlet imports from being added to the codebase. This follows the post-migration guidance from the eventlet removal documentation: https://removal.eventlet.org/guide/post-migration-guidance/#hacking-checks Generated-By: gemini-cli and gemini-2.5-pro Change-Id: I48ac535325f68ba0b2a9f50aec4ce19ac6265e77 Signed-off-by: Hervé Beraud <hberaud@redhat.com>
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"
|
||||
|
||||
@@ -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