hacking: Ensure use of openstackclient.command

These have the necessary type hints for the clientmanager and
should always be used.

Change-Id: I8420212be63dbeaff02c97823e1b80441cbc62ca
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2026-03-10 13:17:08 +00:00
parent 2a28605ba2
commit de81f47305
2 changed files with 18 additions and 0 deletions

View File

@@ -177,3 +177,20 @@ def assert_find_ignore_missing_kwargs(logical_line, filename):
'O403: Calls to find_* proxy methods must explicitly set '
'ignore_missing',
)
@core.flake8ext
def assert_use_of_osc_command(logical_line, filename):
"""Ensure we use openstackclient.command instead of osc_lib.command.
O404
"""
if filename == 'openstackclient/command.py':
return
if re.match(r'^from osc_lib\.command import command$', logical_line):
yield (
0,
'O404: Import Command classes from openstackclient.command, not '
'osc_lib.command.command',
)

View File

@@ -128,4 +128,5 @@ extension =
O401 = checks:assert_no_duplicated_setup
O402 = checks:assert_use_of_client_aliases
O403 = checks:assert_find_ignore_missing_kwargs
O404 = checks:assert_use_of_osc_command
paths = ./hacking