@@ -143,10 +143,6 @@ def wordify(string):
143143
144144def get_public_subcommands (sub ):
145145 """Get all the publicly-visible subcommands for a given subparser."""
146- # NOTE: public subcommands have their primary name listed in the result of
147- # `_get_subactions()`. We use this to get the parser for each subcommand and
148- # compare all the choices (including aliases!) to the set of known-public
149- # parsers.
150146 public_parsers = {id (sub .choices [i .dest ]) for i in sub ._get_subactions ()}
151147 return {k for k , v in sub .choices .items () if id (v ) in public_parsers }
152148
@@ -214,9 +210,6 @@ def recurse(parser, prefix):
214210 # choices (including subparsers & shtab `.complete` functions)
215211 log .debug ("choices:{}:{}" .format (prefix , sorted (positional .choices )))
216212
217- if isinstance (positional .choices , dict ):
218- public_cmds = get_public_subcommands (positional )
219-
220213 this_positional_choices = []
221214 for choice in positional .choices :
222215 if isinstance (choice , Choice ):
@@ -235,6 +228,7 @@ def recurse(parser, prefix):
235228 elif isinstance (positional .choices , dict ):
236229 # subparser, so append to list of subparsers & recurse
237230 log .debug ("subcommand:%s" , choice )
231+ public_cmds = get_public_subcommands (positional )
238232 if choice in public_cmds :
239233 discovered_subparsers .append (str (choice ))
240234 this_positional_choices .append (str (choice ))
0 commit comments