@@ -202,13 +202,14 @@ def _configure_style(self):
202202
203203
204204class ModuleLoadResult : # pylint: disable=too-few-public-methods
205- def __init__ (self , module_name , command_table , group_table , elapsed_time , error = None , traceback_str = None ):
205+ def __init__ (self , module_name , command_table , group_table , elapsed_time , error = None , traceback_str = None , command_loader = None ):
206206 self .module_name = module_name
207207 self .command_table = command_table
208208 self .group_table = group_table
209209 self .elapsed_time = elapsed_time
210210 self .error = error
211211 self .traceback_str = traceback_str
212+ self .command_loader = command_loader
212213
213214
214215class MainCommandsLoader (CLICommandsLoader ):
@@ -343,7 +344,7 @@ def _filter_modname(extensions):
343344 # from an extension requires this map to be up-to-date.
344345 # self._mod_to_ext_map[ext_mod] = ext_name
345346 start_time = timeit .default_timer ()
346- extension_command_table , extension_group_table = \
347+ extension_command_table , extension_group_table , _ = \
347348 _load_extension_command_loader (self , args , ext_mod )
348349 import_extension_breaking_changes (ext_mod )
349350
@@ -581,10 +582,10 @@ def _load_single_module(self, mod, args):
581582 import traceback
582583 try :
583584 start_time = timeit .default_timer ()
584- module_command_table , module_group_table = _load_module_command_loader (self , args , mod )
585+ module_command_table , module_group_table , command_loader = _load_module_command_loader (self , args , mod )
585586 import_module_breaking_changes (mod )
586587 elapsed_time = timeit .default_timer () - start_time
587- return ModuleLoadResult (mod , module_command_table , module_group_table , elapsed_time )
588+ return ModuleLoadResult (mod , module_command_table , module_group_table , elapsed_time , command_loader = command_loader )
588589 except Exception as ex : # pylint: disable=broad-except
589590 tb_str = traceback .format_exc ()
590591 return ModuleLoadResult (mod , {}, {}, 0 , ex , tb_str )
@@ -602,6 +603,12 @@ def _handle_module_load_error(self, result):
602603
603604 def _process_successful_load (self , result ):
604605 """Process successfully loaded module results."""
606+ if result .command_loader :
607+ self .loaders .append (result .command_loader )
608+
609+ for cmd in result .command_table :
610+ self .cmd_to_loader_map [cmd ] = [result .command_loader ]
611+
605612 for cmd in result .command_table .values ():
606613 cmd .command_source = result .module_name
607614
0 commit comments