From de81f473059c3fb5014fb10081da409b3664e14b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 10 Mar 2026 13:17:08 +0000 Subject: [PATCH] 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 --- hacking/checks.py | 17 +++++++++++++++++ tox.ini | 1 + 2 files changed, 18 insertions(+) diff --git a/hacking/checks.py b/hacking/checks.py index 0eb485e7e2..0b0855d192 100644 --- a/hacking/checks.py +++ b/hacking/checks.py @@ -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', + ) diff --git a/tox.ini b/tox.ini index 6ce9e96c60..36ec6a426e 100644 --- a/tox.ini +++ b/tox.ini @@ -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