Skip to content

Commit 8a02564

Browse files
committed
typing: Use objects from typing
Change-Id: I9211e2918324e5e8135051a7c2279ee574b0e243 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent b525e59 commit 8a02564

31 files changed

Lines changed: 88 additions & 84 deletions

openstackclient/common/clientmanager.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import importlib
2121
import logging
2222
import sys
23-
import typing as ty
23+
from typing import TYPE_CHECKING, Any, Protocol, TypeVar, runtime_checkable
2424

2525
from osc_lib.cli import client_config
2626
from osc_lib import clientmanager
2727
from osc_lib import shell
2828
import stevedore
2929

30-
if ty.TYPE_CHECKING:
30+
if TYPE_CHECKING:
3131
from keystoneauth1 import access as ksa_access
3232
from openstack.compute.v2 import _proxy as compute_proxy
3333
from openstack.image.v2 import _proxy as image_proxy
@@ -37,7 +37,7 @@
3737

3838
LOG = logging.getLogger(__name__)
3939

40-
PLUGIN_MODULES: list[ty.Any] = []
40+
PLUGIN_MODULES: list[Any] = []
4141

4242
USER_AGENT = 'python-openstackclient'
4343

@@ -50,7 +50,7 @@ class ClientManager(clientmanager.ClientManager):
5050
in osc-lib so we need to maintain a transition period.
5151
"""
5252

53-
if ty.TYPE_CHECKING:
53+
if TYPE_CHECKING:
5454
# we know this will be set by us and will not be nullable
5555
auth_ref: ksa_access.AccessInfo
5656

@@ -62,11 +62,11 @@ class ClientManager(clientmanager.ClientManager):
6262
# services...
6363
# TODO(stephenfin): We also need to migrate object storage...
6464
compute: compute_proxy.Proxy
65-
identity: ty.Any
65+
identity: Any
6666
image: image_proxy.Proxy
6767
network: network_proxy.Proxy
6868
object_store: object_store_v1.APIv1
69-
volume: ty.Any
69+
volume: Any
7070

7171
def __init__(
7272
self,
@@ -179,17 +179,17 @@ def is_volume_endpoint_enabled(self, volume_client=None):
179179

180180
# Plugin Support
181181

182-
ArgumentParserT = ty.TypeVar('ArgumentParserT', bound=argparse.ArgumentParser)
182+
ArgumentParserT = TypeVar('ArgumentParserT', bound=argparse.ArgumentParser)
183183

184184

185-
@ty.runtime_checkable # Optional: allows usage with isinstance()
186-
class PluginModule(ty.Protocol):
185+
@runtime_checkable # Optional: allows usage with isinstance()
186+
class PluginModule(Protocol):
187187
DEFAULT_API_VERSION: str
188188
API_VERSION_OPTION: str
189189
API_NAME: str
190190
API_VERSIONS: tuple[str]
191191

192-
make_client: Callable[..., ty.Any]
192+
make_client: Callable[..., Any]
193193
build_option_parser: Callable[[ArgumentParserT], ArgumentParserT]
194194
check_api_version: Callable[[str], bool]
195195

openstackclient/common/project_cleanup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import logging
1818
import os
1919
import queue
20-
import typing as ty
20+
from typing import Any
2121

2222
from cliff.formatters import table
2323
from openstack import utils as sdk_utils
@@ -107,7 +107,7 @@ def take_action(self, parsed_args):
107107
connection = connection.connect_as_project(project)
108108

109109
if connection:
110-
status_queue: queue.Queue[ty.Any] = queue.Queue()
110+
status_queue: queue.Queue[Any] = queue.Queue()
111111
parsed_args.max_width = int(
112112
os.environ.get('CLIFF_MAX_TERM_WIDTH', 0)
113113
)

openstackclient/common/quota.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import itertools
1919
import logging
2020
import sys
21-
import typing as ty
21+
from typing import Any
2222

2323
from openstack import exceptions as sdk_exceptions
2424
from openstack import utils as sdk_utils
@@ -203,7 +203,7 @@ def _network_quota_to_dict(network_quota, detail=False):
203203
#
204204
# so we need to make conversion to have data in same format from
205205
# all of the services
206-
result: dict[str, ty.Any] = {"usage": {}, "reservation": {}}
206+
result: dict[str, Any] = {"usage": {}, "reservation": {}}
207207
for key, values in dict_quota.items():
208208
if values is None:
209209
continue

openstackclient/compute/v2/aggregate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""Compute v2 Aggregate action implementations"""
1818

1919
import logging
20-
import typing as ty
20+
from typing import Any
2121

