120
120
from SCons .Debug import logInstanceCreation
121
121
from SCons .Subst import SUBST_CMD , SUBST_RAW , SUBST_SIG
122
122
from SCons .Util import is_String , is_List
123
+ from SCons .Util .sctyping import ExecutorType
123
124
124
125
class _null :
125
126
pass
@@ -528,7 +529,7 @@ def __call__(
528
529
show = _null ,
529
530
execute = _null ,
530
531
chdir = _null ,
531
- executor = None ,
532
+ executor : Optional [ ExecutorType ] = None ,
532
533
):
533
534
raise NotImplementedError
534
535
@@ -540,15 +541,15 @@ def no_batch_key(self, env, target, source):
540
541
541
542
batch_key = no_batch_key
542
543
543
- def genstring (self , target , source , env , executor = None ) -> str :
544
+ def genstring (self , target , source , env , executor : Optional [ ExecutorType ] = None ) -> str :
544
545
return str (self )
545
546
546
547
@abstractmethod
547
- def get_presig (self , target , source , env , executor = None ):
548
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
548
549
raise NotImplementedError
549
550
550
551
@abstractmethod
551
- def get_implicit_deps (self , target , source , env , executor = None ):
552
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
552
553
raise NotImplementedError
553
554
554
555
def get_contents (self , target , source , env ):
@@ -600,10 +601,10 @@ def presub_lines(self, env):
600
601
self .presub_env = None # don't need this any more
601
602
return lines
602
603
603
- def get_varlist (self , target , source , env , executor = None ):
604
+ def get_varlist (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
604
605
return self .varlist
605
606
606
- def get_targets (self , env , executor ):
607
+ def get_targets (self , env , executor : Optional [ ExecutorType ] ):
607
608
"""
608
609
Returns the type of targets ($TARGETS, $CHANGED_TARGETS) used
609
610
by this action.
@@ -657,7 +658,7 @@ def __call__(self, target, source, env,
657
658
show = _null ,
658
659
execute = _null ,
659
660
chdir = _null ,
660
- executor = None ):
661
+ executor : Optional [ ExecutorType ] = None ):
661
662
if not is_List (target ):
662
663
target = [target ]
663
664
if not is_List (source ):
@@ -741,10 +742,10 @@ def __call__(self, target, source, env,
741
742
# an ABC like parent ActionBase, but things reach in and use it. It's
742
743
# not just unittests or we could fix it up with a concrete subclass there.
743
744
744
- def get_presig (self , target , source , env , executor = None ):
745
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
745
746
raise NotImplementedError
746
747
747
- def get_implicit_deps (self , target , source , env , executor = None ):
748
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
748
749
raise NotImplementedError
749
750
750
751
@@ -1008,6 +1009,7 @@ def __str__(self) -> str:
1008
1009
return ' ' .join (map (str , self .cmd_list ))
1009
1010
return str (self .cmd_list )
1010
1011
1012
+
1011
1013
def process (self , target , source , env , executor = None , overrides : Optional [dict ] = None ) -> Tuple [List , bool , bool ]:
1012
1014
if executor :
1013
1015
result = env .subst_list (self .cmd_list , SUBST_CMD , executor = executor , overrides = overrides )
@@ -1029,7 +1031,7 @@ def process(self, target, source, env, executor=None, overrides: Optional[dict]
1029
1031
pass
1030
1032
return result , ignore , silent
1031
1033
1032
- def strfunction (self , target , source , env , executor = None , overrides : Optional [dict ] = None ) -> str :
1034
+ def strfunction (self , target , source , env , executor : Optional [ ExecutorType ] = None , overrides : Optional [dict ] = None ) -> str :
1033
1035
if self .cmdstr is None :
1034
1036
return None
1035
1037
if self .cmdstr is not _null :
@@ -1044,7 +1046,7 @@ def strfunction(self, target, source, env, executor=None, overrides: Optional[di
1044
1046
return ''
1045
1047
return _string_from_cmd_list (cmd_list [0 ])
1046
1048
1047
- def execute (self , target , source , env , executor = None ):
1049
+ def execute (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1048
1050
"""Execute a command action.
1049
1051
1050
1052
This will handle lists of commands as well as individual commands,
@@ -1106,7 +1108,7 @@ def execute(self, target, source, env, executor=None):
1106
1108
command = cmd_line )
1107
1109
return 0
1108
1110
1109
- def get_presig (self , target , source , env , executor = None ):
1111
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1110
1112
"""Return the signature contents of this action's command line.
1111
1113
1112
1114
This strips $(-$) and everything in between the string,
@@ -1121,7 +1123,7 @@ def get_presig(self, target, source, env, executor=None):
1121
1123
return env .subst_target_source (cmd , SUBST_SIG , executor = executor )
1122
1124
return env .subst_target_source (cmd , SUBST_SIG , target , source )
1123
1125
1124
- def get_implicit_deps (self , target , source , env , executor = None ):
1126
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1125
1127
"""Return the implicit dependencies of this action's command line."""
1126
1128
icd = env .get ('IMPLICIT_COMMAND_DEPENDENCIES' , True )
1127
1129
if is_String (icd ) and icd [:1 ] == '$' :
@@ -1143,7 +1145,7 @@ def get_implicit_deps(self, target, source, env, executor=None):
1143
1145
# lightweight dependency scanning.
1144
1146
return self ._get_implicit_deps_lightweight (target , source , env , executor )
1145
1147
1146
- def _get_implicit_deps_lightweight (self , target , source , env , executor ):
1148
+ def _get_implicit_deps_lightweight (self , target , source , env , executor : Optional [ ExecutorType ] ):
1147
1149
"""
1148
1150
Lightweight dependency scanning involves only scanning the first entry
1149
1151
in an action string, even if it contains &&.
@@ -1164,7 +1166,7 @@ def _get_implicit_deps_lightweight(self, target, source, env, executor):
1164
1166
res .append (env .fs .File (d ))
1165
1167
return res
1166
1168
1167
- def _get_implicit_deps_heavyweight (self , target , source , env , executor ,
1169
+ def _get_implicit_deps_heavyweight (self , target , source , env , executor : Optional [ ExecutorType ] ,
1168
1170
icd_int ):
1169
1171
"""
1170
1172
Heavyweight dependency scanning involves scanning more than just the
@@ -1232,7 +1234,7 @@ def __init__(self, generator, kw) -> None:
1232
1234
self .varlist = kw .get ('varlist' , ())
1233
1235
self .targets = kw .get ('targets' , '$TARGETS' )
1234
1236
1235
- def _generate (self , target , source , env , for_signature , executor = None ):
1237
+ def _generate (self , target , source , env , for_signature , executor : Optional [ ExecutorType ] = None ):
1236
1238
# ensure that target is a list, to make it easier to write
1237
1239
# generator functions:
1238
1240
if not is_List (target ):
@@ -1263,11 +1265,11 @@ def __str__(self) -> str:
1263
1265
def batch_key (self , env , target , source ):
1264
1266
return self ._generate (target , source , env , 1 ).batch_key (env , target , source )
1265
1267
1266
- def genstring (self , target , source , env , executor = None ) -> str :
1268
+ def genstring (self , target , source , env , executor : Optional [ ExecutorType ] = None ) -> str :
1267
1269
return self ._generate (target , source , env , 1 , executor ).genstring (target , source , env )
1268
1270
1269
1271
def __call__ (self , target , source , env , exitstatfunc = _null , presub = _null ,
1270
- show = _null , execute = _null , chdir = _null , executor = None ):
1272
+ show = _null , execute = _null , chdir = _null , executor : Optional [ ExecutorType ] = None ):
1271
1273
act = self ._generate (target , source , env , 0 , executor )
1272
1274
if act is None :
1273
1275
raise SCons .Errors .UserError (
@@ -1279,21 +1281,21 @@ def __call__(self, target, source, env, exitstatfunc=_null, presub=_null,
1279
1281
target , source , env , exitstatfunc , presub , show , execute , chdir , executor
1280
1282
)
1281
1283
1282
- def get_presig (self , target , source , env , executor = None ):
1284
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1283
1285
"""Return the signature contents of this action's command line.
1284
1286
1285
1287
This strips $(-$) and everything in between the string,
1286
1288
since those parts don't affect signatures.
1287
1289
"""
1288
1290
return self ._generate (target , source , env , 1 , executor ).get_presig (target , source , env )
1289
1291
1290
- def get_implicit_deps (self , target , source , env , executor = None ):
1292
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1291
1293
return self ._generate (target , source , env , 1 , executor ).get_implicit_deps (target , source , env )
1292
1294
1293
- def get_varlist (self , target , source , env , executor = None ):
1295
+ def get_varlist (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1294
1296
return self ._generate (target , source , env , 1 , executor ).get_varlist (target , source , env , executor )
1295
1297
1296
- def get_targets (self , env , executor ):
1298
+ def get_targets (self , env , executor : Optional [ ExecutorType ] ):
1297
1299
return self ._generate (None , None , env , 1 , executor ).get_targets (env , executor )
1298
1300
1299
1301
@@ -1339,22 +1341,22 @@ def _generate_cache(self, env):
1339
1341
raise SCons .Errors .UserError ("$%s value %s cannot be used to create an Action." % (self .var , repr (c )))
1340
1342
return gen_cmd
1341
1343
1342
- def _generate (self , target , source , env , for_signature , executor = None ):
1344
+ def _generate (self , target , source , env , for_signature , executor : Optional [ ExecutorType ] = None ):
1343
1345
return self ._generate_cache (env )
1344
1346
1345
1347
def __call__ (self , target , source , env , * args , ** kw ):
1346
1348
c = self .get_parent_class (env )
1347
1349
return c .__call__ (self , target , source , env , * args , ** kw )
1348
1350
1349
- def get_presig (self , target , source , env , executor = None ):
1351
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1350
1352
c = self .get_parent_class (env )
1351
1353
return c .get_presig (self , target , source , env )
1352
1354
1353
- def get_implicit_deps (self , target , source , env , executor = None ):
1355
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1354
1356
c = self .get_parent_class (env )
1355
1357
return c .get_implicit_deps (self , target , source , env )
1356
1358
1357
- def get_varlist (self , target , source , env , executor = None ):
1359
+ def get_varlist (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1358
1360
c = self .get_parent_class (env )
1359
1361
return c .get_varlist (self , target , source , env , executor )
1360
1362
@@ -1387,7 +1389,7 @@ def function_name(self):
1387
1389
except AttributeError :
1388
1390
return "unknown_python_function"
1389
1391
1390
- def strfunction (self , target , source , env , executor = None ):
1392
+ def strfunction (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1391
1393
if self .cmdstr is None :
1392
1394
return None
1393
1395
if self .cmdstr is not _null :
@@ -1428,7 +1430,7 @@ def __str__(self) -> str:
1428
1430
return str (self .execfunction )
1429
1431
return "%s(target, source, env)" % name
1430
1432
1431
- def execute (self , target , source , env , executor = None ):
1433
+ def execute (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1432
1434
exc_info = (None ,None ,None )
1433
1435
try :
1434
1436
if executor :
@@ -1469,14 +1471,14 @@ def execute(self, target, source, env, executor=None):
1469
1471
# more information about this issue.
1470
1472
del exc_info
1471
1473
1472
- def get_presig (self , target , source , env , executor = None ):
1474
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1473
1475
"""Return the signature contents of this callable action."""
1474
1476
try :
1475
1477
return self .gc (target , source , env )
1476
1478
except AttributeError :
1477
1479
return self .funccontents
1478
1480
1479
- def get_implicit_deps (self , target , source , env , executor = None ):
1481
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1480
1482
return []
1481
1483
1482
1484
class ListAction (ActionBase ):
@@ -1493,7 +1495,7 @@ def list_of_actions(x):
1493
1495
self .varlist = ()
1494
1496
self .targets = '$TARGETS'
1495
1497
1496
- def genstring (self , target , source , env , executor = None ) -> str :
1498
+ def genstring (self , target , source , env , executor : Optional [ ExecutorType ] = None ) -> str :
1497
1499
return '\n ' .join ([a .genstring (target , source , env ) for a in self .list ])
1498
1500
1499
1501
def __str__ (self ) -> str :
@@ -1503,15 +1505,15 @@ def presub_lines(self, env):
1503
1505
return SCons .Util .flatten_sequence (
1504
1506
[a .presub_lines (env ) for a in self .list ])
1505
1507
1506
- def get_presig (self , target , source , env , executor = None ):
1508
+ def get_presig (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1507
1509
"""Return the signature contents of this action list.
1508
1510
1509
1511
Simple concatenation of the signatures of the elements.
1510
1512
"""
1511
1513
return b"" .join ([bytes (x .get_contents (target , source , env )) for x in self .list ])
1512
1514
1513
1515
def __call__ (self , target , source , env , exitstatfunc = _null , presub = _null ,
1514
- show = _null , execute = _null , chdir = _null , executor = None ):
1516
+ show = _null , execute = _null , chdir = _null , executor : Optional [ ExecutorType ] = None ):
1515
1517
if executor :
1516
1518
target = executor .get_all_targets ()
1517
1519
source = executor .get_all_sources ()
@@ -1522,13 +1524,13 @@ def __call__(self, target, source, env, exitstatfunc=_null, presub=_null,
1522
1524
return stat
1523
1525
return 0
1524
1526
1525
- def get_implicit_deps (self , target , source , env , executor = None ):
1527
+ def get_implicit_deps (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1526
1528
result = []
1527
1529
for act in self .list :
1528
1530
result .extend (act .get_implicit_deps (target , source , env ))
1529
1531
return result
1530
1532
1531
- def get_varlist (self , target , source , env , executor = None ):
1533
+ def get_varlist (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1532
1534
result = OrderedDict ()
1533
1535
for act in self .list :
1534
1536
for var in act .get_varlist (target , source , env , executor ):
@@ -1594,7 +1596,7 @@ def subst_kw(self, target, source, env):
1594
1596
kw [key ] = self .subst (self .kw [key ], target , source , env )
1595
1597
return kw
1596
1598
1597
- def __call__ (self , target , source , env , executor = None ):
1599
+ def __call__ (self , target , source , env , executor : Optional [ ExecutorType ] = None ):
1598
1600
args = self .subst_args (target , source , env )
1599
1601
kw = self .subst_kw (target , source , env )
1600
1602
return self .parent .actfunc (* args , ** kw )
0 commit comments