@@ -164,7 +164,7 @@ def _model_and_stub_from_dict(
164164 class_name = '' .join (part .capitalize () if i > 0 else part for i , part in enumerate (path + [name ])).replace (
165165 '-' , '_'
166166 )
167- stub_lines = [f'class { class_name } (Dict [str, Any]):' ]
167+ stub_lines = [f'class { class_name } (dict [str, Any]):' ]
168168 nested_stubs = []
169169 py_type : Any
170170 for section , entry in data .items ():
@@ -181,23 +181,25 @@ def _model_and_stub_from_dict(
181181 f'{ section .capitalize ()} _item' , first_item , path + [name ]
182182 )
183183 if not keyword .iskeyword (section ) and section .isidentifier ():
184- stub_lines .append (f' { section } : List [{ class_name + section .capitalize ()} _item]' )
184+ stub_lines .append (f' { section } : list [{ class_name + section .capitalize ()} _item]' )
185185 nested_stubs .append (nested_stub )
186186 fields [section ] = (List [nested_model ], entry ) # type: ignore
187187 else :
188188 py_type = type (first_item )
189189 if not keyword .iskeyword (section ) and section .isidentifier ():
190- stub_lines .append (f' { section } : List [{ py_type .__name__ } ]' )
190+ stub_lines .append (f' { section } : list [{ py_type .__name__ } ]' )
191191 fields [section ] = (List [py_type ], entry )
192192 elif isinstance (entry , list ):
193193 if not keyword .iskeyword (section ) and section .isidentifier ():
194- stub_lines .append (f' { section } : List [Any]' )
194+ stub_lines .append (f' { section } : list [Any]' )
195195 fields [section ] = (List [Any ], entry )
196196 else :
197197 py_type = type (entry )
198198 if not keyword .iskeyword (section ) and section .isidentifier ():
199199 stub_lines .append (f' { section } : { py_type .__name__ } ' )
200200 fields [section ] = (py_type , entry )
201+ if len (stub_lines ) == 1 :
202+ stub_lines [0 ] += ' ...'
201203 stub_code = '\n \n ' .join (nested_stubs + ['\n ' .join (stub_lines )])
202204 return create_model (name , ** fields , __base__ = ExtraBase ), stub_code
203205
@@ -236,7 +238,9 @@ def _get_default_raw_data() -> ConfigType:
236238 _default_raw_data = _get_default_raw_data ()
237239 _ , stub = _model_and_stub_from_dict ('Config' , _default_raw_data )
238240 stub_full = (
239- f'# { output_file } was autogenerated from { default_config } with pyya CLI tool, see `pyya -h`\n from typing import Any, Dict, List\n \n '
241+ f'# { output_file } was autogenerated from { default_config } with pyya CLI tool, see `pyya -h`\n '
242+ f'from __future__ import annotations\n \n '
243+ f'from typing import Any\n \n '
240244 f'{ stub } \n \n '
241245 '# for type hints to work the variable name created with pyya.init_config\n '
242246 '# should have the same name (e.g. config = pyya.init_config())\n '
0 commit comments