Skip to content

Commit bdd55d9

Browse files
committed
typing: Indicate tuples to be extended
Change-Id: Ie5907de8d60f2f39e98f6a88227cebb2e2ff565c Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 9c7a5d4 commit bdd55d9

43 files changed

Lines changed: 164 additions & 185 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

openstackclient/common/availability_zone.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,14 @@ def _get_network_availability_zones(self, parsed_args):
172172
return result
173173

174174
def take_action(self, parsed_args):
175+
columns: tuple[str, ...] = ('Zone Name', 'Zone Status')
175176
if parsed_args.long:
176-
columns = (
177-
'Zone Name',
178-
'Zone Status',
177+
columns += (
179178
'Zone Resource',
180179
'Host Name',
181180
'Service Name',
182181
'Service Status',
183182
)
184-
else:
185-
columns = ('Zone Name', 'Zone Status')
186183

187184
# Show everything by default.
188185
show_all = (

openstackclient/common/extension.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,9 @@ def get_parser(self, prog_name):
7373
return parser
7474

7575
def take_action(self, parsed_args):
76+
columns: tuple[str, ...] = ('Name', 'Alias', 'Description')
7677
if parsed_args.long:
77-
columns = (
78-
'Name',
79-
'Alias',
80-
'Description',
81-
'Namespace',
82-
'Updated At',
83-
'Links',
84-
)
85-
else:
86-
columns = ('Name', 'Alias', 'Description')
78+
columns += ('Namespace', 'Updated At', 'Links')
8779

8880
data = []
8981

openstackclient/common/quota.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def _list_quota_compute(self, parsed_args, project_ids):
290290
if default_result != project_result:
291291
result += project_result
292292

293-
columns = (
293+
columns: tuple[str, ...] = (
294294
'id',
295295
'cores',
296296
'injected_files',
@@ -303,7 +303,7 @@ def _list_quota_compute(self, parsed_args, project_ids):
303303
'server_groups',
304304
'server_group_members',
305305
)
306-
column_headers = (
306+
column_headers: tuple[str, ...] = (
307307
'Project ID',
308308
'Cores',
309309
'Injected Files',
@@ -352,7 +352,7 @@ def _list_quota_volume(self, parsed_args, project_ids):
352352
if default_result != project_result:
353353
result += project_result
354354

355-
columns = (
355+
columns: tuple[str, ...] = (
356356
'id',
357357
'backups',
358358
'backup_gigabytes',
@@ -361,7 +361,7 @@ def _list_quota_volume(self, parsed_args, project_ids):
361361
'snapshots',
362362
'volumes',
363363
)
364-
column_headers = (
364+
column_headers: tuple[str, ...] = (
365365
'Project ID',
366366
'Backups',
367367
'Backup Gigabytes',
@@ -407,7 +407,7 @@ def _list_quota_network(self, parsed_args, project_ids):
407407
if default_result != project_result:
408408
result += project_result
409409

410-
columns = (
410+
columns: tuple[str, ...] = (
411411
'id',
412412
'floating_ips',
413413
'networks',
@@ -419,7 +419,7 @@ def _list_quota_network(self, parsed_args, project_ids):
419419
'subnets',
420420
'subnet_pools',
421421
)
422-
column_headers = (
422+
column_headers: tuple[str, ...] = (
423423
'Project ID',
424424
'Floating IPs',
425425
'Networks',
@@ -823,11 +823,11 @@ def take_action(self, parsed_args):
823823
if k not in ('usage', 'reservation')
824824
]
825825

826-
columns = (
826+
columns: tuple[str, ...] = (
827827
'resource',
828828
'limit',
829829
)
830-
column_headers = (
830+
column_headers: tuple[str, ...] = (
831831
'Resource',
832832
'Limit',
833833
)

openstackclient/compute/v2/aggregate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ def take_action(self, parsed_args):
194194
aggregates = list(compute_client.aggregates())
195195

196196
if sdk_utils.supports_microversion(compute_client, '2.41'):
197-
column_headers = ("ID", "UUID")
198-
columns = ("id", "uuid")
197+
column_headers: tuple[str, ...] = ("ID", "UUID")
198+
columns: tuple[str, ...] = ("id", "uuid")
199199
else:
200200
column_headers = ("ID",)
201201
columns = ("id",)

openstackclient/compute/v2/flavor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def take_action(self, parsed_args):
329329
if parsed_args.long and not f.extra_specs:
330330
compute_client.fetch_flavor_extra_specs(f)
331331

332-
columns = (
332+
columns: tuple[str, ...] = (
333333
"id",
334334
"name",
335335
"ram",
@@ -345,7 +345,7 @@ def take_action(self, parsed_args):
345345
"extra_specs",
346346
)
347347

348-
column_headers = (
348+
column_headers: tuple[str, ...] = (
349349
"ID",
350350
"Name",
351351
"RAM",

openstackclient/compute/v2/hypervisor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,20 @@ def take_action(self, parsed_args):
119119
if parsed_args.matching:
120120
list_opts['hypervisor_hostname_pattern'] = parsed_args.matching
121121

122-
column_headers = (
122+
column_headers: tuple[str, ...] = (
123123
"ID",
124124
"Hypervisor Hostname",
125125
"Hypervisor Type",
126126
"Host IP",
127127
"State",
128128
)
129-
columns = ('id', 'name', 'hypervisor_type', 'host_ip', 'state')
129+
columns: tuple[str, ...] = (
130+
'id',
131+
'name',
132+
'hypervisor_type',
133+
'host_ip',
134+
'state',
135+
)
130136

131137
if parsed_args.long:
132138
if not sdk_utils.supports_microversion(compute_client, '2.88'):

openstackclient/compute/v2/keypair.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def take_action(self, parsed_args):
372372
else:
373373
data = compute_client.keypairs(**kwargs)
374374

375-
columns = ("Name", "Fingerprint")
375+
columns: tuple[str, ...] = ("Name", "Fingerprint")
376376

377377
if sdk_utils.supports_microversion(compute_client, '2.2'):
378378
columns += ("Type",)

openstackclient/compute/v2/server.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,15 @@ def take_action(self, parsed_args):
430430

431431
interface = compute_client.create_server_interface(server.id, **kwargs)
432432

433-
columns = (
433+
columns: tuple[str, ...] = (
434434
'port_id',
435435
'server_id',
436436
'net_id',
437437
'mac_addr',
438438
'port_state',
439439
'fixed_ips',
440440
)
441-
column_headers = (
441+
column_headers: tuple[str, ...] = (
442442
'Port ID',
443443
'Server ID',
444444
'Network ID',
@@ -842,8 +842,13 @@ def take_action(self, parsed_args):
842842
**kwargs,
843843
)
844844

845-
columns = ('id', 'server id', 'volume id', 'device')
846-
column_headers = ('ID', 'Server ID', 'Volume ID', 'Device')
845+
columns: tuple[str, ...] = ('id', 'server id', 'volume id', 'device')
846+
column_headers: tuple[str, ...] = (
847+
'ID',
848+
'Server ID',
849+
'Volume ID',
850+
'Device',
851+
)
847852
if sdk_utils.supports_microversion(compute_client, '2.49'):
848853
columns += ('tag',)
849854
column_headers += ('Tag',)
@@ -2802,12 +2807,12 @@ def take_action(self, parsed_args):
28022807
msg % search_opts['changes-since']
28032808
)
28042809

2805-
columns = (
2810+
columns: tuple[str, ...] = (
28062811
'id',
28072812
'name',
28082813
'status',
28092814
)
2810-
column_headers = (
2815+
column_headers: tuple[str, ...] = (
28112816
'ID',
28122817
'Name',
28132818
'Status',

openstackclient/compute/v2/server_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ def take_action(self, parsed_args):
220220

221221
data = compute_client.server_actions(server_id, **kwargs)
222222

223-
columns = (
223+
columns: tuple[str, ...] = (
224224
'request_id',
225225
'server_id',
226226
'action',
227227
'start_time',
228228
)
229-
column_headers = (
229+
column_headers: tuple[str, ...] = (
230230
'Request ID',
231231
'Server ID',
232232
'Action',

openstackclient/compute/v2/server_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ def take_action(self, parsed_args):
216216
if sdk_utils.supports_microversion(compute_client, '2.64'):
217217
policy_key = 'Policy'
218218

219-
columns = (
219+
columns: tuple[str, ...] = (
220220
'id',
221221
'name',
222222
policy_key.lower(),
223223
)
224-
column_headers = (
224+
column_headers: tuple[str, ...] = (
225225
'ID',
226226
'Name',
227227
policy_key,

0 commit comments

Comments
 (0)