@@ -157,7 +157,7 @@ def _add_subcommands(
157157 remove_actions (subparser , (ActionConfigFile , _ActionPrintConfig ))
158158
159159
160- def has_parameter (component , name ):
160+ def has_parameter (component , name ) -> bool :
161161 return name in inspect .signature (component ).parameters .keys ()
162162
163163
@@ -170,7 +170,9 @@ def _add_component_to_parser(
170170):
171171 kwargs : dict = dict (as_positional = as_positional , fail_untyped = fail_untyped , sub_configs = True )
172172 if inspect .isclass (component ):
173- class_methods = [k for k , v in inspect .getmembers (component ) if callable (v ) and k [0 ] != "_" ]
173+ class_methods = [
174+ k for k , v in inspect .getmembers (component ) if (callable (v ) or isinstance (v , property )) and k [0 ] != "_"
175+ ]
174176 if not class_methods :
175177 added_args = parser .add_class_arguments (component , as_group = False , ** kwargs )
176178 if not parser .description :
@@ -182,12 +184,13 @@ def _add_component_to_parser(
182184 method_object = getattr (component , method )
183185 description = get_help_str (method_object , parser .logger )
184186 subparser = type (parser )(description = description )
185- if not has_parameter (getattr (component , method ), "config" ):
186- subparser .add_argument ("--config" , action = ActionConfigFile , help = config_help )
187- added_subargs = subparser .add_method_arguments (component , method , as_group = False , ** kwargs )
188- added_args += [f"{ method } .{ a } " for a in added_subargs ]
189- if not added_subargs :
190- remove_actions (subparser , (ActionConfigFile , _ActionPrintConfig ))
187+ if not isinstance (method_object , property ):
188+ if not has_parameter (method_object , "config" ):
189+ subparser .add_argument ("--config" , action = ActionConfigFile , help = config_help )
190+ added_subargs = subparser .add_method_arguments (component , method , as_group = False , ** kwargs )
191+ added_args += [f"{ method } .{ a } " for a in added_subargs ]
192+ if not added_subargs :
193+ remove_actions (subparser , (ActionConfigFile , _ActionPrintConfig ))
191194 subcommands .add_subcommand (method , subparser , help = get_help_str (method_object , parser .logger ))
192195 else :
193196 added_args = parser .add_function_arguments (component , as_group = False , ** kwargs )
@@ -203,6 +206,8 @@ def _run_component(component, cfg):
203206 subcommand_cfg = cfg .pop (subcommand , {})
204207 subcommand_cfg .pop ("config" , None )
205208 component_obj = component (** cfg )
209+ if isinstance (getattr (component , subcommand ), property ):
210+ return getattr (component_obj , subcommand )
206211 component = getattr (component_obj , subcommand )
207212 cfg = subcommand_cfg
208213 if inspect .iscoroutinefunction (component ):
0 commit comments