@@ -210,8 +210,16 @@ def do_update(self) -> Dict[str, Any]:
210
210
return result
211
211
212
212
213
+ # https://github.com/python/typeshed/issues/7539#issuecomment-1076581049
214
+ if TYPE_CHECKING :
215
+ _SubparserType = argparse ._SubParsersAction [argparse .ArgumentParser ]
216
+ else :
217
+ _SubparserType = Any
218
+
219
+
213
220
def _populate_sub_parser_by_class (
214
- cls : Type [gitlab .base .RESTObject ], sub_parser : argparse ._SubParsersAction
221
+ cls : Type [gitlab .base .RESTObject ],
222
+ sub_parser : _SubparserType ,
215
223
) -> None :
216
224
mgr_cls_name = f"{ cls .__name__ } Manager"
217
225
mgr_cls = getattr (gitlab .v4 .objects , mgr_cls_name )
@@ -301,9 +309,11 @@ def _populate_sub_parser_by_class(
301
309
for action_name in cli .custom_actions [name ]:
302
310
# NOTE(jlvillal): If we put a function for the `default` value of
303
311
# the `get` it will always get called, which will break things.
304
- sub_parser_action = action_parsers .get (action_name )
305
- if sub_parser_action is None :
312
+ action_parser = action_parsers .get (action_name )
313
+ if action_parser is None :
306
314
sub_parser_action = sub_parser .add_parser (action_name )
315
+ else :
316
+ sub_parser_action = action_parser
307
317
# Get the attributes for URL/path construction
308
318
if mgr_cls ._from_parent_attrs :
309
319
for x in mgr_cls ._from_parent_attrs :
@@ -335,9 +345,11 @@ def _populate_sub_parser_by_class(
335
345
for action_name in cli .custom_actions [name ]:
336
346
# NOTE(jlvillal): If we put a function for the `default` value of
337
347
# the `get` it will always get called, which will break things.
338
- sub_parser_action = action_parsers .get (action_name )
339
- if sub_parser_action is None :
348
+ action_parser = action_parsers .get (action_name )
349
+ if action_parser is None :
340
350
sub_parser_action = sub_parser .add_parser (action_name )
351
+ else :
352
+ sub_parser_action = action_parser
341
353
if mgr_cls ._from_parent_attrs :
342
354
for x in mgr_cls ._from_parent_attrs :
343
355
sub_parser_action .add_argument (
0 commit comments