@@ -88,17 +88,34 @@ def _load_plugins(self):
8888 # this throws an exception if invalid
8989 skip_old_check = mod_check_api_version (version_opt )
9090
91+ # NOTE(stephenfin): API_VERSIONS has traditionally been a
92+ # dictionary but the values are only used internally and are
93+ # ignored for the modules using SDK. So we now support tuples
94+ # instead.
9195 mod_versions = getattr (mod , 'API_VERSIONS' , None )
92- if not skip_old_check and mod_versions :
96+ if mod_versions is not None and not isinstance (
97+ mod_versions , (dict , tuple )
98+ ):
99+ raise TypeError (
100+ f'Plugin { mod } has incompatible API_VERSIONS. '
101+ f'Expected: tuple, dict. Got: { type (mod_versions )} . '
102+ f'Please report this to your package maintainer.'
103+ )
104+
105+ if mod_versions and not skip_old_check :
93106 if version_opt not in mod_versions :
94107 sorted_versions = sorted (
95- mod .API_VERSIONS . keys ( ),
108+ list ( mod .API_VERSIONS ),
96109 key = lambda s : list (map (int , s .split ('.' ))),
97110 )
98111 self .log .warning (
99- "{} version {} is not in supported versions: {}" .format (
100- api , version_opt , ', ' .join (sorted_versions )
101- )
112+ "%(name)s API version %(version)s is not in "
113+ "supported versions: %(supported)s" ,
114+ {
115+ 'name' : api ,
116+ 'version' : version_opt ,
117+ 'supported' : ', ' .join (sorted_versions ),
118+ },
102119 )
103120
104121 # Command groups deal only with major versions
0 commit comments