2525)
2626from ._util import NoneType , Path , import_object , unique
2727
28- shtab_shell : ContextVar = ContextVar ("shtab_shell" )
29- shtab_prog : ContextVar = ContextVar ("shtab_prog" )
30- shtab_preambles : ContextVar = ContextVar ("shtab_preambles" )
31-
3228
3329def handle_completions (parser ):
3430 if find_spec ("argcomplete" ) and "_ARGCOMPLETE" in os .environ :
@@ -76,6 +72,10 @@ def argcomplete_warn_redraw_prompt(prefix, message):
7672
7773# shtab
7874
75+ shtab_shell : ContextVar = ContextVar ("shtab_shell" )
76+ shtab_prog : ContextVar = ContextVar ("shtab_prog" )
77+ shtab_preambles : ContextVar = ContextVar ("shtab_preambles" )
78+
7979
8080class ShtabAction (argparse .Action ):
8181 def __init__ (
@@ -236,7 +236,7 @@ def get_typehint_choices(typehint, prefix, parser, skip, choices=None, added_sub
236236 origin = get_typehint_origin (typehint )
237237 if origin == Union :
238238 for subtype in typehint .__args__ :
239- if subtype in added_subclasses :
239+ if subtype in added_subclasses or subtype is object :
240240 continue
241241 get_typehint_choices (subtype , prefix , parser , skip , choices , added_subclasses )
242242 elif ActionTypeHint .is_subclass_typehint (typehint ):
@@ -261,8 +261,12 @@ def add_subactions_and_get_subclass_choices(typehint, prefix, parser, skip, adde
261261 subclasses = defaultdict (list )
262262 for path in paths :
263263 choices .append (path )
264- cls = import_object (path )
265- params = get_signature_parameters (cls )
264+ try :
265+ cls = import_object (path )
266+ params = get_signature_parameters (cls , None , parser ._logger )
267+ except Exception as ex :
268+ parser ._logger .debug (f"Unable to get signature parameters for '{ path } ': { ex } " )
269+ continue
266270 num_skip = next ((s for s in skip if isinstance (s , int )), 0 )
267271 if num_skip > 0 :
268272 params = params [num_skip :]
0 commit comments