2222
from cliff import columns
2323
from openstack import utils as sdk_utils
@@ -33,7 +33,7 @@
3333
LOG = logging.getLogger(__name__)
3434

3535

36-
_aggregate_formatters: dict[str, type[columns.FormattableColumn[ty.Any]]] = {
36+
_aggregate_formatters: dict[str, type[columns.FormattableColumn[Any]]] = {
3737
'Hosts': format_columns.ListColumn,
3838
'Metadata': format_columns.DictColumn,
3939
'hosts': format_columns.ListColumn,
@@ -323,7 +323,7 @@ def take_action(self, parsed_args):
323323
if kwargs:
324324
compute_client.update_aggregate(aggregate.id, **kwargs)
325325

326-
properties: dict[str, ty.Any] = {}
326+
properties: dict[str, Any] = {}
327327
if parsed_args.no_property:
328328
# NOTE(RuiChen): "availability_zone" can not be unset from
329329
# properties. It is already excluded from show and create output.

openstackclient/compute/v2/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import json
2222
import logging
2323
import os
24-
import typing as ty
24+
from typing import Any
2525

2626
from cliff import columns as cliff_columns
2727
import iso8601
@@ -66,7 +66,7 @@ def human_readable(self):
6666
return 'N/A'
6767

6868

69-
class AddressesColumn(cliff_columns.FormattableColumn[ty.Any]):
69+
class AddressesColumn(cliff_columns.FormattableColumn[Any]):
7070
"""Generate a formatted string of a server's addresses."""
7171

7272
def human_readable(self):

openstackclient/compute/v2/server_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""Compute v2 Server Group action implementations"""
1717

1818
import logging
19-
import typing as ty
19+
from typing import Any
2020

2121
from cliff import columns
2222
from openstack import utils as sdk_utils
@@ -32,7 +32,7 @@
3232
LOG = logging.getLogger(__name__)
3333

3434

35-
_formatters: dict[str, type[columns.FormattableColumn[ty.Any]]] = {
35+
_formatters: dict[str, type[columns.FormattableColumn[Any]]] = {
3636
'member_ids': format_columns.ListColumn,
3737
'policies': format_columns.ListColumn,
3838
'rules': format_columns.DictColumn,

openstackclient/compute/v2/usage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from collections.abc import Collection
1919
import datetime
2020
import functools
21-
import typing as ty
21+
from typing import Any
2222

2323
from cliff import columns as cliff_columns
2424
from osc_lib import utils
@@ -55,7 +55,7 @@ def human_readable(self):
5555
return project
5656

5757

58-
class CountColumn(cliff_columns.FormattableColumn[Collection[ty.Any]]):
58+
class CountColumn(cliff_columns.FormattableColumn[Collection[Any]]):
5959
def human_readable(self):
6060
return len(self._value) if self._value is not None else None
6161

openstackclient/identity/v2_0/catalog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""Identity v2 Service Catalog action implementations"""
1515

1616
import logging
17-
import typing as ty
17+
from typing import Any
1818

1919
from cliff import columns as cliff_columns
2020
from osc_lib import exceptions
@@ -27,7 +27,7 @@
2727
LOG = logging.getLogger(__name__)
2828

2929

30-
class EndpointsColumn(cliff_columns.FormattableColumn[ty.Any]):
30+
class EndpointsColumn(cliff_columns.FormattableColumn[Any]):
3131
def human_readable(self):
3232
if not self._value:
3333
return ""

openstackclient/identity/v3/application_credential.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import datetime
1919
import json
2020
import logging
21-
import typing as ty
21+
from typing import Any
2222
import uuid
2323

2424
from cliff import columns as cliff_columns
@@ -33,7 +33,7 @@
3333
LOG = logging.getLogger(__name__)
3434

3535

36-
class RolesColumn(cliff_columns.FormattableColumn[ty.Any]):
36+
class RolesColumn(cliff_columns.FormattableColumn[Any]):
3737
"""Generate a formatted string of role names."""
3838

3939
def human_readable(self):

openstackclient/identity/v3/catalog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""Identity v3 Service Catalog action implementations"""
1414

1515
import logging
16-
import typing as ty
16+
from typing import Any
1717

1818
from cliff import columns as cliff_columns
1919
from osc_lib import exceptions
@@ -26,7 +26,7 @@
2626
LOG = logging.getLogger(__name__)
2727

2828

29-
class EndpointsColumn(cliff_columns.FormattableColumn[ty.Any]):
29+
class EndpointsColumn(cliff_columns.FormattableColumn[Any]):
3030
def human_readable(self):
3131
if not self._value:
3232
return ""

0 commit comments

Comments
 (0)