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