@@ -210,8 +210,16 @@ def do_update(self) -> Dict[str, Any]:
210210return result
211211
212212
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+
213220def _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 ,
215223)-> None :
216224mgr_cls_name = f"{ cls .__name__ } Manager"
217225mgr_cls = getattr (gitlab .v4 .objects ,mgr_cls_name )
@@ -301,9 +309,11 @@ def _populate_sub_parser_by_class(
301309for action_name in cli .custom_actions [name ]:
302310# NOTE(jlvillal): If we put a function for the `default` value of
303311# 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 :
306314sub_parser_action = sub_parser .add_parser (action_name )
315+ else :
316+ sub_parser_action = action_parser
307317# Get the attributes for URL/path construction
308318if mgr_cls ._from_parent_attrs :
309319for x in mgr_cls ._from_parent_attrs :
@@ -335,9 +345,11 @@ def _populate_sub_parser_by_class(
335345for action_name in cli .custom_actions [name ]:
336346# NOTE(jlvillal): If we put a function for the `default` value of
337347# 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 :
340350sub_parser_action = sub_parser .add_parser (action_name )
351+ else :
352+ sub_parser_action = action_parser
341353if mgr_cls ._from_parent_attrs :
342354for x in mgr_cls ._from_parent_attrs :
343355sub_parser_action .add_argument (