1919import logging
2020import os
2121import sys
22+ from collections .abc import Iterable , Sequence
2223from typing import Any
2324
2425from cliff import columns as cliff_columns
5152LOG = logging .getLogger (__name__ )
5253
5354
54- def _get_columns (item ) :
55+ def _get_columns (item : Any ) -> tuple [ tuple [ str , ...], tuple [ str , ...]] :
5556 column_map = {'is_protected' : 'protected' , 'owner_id' : 'owner' }
5657 hidden_columns = [
5758 'location' ,
@@ -69,7 +70,7 @@ def _get_columns(item):
6970
7071
7172class HumanReadableSizeColumn (cliff_columns .FormattableColumn [int ]):
72- def human_readable (self ):
73+ def human_readable (self ) -> str :
7374 """Return a formatted visibility string
7475
7576 :rtype:
@@ -83,7 +84,7 @@ def human_readable(self):
8384
8485
8586class VisibilityColumn (cliff_columns .FormattableColumn [bool ]):
86- def human_readable (self ):
87+ def human_readable (self ) -> str :
8788 """Return a formatted visibility string
8889
8990 :rtype:
@@ -99,7 +100,7 @@ def human_readable(self):
99100class CreateImage (command .ShowOne ):
100101 _description = _ ("Create/upload an image" )
101102
102- def get_parser (self , prog_name ) :
103+ def get_parser (self , prog_name : str ) -> argparse . ArgumentParser :
103104 parser = super ().get_parser (prog_name )
104105 parser .add_argument (
105106 "name" ,
@@ -239,7 +240,9 @@ def get_parser(self, prog_name):
239240 )
240241 return parser
241242
242- def take_action (self , parsed_args ):
243+ def take_action (
244+ self , parsed_args : argparse .Namespace
245+ ) -> tuple [Sequence [str ], Iterable [Any ]]:
243246 image_client = self .app .client_manager .image
244247
245248 # Build an attribute dict from the parsed args, only include
@@ -351,13 +354,15 @@ def take_action(self, parsed_args):
351354 info ['properties' ] = format_columns .DictColumn (
352355 info .get ('properties' , {})
353356 )
354- return zip (* sorted (info .items ()))
357+ col_headers , col_data = zip (* sorted (info .items ()))
358+ return col_headers , col_data
359+ return ((), ())
355360
356361
357362class DeleteImage (command .Command ):
358363 _description = _ ("Delete image(s)" )
359364
360- def get_parser (self , prog_name ) :
365+ def get_parser (self , prog_name : str ) -> argparse . ArgumentParser :
361366 parser = super ().get_parser (prog_name )
362367 parser .add_argument (
363368 "images" ,
@@ -367,7 +372,7 @@ def get_parser(self, prog_name):
367372 )
368373 return parser
369374
370- def take_action (self , parsed_args ) :
375+ def take_action (self , parsed_args : argparse . Namespace ) -> None :
371376 result = 0
372377 image_client = self .app .client_manager .image
373378 for image in parsed_args .images :
@@ -396,7 +401,7 @@ def take_action(self, parsed_args):
396401class ListImage (command .Lister ):
397402 _description = _ ("List available images" )
398403
399- def get_parser (self , prog_name ) :
404+ def get_parser (self , prog_name : str ) -> argparse . ArgumentParser :
400405 parser = super ().get_parser (prog_name )
401406 public_group = parser .add_mutually_exclusive_group ()
402407 public_group .add_argument (
@@ -453,7 +458,9 @@ def get_parser(self, prog_name):
453458 )
454459 return parser
455460
456- def take_action (self , parsed_args ):
461+ def take_action (
462+ self , parsed_args : argparse .Namespace
463+ ) -> tuple [Sequence [str ], Iterable [tuple [Any , ...]]]:
457464 image_client = self .app .client_manager .image
458465
459466 kwargs = {}
@@ -527,7 +534,7 @@ def take_action(self, parsed_args):
527534class SaveImage (command .Command ):
528535 _description = _ ("Save an image locally" )
529536
530- def get_parser (self , prog_name ) :
537+ def get_parser (self , prog_name : str ) -> argparse . ArgumentParser :
531538 parser = super ().get_parser (prog_name )
532539 parser .add_argument (
533540 "--chunk-size" ,
@@ -551,7 +558,7 @@ def get_parser(self, prog_name):
551558 )
552559 return parser
553560
554- def take_action (self , parsed_args ) :
561+ def take_action (self , parsed_args : argparse . Namespace ) -> None :
555562 image_client = self .app .client_manager .image
556563 image = image_client .find_image (
557564 parsed_args .image , ignore_missing = False
@@ -572,7 +579,7 @@ def take_action(self, parsed_args):
572579class SetImage (command .Command ):
573580 _description = _ ("Set image properties" )
574581
575- def get_parser (self , prog_name ) :
582+ def get_parser (self , prog_name : str ) -> argparse . ArgumentParser :
576583 parser = super ().get_parser (prog_name )
577584 parser .add_argument (
578585 "image" ,
@@ -702,7 +709,7 @@ def get_parser(self, prog_name):
702709 )
703710 return parser
704711
705- def take_action (self , parsed_args ) :
712+ def take_action (self , parsed_args : argparse . Namespace ) -> None :
706713 image_client = self .app .client_manager .image
707714
708715 kwargs = {}
@@ -819,7 +826,7 @@ def take_action(self, parsed_args):
819826class ShowImage (command .ShowOne ):
820827 _description = _ ("Display image details" )
821828
822- def get_parser (self , prog_name ) :
829+ def get_parser (self , prog_name : str ) -> argparse . ArgumentParser :
823830 parser = super ().get_parser (prog_name )
824831 parser .add_argument (
825832 "--human-readable" ,
@@ -834,7 +841,9 @@ def get_parser(self, prog_name):
834841 )
835842 return parser
836843
837- def take_action (self , parsed_args ):
844+ def take_action (
845+ self , parsed_args : argparse .Namespace
846+ ) -> tuple [Sequence [str ], Iterable [Any ]]:
838847 image_client = self .app .client_manager .image
839848 image = image_client .find_image (
840849 parsed_args .image , ignore_missing = False
0 commit comments