File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -445,6 +445,43 @@ def session_check_name(session_name: t.Optional[str]) -> None:
445
445
raise exc .BadSessionName (reason = "contains colons" , session_name = session_name )
446
446
447
447
448
+ def has_target_in_args (val : t .List [t .Any ]) -> bool :
449
+ """Return True if target in args.
450
+
451
+ Parameters
452
+ ----------
453
+ val : any
454
+ Any value to check if target is in it.
455
+
456
+ Returns
457
+ -------
458
+ bool
459
+ True if target in args.
460
+
461
+ Examples
462
+ --------
463
+ >>> has_target_in_args(['-t',])
464
+ False
465
+ >>> has_target_in_args(['-t', 'mytarget'])
466
+ True
467
+ >>> has_target_in_args(['-tmytarget'])
468
+ True
469
+ """
470
+ for idx , item in enumerate (val ):
471
+ if not isinstance (item , str ):
472
+ continue
473
+
474
+ if item == "-t" :
475
+ try :
476
+ val [idx + 1 ]
477
+ except IndexError :
478
+ return False
479
+ return True
480
+ elif item .startswith ("-t" ):
481
+ return True
482
+ return False
483
+
484
+
448
485
def handle_option_error (error : str ) -> t .Type [exc .OptionError ]:
449
486
"""Raise exception if error in option command found.
450
487
You can’t perform that action at this time.
0 commit comments