From 913c8ea0f7aa8511212cea2f6e1b12b8075659af Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 10:03:40 +0100 Subject: [PATCH] typing: Set Command.app type The osc_lib.shell.Shell class provides far more functionality than cliff.app.App does and is what is actually used in practice. We also remove some old, commented out code. Change-Id: I972580747c627c2448c4a931bf8ae1ef1cd9558c Signed-off-by: Stephen Finucane --- osc_lib/command/command.py | 4 ++++ osc_lib/command/timing.py | 5 ----- osc_lib/shell.py | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/osc_lib/command/command.py b/osc_lib/command/command.py index 53b5ec72..47e584dc 100644 --- a/osc_lib/command/command.py +++ b/osc_lib/command/command.py @@ -24,6 +24,9 @@ from cliff import show from osc_lib import exceptions from osc_lib.i18n import _ +if ty.TYPE_CHECKING: + from osc_lib import shell + class CommandMeta(abc.ABCMeta): def __new__( @@ -41,6 +44,7 @@ class CommandMeta(abc.ABCMeta): class Command(command.Command, metaclass=CommandMeta): log: logging.Logger + app: 'shell.OpenStackShell' def run(self, parsed_args: argparse.Namespace) -> int: self.log.debug('run(%s)', parsed_args) diff --git a/osc_lib/command/timing.py b/osc_lib/command/timing.py index 3cf99fb9..afe97767 100644 --- a/osc_lib/command/timing.py +++ b/osc_lib/command/timing.py @@ -18,15 +18,10 @@ import typing as ty from osc_lib.command import command -if ty.TYPE_CHECKING: - from osc_lib import shell - class Timing(command.Lister): """Show timing data""" - app: 'shell.OpenStackShell' - def take_action( self, parsed_args: argparse.Namespace ) -> tuple[tuple[str, ...], list[ty.Any]]: diff --git a/osc_lib/shell.py b/osc_lib/shell.py index a7b7d440..5936d9f5 100644 --- a/osc_lib/shell.py +++ b/osc_lib/shell.py @@ -470,9 +470,6 @@ class OpenStackShell(app.App): "cloud cfg: %s", strutils.mask_password(self.cloud.config) ) - # Callout for stuff between o-c-c and ClientManager - # self._initialize_app_2(self.options) - self._load_plugins() self._load_commands()