@@ -4224,7 +4224,7 @@ def do_shell(self, args: argparse.Namespace) -> None:
4224
4224
kwargs ['executable' ] = shell
4225
4225
4226
4226
# Create a list of arguments to shell
4227
- tokens = [args .command ] + args .command_args
4227
+ tokens = [args .command , * args .command_args ]
4228
4228
4229
4229
# Expand ~ where needed
4230
4230
utils .expand_user_in_tokens (tokens )
@@ -4530,7 +4530,7 @@ def do_run_pyscript(self, args: argparse.Namespace) -> Optional[bool]:
4530
4530
4531
4531
try :
4532
4532
# Overwrite sys.argv to allow the script to take command line arguments
4533
- sys .argv = [args .script_path ] + args .script_arguments
4533
+ sys .argv = [args .script_path , * args .script_arguments ]
4534
4534
4535
4535
# self.last_resort will be set by _run_python()
4536
4536
py_return = self ._run_python (pyscript = args .script_path )
@@ -5562,7 +5562,7 @@ def _validate_postparsing_callable(cls, func: Callable[[plugin.PostparsingData],
5562
5562
"""Check parameter and return types for postparsing hooks"""
5563
5563
cls ._validate_callable_param_count (cast (Callable [..., Any ], func ), 1 )
5564
5564
signature = inspect .signature (func )
5565
- _ , param = list ( signature .parameters .items ())[ 0 ]
5565
+ _ , param = next ( iter ( signature .parameters .items ()))
5566
5566
if param .annotation != plugin .PostparsingData :
5567
5567
raise TypeError (f"{ func .__name__ } must have one parameter declared with type 'cmd2.plugin.PostparsingData'" )
5568
5568
if signature .return_annotation != plugin .PostparsingData :
@@ -5584,7 +5584,7 @@ def _validate_prepostcmd_hook(
5584
5584
# validate that the callable has the right number of parameters
5585
5585
cls ._validate_callable_param_count (cast (Callable [..., Any ], func ), 1 )
5586
5586
# validate the parameter has the right annotation
5587
- paramname = list ( signature .parameters .keys ())[ 0 ]
5587
+ paramname = next ( iter ( signature .parameters .keys ()))
5588
5588
param = signature .parameters [paramname ]
5589
5589
if param .annotation != data_type :
5590
5590
raise TypeError (f'argument 1 of { func .__name__ } has incompatible type { param .annotation } , expected { data_type } ' )
@@ -5613,7 +5613,7 @@ def _validate_cmdfinalization_callable(
5613
5613
"""Check parameter and return types for command finalization hooks."""
5614
5614
cls ._validate_callable_param_count (func , 1 )
5615
5615
signature = inspect .signature (func )
5616
- _ , param = list ( signature .parameters .items ())[ 0 ]
5616
+ _ , param = next ( iter ( signature .parameters .items ()))
5617
5617
if param .annotation != plugin .CommandFinalizationData :
5618
5618
raise TypeError (f"{ func .__name__ } must have one parameter declared with type { plugin .CommandFinalizationData } " )
5619
5619
if signature .return_annotation != plugin .CommandFinalizationData :
0 commit comments