Skip to content

Commit 7e120e8

Browse files
authored
Merge pull request SCons#4473 from mwichmann/maint/action-typing
Fix bad typing in Action.py
2 parents 5d37479 + ef3fecf commit 7e120e8

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
7878
Fixes #3529.
7979
- Clarify/fix documentation of Scanners in User Guide and Manpage.
8080
Fixes #4468.
81+
- Fix bad typing in Action.py: process() and strfunction().
8182
- Add Pseudo() to global functions, had been omitted. Fixes #4474.
8283

8384

SCons/Action.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
from abc import ABC, abstractmethod
110110
from collections import OrderedDict
111111
from subprocess import DEVNULL, PIPE
112+
from typing import List, Optional, Tuple
112113

113114
import SCons.Debug
114115
import SCons.Errors
@@ -117,7 +118,7 @@
117118

118119
# we use these a lot, so try to optimize them
119120
from SCons.Debug import logInstanceCreation
120-
from SCons.Subst import SUBST_SIG, SUBST_RAW
121+
from SCons.Subst import SUBST_CMD, SUBST_RAW, SUBST_SIG
121122
from SCons.Util import is_String, is_List
122123

123124
class _null:
@@ -127,13 +128,10 @@ class _null:
127128
execute_actions = True
128129
print_actions_presub = False
129130

130-
# Use pickle protocol 1 when pickling functions for signature
131-
# otherwise python3 and python2 will yield different pickles
132-
# for the same object.
133-
# This is due to default being 1 for python 2.7, and 3 for 3.x
134-
# TODO: We can roll this forward to 2 (if it has value), but not
135-
# before a deprecation cycle as the sconsigns will change
136-
ACTION_SIGNATURE_PICKLE_PROTOCOL = 1
131+
# Use pickle protocol 4 when pickling functions for signature.
132+
# This is the common format since Python 3.4
133+
# TODO: use is commented out as not stable since 2017: e0bc3a04d5. Drop?
134+
# ACTION_SIGNATURE_PICKLE_PROTOCOL = 4
137135

138136

139137
def rfile(n):
@@ -448,7 +446,7 @@ def _do_create_action(act, kw):
448446
return act
449447

450448
if is_String(act):
451-
var=SCons.Util.get_environment_var(act)
449+
var = SCons.Util.get_environment_var(act)
452450
if var:
453451
# This looks like a string that is purely an Environment
454452
# variable reference, like "$FOO" or "${FOO}". We do
@@ -1010,18 +1008,18 @@ def __str__(self) -> str:
10101008
return ' '.join(map(str, self.cmd_list))
10111009
return str(self.cmd_list)
10121010

1013-
def process(self, target, source, env, executor=None, overrides: bool=False):
1011+
def process(self, target, source, env, executor=None, overrides: Optional[dict] = None) -> Tuple[List, bool, bool]:
10141012
if executor:
1015-
result = env.subst_list(self.cmd_list, 0, executor=executor, overrides=overrides)
1013+
result = env.subst_list(self.cmd_list, SUBST_CMD, executor=executor, overrides=overrides)
10161014
else:
1017-
result = env.subst_list(self.cmd_list, 0, target, source, overrides=overrides)
1018-
silent = None
1019-
ignore = None
1015+
result = env.subst_list(self.cmd_list, SUBST_CMD, target, source, overrides=overrides)
1016+
silent = False
1017+
ignore = False
10201018
while True:
10211019
try: c = result[0][0][0]
10221020
except IndexError: c = None
1023-
if c == '@': silent = 1
1024-
elif c == '-': ignore = 1
1021+
if c == '@': silent = True
1022+
elif c == '-': ignore = True
10251023
else: break
10261024
result[0][0] = result[0][0][1:]
10271025
try:
@@ -1031,7 +1029,7 @@ def process(self, target, source, env, executor=None, overrides: bool=False):
10311029
pass
10321030
return result, ignore, silent
10331031

1034-
def strfunction(self, target, source, env, executor=None, overrides: bool=False):
1032+
def strfunction(self, target, source, env, executor=None, overrides: Optional[dict] = None) -> str:
10351033
if self.cmdstr is None:
10361034
return None
10371035
if self.cmdstr is not _null:

0 commit comments

Comments
 (0)