diff options
Diffstat (limited to 'SCons/Node')
-rw-r--r-- | SCons/Node/Alias.py | 16 | ||||
-rw-r--r-- | SCons/Node/AliasTests.py | 16 | ||||
-rw-r--r-- | SCons/Node/FS.py | 166 | ||||
-rw-r--r-- | SCons/Node/FSTests.py | 240 | ||||
-rw-r--r-- | SCons/Node/NodeTests.py | 190 | ||||
-rw-r--r-- | SCons/Node/Python.py | 14 | ||||
-rw-r--r-- | SCons/Node/PythonTests.py | 26 | ||||
-rw-r--r-- | SCons/Node/__init__.py | 122 |
8 files changed, 395 insertions, 395 deletions
diff --git a/SCons/Node/Alias.py b/SCons/Node/Alias.py index 1125c22f6..55c4795e2 100644 --- a/SCons/Node/Alias.py +++ b/SCons/Node/Alias.py @@ -78,7 +78,7 @@ class AliasNodeInfo(SCons.Node.NodeInfoBase): return state - def __setstate__(self, state): + def __setstate__(self, state) -> None: """ Restore the attributes from a pickled state. """ @@ -98,7 +98,7 @@ class Alias(SCons.Node.Node): NodeInfo = AliasNodeInfo BuildInfo = AliasBuildInfo - def __init__(self, name): + def __init__(self, name) -> None: super().__init__() self.name = name self.changed_since_last_build = 1 @@ -107,16 +107,16 @@ class Alias(SCons.Node.Node): def str_for_display(self): return '"' + self.__str__() + '"' - def __str__(self): + def __str__(self) -> str: return self.name - def make_ready(self): + def make_ready(self) -> None: self.get_csig() really_build = SCons.Node.Node.build is_up_to_date = SCons.Node.Node.children_are_up_to_date - def is_under(self, dir): + def is_under(self, dir) -> int: # Make Alias nodes get built regardless of # what directory scons was run from. Alias nodes # are outside the filesystem: @@ -128,7 +128,7 @@ class Alias(SCons.Node.Node): childsigs = [n.get_csig() for n in self.children()] return ''.join(childsigs) - def sconsign(self): + def sconsign(self) -> None: """An Alias is not recorded in .sconsign files""" pass @@ -136,11 +136,11 @@ class Alias(SCons.Node.Node): # # - def build(self): + def build(self) -> None: """A "builder" for aliases.""" pass - def convert(self): + def convert(self) -> None: try: del self.builder except AttributeError: pass self.reset_executor() diff --git a/SCons/Node/AliasTests.py b/SCons/Node/AliasTests.py index 14662fd9c..78138f93a 100644 --- a/SCons/Node/AliasTests.py +++ b/SCons/Node/AliasTests.py @@ -28,13 +28,13 @@ import SCons.Node.Alias class AliasTestCase(unittest.TestCase): - def test_AliasNameSpace(self): + def test_AliasNameSpace(self) -> None: """Test creating an Alias name space """ ans = SCons.Node.Alias.AliasNameSpace() assert ans is not None, ans - def test_ANS_Alias(self): + def test_ANS_Alias(self) -> None: """Test the Alias() factory """ ans = SCons.Node.Alias.AliasNameSpace() @@ -45,11 +45,11 @@ class AliasTestCase(unittest.TestCase): a2 = ans.Alias('a1') assert a1 is a2, (a1, a2) - def test_get_contents(self): + def test_get_contents(self) -> None: """Test the get_contents() method """ class DummyNode: - def __init__(self, contents): + def __init__(self, contents) -> None: self.contents = contents def get_csig(self): return self.contents @@ -66,7 +66,7 @@ class AliasTestCase(unittest.TestCase): c = a.get_contents() assert c == 'onetwothree', c - def test_lookup(self): + def test_lookup(self) -> None: """Test the lookup() method """ ans = SCons.Node.Alias.AliasNameSpace() @@ -81,7 +81,7 @@ class AliasTestCase(unittest.TestCase): a = ans.lookup('a2') assert a is None, a - def test_Alias(self): + def test_Alias(self) -> None: """Test creating an Alias() object """ a1 = SCons.Node.Alias.Alias('a') @@ -94,14 +94,14 @@ class AliasTestCase(unittest.TestCase): assert a1.name == a2.name class AliasNodeInfoTestCase(unittest.TestCase): - def test___init__(self): + def test___init__(self) -> None: """Test AliasNodeInfo initialization""" ans = SCons.Node.Alias.AliasNameSpace() aaa = ans.Alias('aaa') ni = SCons.Node.Alias.AliasNodeInfo() class AliasBuildInfoTestCase(unittest.TestCase): - def test___init__(self): + def test___init__(self) -> None: """Test AliasBuildInfo initialization""" ans = SCons.Node.Alias.AliasNameSpace() aaa = ans.Alias('aaa') diff --git a/SCons/Node/FS.py b/SCons/Node/FS.py index 67e1ff608..58b8a5cf4 100644 --- a/SCons/Node/FS.py +++ b/SCons/Node/FS.py @@ -81,11 +81,11 @@ class EntryProxyAttributeError(AttributeError): An AttributeError subclass for recording and displaying the name of the underlying Entry involved in an AttributeError exception. """ - def __init__(self, entry_proxy, attribute): + def __init__(self, entry_proxy, attribute) -> None: super().__init__() self.entry_proxy = entry_proxy self.attribute = attribute - def __str__(self): + def __str__(self) -> str: entry = self.entry_proxy.get() fmt = "%s instance %s has no attribute %s" return fmt % (entry.__class__.__name__, @@ -116,7 +116,7 @@ default_max_drift = 2*24*60*60 # Save_Strings = None -def save_strings(val): +def save_strings(val) -> None: global Save_Strings Save_Strings = val @@ -130,7 +130,7 @@ def save_strings(val): do_splitdrive = None _my_splitdrive =None -def initialize_do_splitdrive(): +def initialize_do_splitdrive() -> None: global do_splitdrive global has_unc drive, path = os.path.splitdrive('X:/foo') @@ -231,7 +231,7 @@ needs_normpath_match = needs_normpath_check.match # TODO: See if theres a reasonable way to enable using links on win32/64 if hasattr(os, 'link') and sys.platform != 'win32': - def _hardlink_func(fs, src, dst): + def _hardlink_func(fs, src, dst) -> None: # If the source is a symlink, we can't just hard-link to it # because a relative symlink may point somewhere completely # different. We must disambiguate the symlink and then @@ -247,12 +247,12 @@ else: _hardlink_func = None if hasattr(os, 'symlink') and sys.platform != 'win32': - def _softlink_func(fs, src, dst): + def _softlink_func(fs, src, dst) -> None: fs.symlink(src, dst) else: _softlink_func = None -def _copy_func(fs, src, dest): +def _copy_func(fs, src, dest) -> None: shutil.copy2(src, dest) st = fs.stat(src) fs.chmod(dest, stat.S_IMODE(st.st_mode) | stat.S_IWRITE) @@ -286,7 +286,7 @@ def set_duplicate(duplicate): if link_dict[func]: Link_Funcs.append(link_dict[func]) -def LinkFunc(target, source, env): +def LinkFunc(target, source, env) -> int: """ Relative paths cause problems with symbolic links, so we use absolute paths, which may be a problem for people @@ -321,19 +321,19 @@ def LinkFunc(target, source, env): return 0 Link = SCons.Action.Action(LinkFunc, None) -def LocalString(target, source, env): +def LocalString(target, source, env) -> str: return 'Local copy of %s from %s' % (target[0], source[0]) LocalCopy = SCons.Action.Action(LinkFunc, LocalString) -def UnlinkFunc(target, source, env): +def UnlinkFunc(target, source, env) -> int: t = target[0] t.fs.unlink(t.get_abspath()) return 0 Unlink = SCons.Action.Action(UnlinkFunc, None) -def MkdirFunc(target, source, env): +def MkdirFunc(target, source, env) -> int: t = target[0] # This os.path.exists test looks redundant, but it's possible # when using Install() to install multiple dirs outside the @@ -385,7 +385,7 @@ class DiskChecker: This Class will hold functions to determine what this particular disk checking implementation should do when enabled or disabled. """ - def __init__(self, disk_check_type, do_check_function, ignore_check_function): + def __init__(self, disk_check_type, do_check_function, ignore_check_function) -> None: self.disk_check_type = disk_check_type self.do_check_function = do_check_function self.ignore_check_function = ignore_check_function @@ -394,7 +394,7 @@ class DiskChecker: def __call__(self, *args, **kw): return self.func(*args, **kw) - def enable(self, disk_check_type_list): + def enable(self, disk_check_type_list) -> None: """ If the current object's disk_check_type matches any in the list passed :param disk_check_type_list: List of disk checks to enable @@ -423,7 +423,7 @@ def do_diskcheck_match(node, predicate, errorfmt): raise TypeError(errorfmt % node.get_abspath()) -def ignore_diskcheck_match(node, predicate, errorfmt): +def ignore_diskcheck_match(node, predicate, errorfmt) -> None: pass @@ -434,7 +434,7 @@ diskcheckers = [ ] -def set_diskcheck(enabled_checkers): +def set_diskcheck(enabled_checkers) -> None: for dc in diskcheckers: dc.enable(enabled_checkers) @@ -584,7 +584,7 @@ class Base(SCons.Node.Node): '_proxy', '_func_sconsign'] - def __init__(self, name, directory, fs): + def __init__(self, name, directory, fs) -> None: """Initialize a generic Node.FS.Base object. Call the superclass initialization, take care of setting up @@ -663,7 +663,7 @@ class Base(SCons.Node.Node): raise AttributeError("%r object has no attribute %r" % (self.__class__, attr)) - def __str__(self): + def __str__(self) -> str: """A Node.FS.Base object's string representation is its path name.""" global Save_Strings @@ -775,7 +775,7 @@ class Base(SCons.Node.Node): st = self.lstat() return st is not None and stat.S_ISLNK(st.st_mode) else: - def islink(self): + def islink(self) -> bool: return False # no symlinks def is_under(self, dir): @@ -784,7 +784,7 @@ class Base(SCons.Node.Node): else: return self.dir.is_under(dir) - def set_local(self): + def set_local(self) -> None: self._local = 1 def srcnode(self): @@ -817,7 +817,7 @@ class Base(SCons.Node.Node): pathname += p.dirname return pathname + path_elems[-1].name - def set_src_builder(self, builder): + def set_src_builder(self, builder) -> None: """Set the source code builder for this node.""" self.sbuilder = builder if not self.has_builder(): @@ -951,7 +951,7 @@ class Base(SCons.Node.Node): self._memo['rentry'] = result return result - def _glob1(self, pattern, ondisk=True, source=False, strings=False): + def _glob1(self, pattern, ondisk: bool=True, source: bool=False, strings: bool=False): return [] # Dict that provides a simple backward compatibility @@ -989,12 +989,12 @@ class Entry(Base): 'released_target_info', 'contentsig'] - def __init__(self, name, directory, fs): + def __init__(self, name, directory, fs) -> None: super().__init__(name, directory, fs) self._func_exists = 3 self._func_get_contents = 1 - def diskcheck_match(self): + def diskcheck_match(self) -> None: pass def disambiguate(self, must_exist=None): @@ -1066,7 +1066,7 @@ class Entry(Base): else: return self.get_text_contents() - def must_be_same(self, klass): + def must_be_same(self, klass) -> None: """Called to make sure a Node is a Dir. Since we're an Entry, we can morph into one.""" if self.__class__ is not klass: @@ -1097,7 +1097,7 @@ class Entry(Base): def new_ninfo(self): return self.disambiguate().new_ninfo() - def _glob1(self, pattern, ondisk=True, source=False, strings=False): + def _glob1(self, pattern, ondisk: bool=True, source: bool=False, strings: bool=False): return self.disambiguate()._glob1(pattern, ondisk, source, strings) def get_subst_proxy(self): @@ -1162,10 +1162,10 @@ class LocalFS: def scandir(self, path): return os.scandir(path) - def makedirs(self, path, mode=0o777, exist_ok=False): + def makedirs(self, path, mode: int=0o777, exist_ok: bool=False): return os.makedirs(path, mode=mode, exist_ok=exist_ok) - def mkdir(self, path, mode=0o777): + def mkdir(self, path, mode: int=0o777): return os.mkdir(path, mode=mode) def rename(self, old, new): @@ -1190,7 +1190,7 @@ class LocalFS: else: - def islink(self, path): + def islink(self, path) -> bool: return False # no symlinks if hasattr(os, 'readlink'): @@ -1200,13 +1200,13 @@ class LocalFS: else: - def readlink(self, file): + def readlink(self, file) -> str: return '' class FS(LocalFS): - def __init__(self, path = None): + def __init__(self, path = None) -> None: """Initialize the Node.FS subsystem. The supplied path is the top of the source tree, where we @@ -1238,13 +1238,13 @@ class FS(LocalFS): DirNodeInfo.fs = self FileNodeInfo.fs = self - def set_SConstruct_dir(self, dir): + def set_SConstruct_dir(self, dir) -> None: self.SConstruct_dir = dir def get_max_drift(self): return self.max_drift - def set_max_drift(self, max_drift): + def set_max_drift(self, max_drift) -> None: self.max_drift = max_drift def getcwd(self): @@ -1253,7 +1253,7 @@ class FS(LocalFS): else: return "<no cwd>" - def chdir(self, dir, change_os_dir=False): + def chdir(self, dir, change_os_dir: bool=False): """Change the current working directory for lookups. If change_os_dir is true, we will also change the "real" cwd to match. @@ -1285,7 +1285,7 @@ class FS(LocalFS): self.Root[''] = root return root - def _lookup(self, p, directory, fsclass, create=1): + def _lookup(self, p, directory, fsclass, create: int=1): """ The generic entry point for Node lookup with user-supplied data. @@ -1421,7 +1421,7 @@ class FS(LocalFS): return root._lookup_abs(p, fsclass, create) - def Entry(self, name, directory = None, create = 1): + def Entry(self, name, directory = None, create: int = 1): """Look up or create a generic Entry node with the specified name. If the name is a relative path (begins with ./, ../, or a file name), then it is looked up relative to the supplied directory @@ -1430,7 +1430,7 @@ class FS(LocalFS): """ return self._lookup(name, directory, Entry, create) - def File(self, name, directory = None, create = 1): + def File(self, name, directory = None, create: int = 1): """Look up or create a File node with the specified name. If the name is a relative path (begins with ./, ../, or a file name), then it is looked up relative to the supplied directory node, @@ -1442,7 +1442,7 @@ class FS(LocalFS): """ return self._lookup(name, directory, File, create) - def Dir(self, name, directory = None, create = True): + def Dir(self, name, directory = None, create: bool = True): """Look up or create a Dir node with the specified name. If the name is a relative path (begins with ./, ../, or a file name), then it is looked up relative to the supplied directory node, @@ -1454,7 +1454,7 @@ class FS(LocalFS): """ return self._lookup(name, directory, Dir, create) - def VariantDir(self, variant_dir, src_dir, duplicate=1): + def VariantDir(self, variant_dir, src_dir, duplicate: int=1): """Link the supplied variant directory to the source directory for purposes of building files.""" @@ -1470,7 +1470,7 @@ class FS(LocalFS): raise SCons.Errors.UserError("'%s' already has a source directory: '%s'."%(variant_dir, variant_dir.srcdir)) variant_dir.link(src_dir, duplicate) - def Repository(self, *dirs): + def Repository(self, *dirs) -> None: """Specify Repository directories to search.""" for d in dirs: if not isinstance(d, SCons.Node.Node): @@ -1521,7 +1521,7 @@ class FS(LocalFS): message = fmt % ' '.join(map(str, targets)) return targets, message - def Glob(self, pathname, ondisk=True, source=True, strings=False, exclude=None, cwd=None): + def Glob(self, pathname, ondisk: bool=True, source: bool=True, strings: bool=False, exclude=None, cwd=None): """ Globs @@ -1555,7 +1555,7 @@ class DirBuildInfo(SCons.Node.BuildInfoBase): glob_magic_check = re.compile('[*?[]') -def has_glob_magic(s): +def has_glob_magic(s) -> bool: return glob_magic_check.search(s) is not None class Dir(Base): @@ -1580,12 +1580,12 @@ class Dir(Base): NodeInfo = DirNodeInfo BuildInfo = DirBuildInfo - def __init__(self, name, directory, fs): + def __init__(self, name, directory, fs) -> None: if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.Dir') super().__init__(name, directory, fs) self._morph() - def _morph(self): + def _morph(self) -> None: """Turn a file system Node (either a freshly initialized directory object or a separate Entry object) into a proper directory object. @@ -1649,11 +1649,11 @@ class Dir(Base): l.insert(0, a) self.get_executor().set_action_list(l) - def diskcheck_match(self): + def diskcheck_match(self) -> None: diskcheck_match(self, self.isfile, "File %s found where directory expected.") - def __clearRepositoryCache(self, duplicate=None): + def __clearRepositoryCache(self, duplicate=None) -> None: """Called when we change the repository(ies) for a directory. This clears any cached information that is invalidated by changing the repository.""" @@ -1671,7 +1671,7 @@ class Dir(Base): if duplicate is not None: node.duplicate = duplicate - def __resetDuplicate(self, node): + def __resetDuplicate(self, node) -> None: if node != self: node.duplicate = node.get_dir().duplicate @@ -1682,7 +1682,7 @@ class Dir(Base): """ return self.fs.Entry(name, self) - def Dir(self, name, create=True): + def Dir(self, name, create: bool=True): """ Looks up or creates a directory node named 'name' relative to this directory. @@ -1696,7 +1696,7 @@ class Dir(Base): """ return self.fs.File(name, self) - def link(self, srcdir, duplicate): + def link(self, srcdir, duplicate) -> None: """Set this directory as the variant directory for the supplied source directory.""" self.srcdir = srcdir @@ -1734,7 +1734,7 @@ class Dir(Base): return result - def addRepository(self, dir): + def addRepository(self, dir) -> None: if dir != self and dir not in self.repositories: self.repositories.append(dir) dir._tpath = '.' @@ -1834,10 +1834,10 @@ class Dir(Base): # Taskmaster interface subsystem # - def prepare(self): + def prepare(self) -> None: pass - def build(self, **kw): + def build(self, **kw) -> None: """A null "builder" for directories.""" global MkdirBuilder if self.builder is not MkdirBuilder: @@ -1911,10 +1911,10 @@ class Dir(Base): contents = self.get_contents() return hash_signature(contents) - def do_duplicate(self, src): + def do_duplicate(self, src) -> None: pass - def is_up_to_date(self): + def is_up_to_date(self) -> int: """If any child is not up-to-date, then this directory isn't, either.""" if self.builder is not MkdirBuilder and not self.exists(): @@ -2145,7 +2145,7 @@ class Dir(Base): return None return node - def walk(self, func, arg): + def walk(self, func, arg) -> None: """ Walk this directory tree by calling the specified function for each directory in the tree. @@ -2171,7 +2171,7 @@ class Dir(Base): for dirname in [n for n in names if isinstance(entries[n], Dir)]: entries[dirname].walk(func, arg) - def glob(self, pathname, ondisk=True, source=False, strings=False, exclude=None) -> list: + def glob(self, pathname, ondisk: bool=True, source: bool=False, strings: bool=False, exclude=None) -> list: """Returns a list of Nodes (or strings) matching a pathname pattern. Pathname patterns follow POSIX shell syntax:: @@ -2234,7 +2234,7 @@ class Dir(Base): result = [x for x in result if not any(fnmatch.fnmatch(str(x), str(e)) for e in SCons.Util.flatten(excludes))] return sorted(result, key=lambda a: str(a)) - def _glob1(self, pattern, ondisk=True, source=False, strings=False): + def _glob1(self, pattern, ondisk: bool=True, source: bool=False, strings: bool=False): """ Globs for and returns a list of entry names matching a single pattern in this directory. @@ -2313,7 +2313,7 @@ class RootDir(Dir): __slots__ = ('_lookupDict', 'abspath', 'path') - def __init__(self, drive, fs): + def __init__(self, drive, fs) -> None: if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.RootDir') SCons.Node.Node.__init__(self) @@ -2371,7 +2371,7 @@ class RootDir(Dir): if not has_unc: self._lookupDict['//'] = self - def _morph(self): + def _morph(self) -> None: """Turn a file system Node (either a freshly initialized directory object or a separate Entry object) into a proper directory object. @@ -2412,12 +2412,12 @@ class RootDir(Dir): self.get_executor().set_action_list(l) - def must_be_same(self, klass): + def must_be_same(self, klass) -> None: if klass is Dir: return Base.must_be_same(self, klass) - def _lookup_abs(self, p, klass, create=True): + def _lookup_abs(self, p, klass, create: bool=True): """ Fast (?) lookup of a *normalized* absolute path. @@ -2459,7 +2459,7 @@ class RootDir(Dir): result.must_be_same(klass) return result - def __str__(self): + def __str__(self) -> str: return self._abspath def entry_abspath(self, name): @@ -2474,7 +2474,7 @@ class RootDir(Dir): def entry_tpath(self, name): return self._tpath + name - def is_under(self, dir): + def is_under(self, dir) -> int: if self is dir: return 1 else: @@ -2531,7 +2531,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): return state - def __setstate__(self, state): + def __setstate__(self, state) -> None: """ Restore the attributes from a pickled state. """ @@ -2544,7 +2544,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase): def __eq__(self, other): return self.csig == other.csig and self.timestamp == other.timestamp and self.size == other.size - def __ne__(self, other): + def __ne__(self, other) -> bool: return not self.__eq__(other) @@ -2577,7 +2577,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): return super().__setattr__(key, value) - def convert_to_sconsign(self): + def convert_to_sconsign(self) -> None: """ Converts this FileBuildInfo object for writing to a .sconsign file @@ -2604,7 +2604,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): else: setattr(self, attr, list(map(node_to_str, val))) - def convert_from_sconsign(self, dir, name): + def convert_from_sconsign(self, dir, name) -> None: """ Converts a newly-read FileBuildInfo object for in-SCons use @@ -2613,7 +2613,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): """ pass - def prepare_dependencies(self): + def prepare_dependencies(self) -> None: """ Prepares a FileBuildInfo object for explaining what changed @@ -2642,7 +2642,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase): nodes.append(s) setattr(self, nattr, nodes) - def format(self, names=0): + def format(self, names: int=0): result = [] bkids = self.bsources + self.bdepends + self.bimplicit bkidsigs = self.bsourcesigs + self.bdependsigs + self.bimplicitsigs @@ -2680,11 +2680,11 @@ class File(Base): # Although the command-line argument is in kilobytes, this is in bytes. hash_chunksize = 65536 - def diskcheck_match(self): + def diskcheck_match(self) -> None: diskcheck_match(self, self.isdir, "Directory %s found where file expected.") - def __init__(self, name, directory, fs): + def __init__(self, name, directory, fs) -> None: if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.File') super().__init__(name, directory, fs) self._morph() @@ -2694,7 +2694,7 @@ class File(Base): the directory of this file.""" return self.dir.Entry(name) - def Dir(self, name, create=True): + def Dir(self, name, create: bool=True): """Create a directory node named 'name' relative to the directory of this file.""" return self.dir.Dir(name, create=create) @@ -2709,7 +2709,7 @@ class File(Base): the directory of this file.""" return self.dir.File(name) - def _morph(self): + def _morph(self) -> None: """Turn a file system node into a File object.""" self.scanner_paths = {} if not hasattr(self, '_local'): @@ -2997,12 +2997,12 @@ class File(Base): return result - def _createDir(self): + def _createDir(self) -> None: # ensure that the directories for this node are # created. self.dir._create() - def push_to_cache(self): + def push_to_cache(self) -> None: """Try to push the node into a cache """ # This should get called before the Nodes' .built() method is @@ -3033,7 +3033,7 @@ class File(Base): return None return self.get_build_env().get_CacheDir().retrieve(self) - def visited(self): + def visited(self) -> None: if self.exists() and self.executor is not None: self.get_build_env().get_CacheDir().push_if_forced(self) @@ -3056,7 +3056,7 @@ class File(Base): SCons.Node.store_info_map[self.store_info](self) - def release_target_info(self): + def release_target_info(self) -> None: """Called just after this node has been marked up-to-date or was built completely. @@ -3123,7 +3123,7 @@ class File(Base): self.builder_set(scb) return scb - def has_src_builder(self): + def has_src_builder(self) -> bool: """Return whether this Node has a source builder or not. If this Node doesn't have an explicit source code builder, this @@ -3159,7 +3159,7 @@ class File(Base): # Taskmaster interface subsystem # - def make_ready(self): + def make_ready(self) -> None: self.has_src_builder() self.get_binfo() @@ -3282,11 +3282,11 @@ class File(Base): # DECISION SUBSYSTEM # - def builder_set(self, builder): + def builder_set(self, builder) -> None: SCons.Node.Node.builder_set(self, builder) self.changed_since_last_build = 5 - def built(self): + def built(self) -> None: """Called just after this File node is successfully built. Just like for 'release_target_info' we try to release @@ -3310,7 +3310,7 @@ class File(Base): self.scanner_paths = None - def changed(self, node=None, allowcache=False): + def changed(self, node=None, allowcache: bool=False): """ Returns if the node is up-to-date with respect to the BuildInfo stored last time it was built. @@ -3728,7 +3728,7 @@ class FileFinder: """ """ - def __init__(self): + def __init__(self) -> None: self._memo = {} def filedir_lookup(self, p, fd=None): @@ -3826,7 +3826,7 @@ class FileFinder: find_file = FileFinder().find_file -def invalidate_node_memos(targets): +def invalidate_node_memos(targets) -> None: """ Invalidate the memoized values of all Nodes (files or directories) that are associated with the given entries. Has been added to diff --git a/SCons/Node/FSTests.py b/SCons/Node/FSTests.py index f3afacea3..e2eb0af70 100644 --- a/SCons/Node/FSTests.py +++ b/SCons/Node/FSTests.py @@ -44,7 +44,7 @@ scanner_count = 0 class Scanner: - def __init__(self, node=None): + def __init__(self, node=None) -> None: global scanner_count scanner_count = scanner_count + 1 self.hash = scanner_count @@ -67,7 +67,7 @@ class Scanner: class Environment: - def __init__(self): + def __init__(self) -> None: self.scanner = Scanner() def Dictionary(self, *args): @@ -82,27 +82,27 @@ class Environment: def Override(self, overrides): return self - def _update(self, dict): + def _update(self, dict) -> None: pass class Action: - def __call__(self, targets, sources, env, **kw): + def __call__(self, targets, sources, env, **kw) -> int: global built_it if kw.get('execute', 1): built_it = 1 return 0 - def show(self, string): + def show(self, string) -> None: pass def get_contents(self, target, source, env): return bytearray("", 'utf-8') - def genstring(self, target, source, env): + def genstring(self, target, source, env) -> str: return "" - def strfunction(self, targets, sources, env): + def strfunction(self, targets, sources, env) -> str: return "" def get_implicit_deps(self, target, source, env): @@ -110,7 +110,7 @@ class Action: class Builder: - def __init__(self, factory, action=Action()): + def __init__(self, factory, action=Action()) -> None: self.factory = factory self.env = Environment() self.overrides = {} @@ -126,19 +126,19 @@ class Builder: class _tempdirTestCase(unittest.TestCase): - def setUp(self): + def setUp(self) -> None: self.save_cwd = os.getcwd() self.test = TestCmd(workdir='') # FS doesn't like the cwd to be something other than its root. os.chdir(self.test.workpath("")) self.fs = SCons.Node.FS.FS() - def tearDown(self): + def tearDown(self) -> None: os.chdir(self.save_cwd) class VariantDirTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test variant dir functionality""" test = TestCmd(workdir='') @@ -316,10 +316,10 @@ class VariantDirTestCase(unittest.TestCase): f9 = fs.File('build/var2/new_dir/test9.out') class MkdirAction(Action): - def __init__(self, dir_made): + def __init__(self, dir_made) -> None: self.dir_made = dir_made - def __call__(self, target, source, env, executor=None): + def __call__(self, target, source, env, executor=None) -> None: if executor: target = executor.get_all_targets() source = executor.get_all_sources() @@ -328,7 +328,7 @@ class VariantDirTestCase(unittest.TestCase): save_Link = SCons.Node.FS.Link link_made = [] - def link_func(target, source, env, link_made=link_made): + def link_func(target, source, env, link_made=link_made) -> None: link_made.append(target) SCons.Node.FS.Link = link_func @@ -458,7 +458,7 @@ class VariantDirTestCase(unittest.TestCase): class LinkSimulator: """A class to intercept os.[sym]link() calls and track them.""" - def __init__(self, duplicate, link, symlink, copy): + def __init__(self, duplicate, link, symlink, copy) -> None: self.duplicate = duplicate self.have = {'hard': link, 'soft': symlink, 'copy': copy} @@ -481,7 +481,7 @@ class VariantDirTestCase(unittest.TestCase): "instead of soft" % next_link raise OSError("Simulating symlink creation error.") - def copy(self, src, dest): + def copy(self, src, dest) -> None: next_link = self.links_to_be_called.pop(0) assert next_link == "copy", \ "Wrong link order: expected %s to be called " \ @@ -631,7 +631,7 @@ class VariantDirTestCase(unittest.TestCase): class BaseTestCase(_tempdirTestCase): - def test_stat(self): + def test_stat(self) -> None: """Test the Base.stat() method""" test = self.test test.write("e1", "e1\n") @@ -645,7 +645,7 @@ class BaseTestCase(_tempdirTestCase): s = e2.stat() assert s is None, s - def test_getmtime(self): + def test_getmtime(self) -> None: """Test the Base.getmtime() method""" test = self.test test.write("file", "file\n") @@ -658,7 +658,7 @@ class BaseTestCase(_tempdirTestCase): mtime = file.getmtime() assert mtime is None, mtime - def test_getsize(self): + def test_getsize(self) -> None: """Test the Base.getsize() method""" test = self.test test.write("file", "file\n") @@ -672,7 +672,7 @@ class BaseTestCase(_tempdirTestCase): size = file.getsize() assert size is None, size - def test_isdir(self): + def test_isdir(self) -> None: """Test the Base.isdir() method""" test = self.test test.subdir('dir') @@ -688,7 +688,7 @@ class BaseTestCase(_tempdirTestCase): nonexistent = fs.Entry('nonexistent') assert not nonexistent.isdir() - def test_isfile(self): + def test_isfile(self) -> None: """Test the Base.isfile() method""" test = self.test test.subdir('dir') @@ -706,7 +706,7 @@ class BaseTestCase(_tempdirTestCase): @unittest.skipUnless(sys.platform != 'win32' and hasattr(os, 'symlink'), "symlink is not used on Windows") - def test_islink(self): + def test_islink(self) -> None: """Test the Base.islink() method""" test = self.test test.subdir('dir') @@ -728,27 +728,27 @@ class BaseTestCase(_tempdirTestCase): class DirNodeInfoTestCase(_tempdirTestCase): - def test___init__(self): + def test___init__(self) -> None: """Test DirNodeInfo initialization""" ddd = self.fs.Dir('ddd') ni = SCons.Node.FS.DirNodeInfo() class DirBuildInfoTestCase(_tempdirTestCase): - def test___init__(self): + def test___init__(self) -> None: """Test DirBuildInfo initialization""" ddd = self.fs.Dir('ddd') bi = SCons.Node.FS.DirBuildInfo() class FileNodeInfoTestCase(_tempdirTestCase): - def test___init__(self): + def test___init__(self) -> None: """Test FileNodeInfo initialization""" fff = self.fs.File('fff') ni = SCons.Node.FS.FileNodeInfo() assert isinstance(ni, SCons.Node.FS.FileNodeInfo) - def test_update(self): + def test_update(self) -> None: """Test updating a File.NodeInfo with on-disk information""" test = self.test fff = self.fs.File('fff') @@ -788,31 +788,31 @@ class FileNodeInfoTestCase(_tempdirTestCase): class FileBuildInfoTestCase(_tempdirTestCase): - def test___init__(self): + def test___init__(self) -> None: """Test File.BuildInfo initialization""" fff = self.fs.File('fff') bi = SCons.Node.FS.FileBuildInfo() assert bi, bi - def test_convert_to_sconsign(self): + def test_convert_to_sconsign(self) -> None: """Test converting to .sconsign file format""" fff = self.fs.File('fff') bi = SCons.Node.FS.FileBuildInfo() assert hasattr(bi, 'convert_to_sconsign') - def test_convert_from_sconsign(self): + def test_convert_from_sconsign(self) -> None: """Test converting from .sconsign file format""" fff = self.fs.File('fff') bi = SCons.Node.FS.FileBuildInfo() assert hasattr(bi, 'convert_from_sconsign') - def test_prepare_dependencies(self): + def test_prepare_dependencies(self) -> None: """Test that we have a prepare_dependencies() method""" fff = self.fs.File('fff') bi = SCons.Node.FS.FileBuildInfo() bi.prepare_dependencies() - def test_format(self): + def test_format(self) -> None: """Test the format() method""" f1 = self.fs.File('f1') bi1 = SCons.Node.FS.FileBuildInfo() @@ -850,7 +850,7 @@ class FileBuildInfoTestCase(_tempdirTestCase): class FSTestCase(_tempdirTestCase): - def test_needs_normpath(self): + def test_needs_normpath(self) -> None: """Test the needs_normpath Regular expression This test case verifies that the regular expression used to @@ -1048,7 +1048,7 @@ class FSTestCase(_tempdirTestCase): drive, path = os.path.splitdrive(os.getcwd()) - def _do_Dir_test(lpath, path_, abspath_, up_path_, sep, fileSys=fs, drive=drive): + def _do_Dir_test(lpath, path_, abspath_, up_path_, sep, fileSys=fs, drive=drive) -> None: dir = fileSys.Dir(lpath.replace('/', sep)) if os.sep != '/': @@ -1194,7 +1194,7 @@ class FSTestCase(_tempdirTestCase): f1.build() assert built_it - def match(path, expect): + def match(path, expect) -> None: expect = expect.replace('/', os.sep) assert path == expect, "path %s != expected %s" % (path, expect) @@ -1569,7 +1569,7 @@ class FSTestCase(_tempdirTestCase): f.get_string(0) assert f.get_string(1) == 'baz', f.get_string(1) - def test_drive_letters(self): + def test_drive_letters(self) -> None: """Test drive-letter look-ups""" test = self.test @@ -1608,7 +1608,7 @@ class FSTestCase(_tempdirTestCase): if os.sep != '/': seps = seps + ['/'] - def _do_Dir_test(lpath, path_, up_path_, sep, fileSys=fs): + def _do_Dir_test(lpath, path_, up_path_, sep, fileSys=fs) -> None: dir = fileSys.Dir(lpath.replace('/', sep)) if os.sep != '/': @@ -1670,7 +1670,7 @@ class FSTestCase(_tempdirTestCase): os.sep = save_os_sep SCons.Node.FS.initialize_do_splitdrive() - def test_unc_path(self): + def test_unc_path(self) -> None: """Test UNC path look-ups""" test = self.test @@ -1719,7 +1719,7 @@ class FSTestCase(_tempdirTestCase): if os.sep != '/': seps = seps + ['/'] - def _do_Dir_test(lpath, path, up_path, sep, fileSys=fs): + def _do_Dir_test(lpath, path, up_path, sep, fileSys=fs) -> None: dir = fileSys.Dir(lpath.replace('/', sep)) if os.sep != '/': @@ -1784,7 +1784,7 @@ class FSTestCase(_tempdirTestCase): os.sep = save_os_sep SCons.Node.FS.initialize_do_splitdrive() - def test_target_from_source(self): + def test_target_from_source(self) -> None: """Test the method for generating target nodes from sources""" fs = self.fs @@ -1813,7 +1813,7 @@ class FSTestCase(_tempdirTestCase): assert str(t) == 'pre-eee-suf', str(t) assert t.__class__ == SCons.Node.FS.Entry - def test_same_name(self): + def test_same_name(self) -> None: """Test that a local same-named file isn't found for a Dir lookup""" test = self.test fs = self.fs @@ -1825,7 +1825,7 @@ class FSTestCase(_tempdirTestCase): fs.chdir(subdir, change_os_dir=True) self.fs._lookup('#build/file', subdir, SCons.Node.FS.File) - def test_above_root(self): + def test_above_root(self) -> None: """Testing looking up a path above the root directory""" test = self.test fs = self.fs @@ -1836,7 +1836,7 @@ class FSTestCase(_tempdirTestCase): above_path = os.path.join(*['..'] * len(dirs) + ['above']) above = d2.Dir(above_path) - def test_lookup_abs(self): + def test_lookup_abs(self) -> None: """Exercise the _lookup_abs function""" test = self.test fs = self.fs @@ -1846,7 +1846,7 @@ class FSTestCase(_tempdirTestCase): assert d.__class__ == SCons.Node.FS.Dir, str(d.__class__) @unittest.skipUnless(sys.platform == "win32", "requires Windows") - def test_lookup_uncpath(self): + def test_lookup_uncpath(self) -> None: """Testing looking up a UNC path on Windows""" test = self.test fs = self.fs @@ -1858,13 +1858,13 @@ class FSTestCase(_tempdirTestCase): 'UNC path %s got looked up as %s' % (path, f) @unittest.skipUnless(sys.platform.startswith == "win32", "requires Windows") - def test_unc_drive_letter(self): + def test_unc_drive_letter(self) -> None: """Test drive-letter lookup for windows UNC-style directories""" share = self.fs.Dir(r'\\SERVER\SHARE\Directory') assert str(share) == r'\\SERVER\SHARE\Directory', str(share) @unittest.skipUnless(sys.platform == "win32", "requires Windows") - def test_UNC_dirs_2689(self): + def test_UNC_dirs_2689(self) -> None: """Test some UNC dirs that printed incorrectly and/or caused infinite recursion errors prior to r5180 (SCons 2.1).""" fs = self.fs @@ -1873,7 +1873,7 @@ class FSTestCase(_tempdirTestCase): p = fs.Dir(r"\\\computername\sharename").get_abspath() assert p == r"\\computername\sharename", p - def test_rel_path(self): + def test_rel_path(self) -> None: """Test the rel_path() method""" test = self.test fs = self.fs @@ -1956,7 +1956,7 @@ class FSTestCase(_tempdirTestCase): failed = failed + 1 assert failed == 0, "%d rel_path() cases failed" % failed - def test_proxy(self): + def test_proxy(self) -> None: """Test a Node.FS object wrapped in a proxy instance""" f1 = self.fs.File('fff') @@ -1970,7 +1970,7 @@ class FSTestCase(_tempdirTestCase): class DirTestCase(_tempdirTestCase): - def test__morph(self): + def test__morph(self) -> None: """Test handling of actions when morphing an Entry into a Dir""" test = self.test e = self.fs.Entry('eee') @@ -1982,7 +1982,7 @@ class DirTestCase(_tempdirTestCase): assert 'pre' in a, a assert 'post' in a, a - def test_subclass(self): + def test_subclass(self) -> None: """Test looking up subclass of Dir nodes""" class DirSubclass(SCons.Node.FS.Dir): @@ -1991,7 +1991,7 @@ class DirTestCase(_tempdirTestCase): sd = self.fs._lookup('special_dir', None, DirSubclass, create=1) sd.must_be_same(SCons.Node.FS.Dir) - def test_get_env_scanner(self): + def test_get_env_scanner(self) -> None: """Test the Dir.get_env_scanner() method """ import SCons.Defaults @@ -1999,7 +1999,7 @@ class DirTestCase(_tempdirTestCase): s = d.get_env_scanner(Environment()) assert s is SCons.Defaults.DirEntryScanner, s - def test_get_target_scanner(self): + def test_get_target_scanner(self) -> None: """Test the Dir.get_target_scanner() method """ import SCons.Defaults @@ -2007,7 +2007,7 @@ class DirTestCase(_tempdirTestCase): s = d.get_target_scanner() assert s is SCons.Defaults.DirEntryScanner, s - def test_scan(self): + def test_scan(self) -> None: """Test scanning a directory for in-memory entries """ fs = self.fs @@ -2026,7 +2026,7 @@ class DirTestCase(_tempdirTestCase): os.path.join('ddd', 'f2'), os.path.join('ddd', 'f3')], kids - def test_get_contents(self): + def test_get_contents(self) -> None: """Test getting the contents for a directory. """ test = self.test @@ -2113,7 +2113,7 @@ class DirTestCase(_tempdirTestCase): assert self.actual_get_contents_calls == len(expected_get_contents_calls), \ self.actual_get_contents_calls - def test_implicit_re_scans(self): + def test_implicit_re_scans(self) -> None: """Test that adding entries causes a directory to be re-scanned """ @@ -2132,7 +2132,7 @@ class DirTestCase(_tempdirTestCase): assert kids == [os.path.join('ddd', 'f1'), os.path.join('ddd', 'f2')], kids - def test_entry_exists_on_disk(self): + def test_entry_exists_on_disk(self) -> None: """Test the Dir.entry_exists_on_disk() method """ test = self.test @@ -2151,7 +2151,7 @@ class DirTestCase(_tempdirTestCase): if os.path.normcase("TeSt") != os.path.normpath("TeSt") or sys.platform == "cygwin": assert d.entry_exists_on_disk('case-insensitive') - def test_rentry_exists_on_disk(self): + def test_rentry_exists_on_disk(self) -> None: """Test the Dir.rentry_exists_on_disk() method """ test = self.test @@ -2177,7 +2177,7 @@ class DirTestCase(_tempdirTestCase): if os.path.normcase("TeSt") != os.path.normpath("TeSt") or sys.platform == "cygwin": assert d.rentry_exists_on_disk('case-insensitive') - def test_srcdir_list(self): + def test_srcdir_list(self) -> None: """Test the Dir.srcdir_list() method """ src = self.fs.Dir('src') @@ -2188,7 +2188,7 @@ class DirTestCase(_tempdirTestCase): self.fs.VariantDir(bld, src, duplicate=0) self.fs.VariantDir(sub2, src, duplicate=0) - def check(result, expect): + def check(result, expect) -> None: result = list(map(str, result)) expect = list(map(os.path.normpath, expect)) assert result == expect, result @@ -2230,7 +2230,7 @@ class DirTestCase(_tempdirTestCase): s = b1_b2_b1_b2_sub.srcdir_list() check(s, ['src/b1/b2/sub']) - def test_srcdir_duplicate(self): + def test_srcdir_duplicate(self) -> None: """Test the Dir.srcdir_duplicate() method """ test = self.test @@ -2265,12 +2265,12 @@ class DirTestCase(_tempdirTestCase): assert str(n) == os.path.normpath('bld1/exists'), str(n) assert os.path.exists(test.workpath('bld1', 'exists')) - def test_srcdir_find_file(self): + def test_srcdir_find_file(self) -> None: """Test the Dir.srcdir_find_file() method """ test = self.test - def return_true(node): + def return_true(node) -> int: return 1 SCons.Node._is_derived_map[2] = return_true @@ -2296,7 +2296,7 @@ class DirTestCase(_tempdirTestCase): exists_e = src0.Entry('exists-e') exists_e._func_exists = 5 - def check(result, expect): + def check(result, expect) -> None: result = list(map(str, result)) expect = list(map(os.path.normpath, expect)) assert result == expect, result @@ -2393,7 +2393,7 @@ class DirTestCase(_tempdirTestCase): n = bld1.srcdir_find_file('on-disk-e2') check(n, ['bld1/on-disk-e2', 'bld1']) - def test_dir_on_disk(self): + def test_dir_on_disk(self) -> None: """Test the Dir.dir_on_disk() method""" self.test.subdir('sub', ['sub', 'exists']) self.test.write(['sub', 'file'], "self/file\n") @@ -2408,7 +2408,7 @@ class DirTestCase(_tempdirTestCase): r = sub.dir_on_disk('file') assert not r, r - def test_file_on_disk(self): + def test_file_on_disk(self) -> None: """Test the Dir.file_on_disk() method""" self.test.subdir('sub', ['sub', 'dir']) self.test.write(['sub', 'exists'], "self/exists\n") @@ -2425,7 +2425,7 @@ class DirTestCase(_tempdirTestCase): class EntryTestCase(_tempdirTestCase): - def test_runTest(self): + def test_runTest(self) -> None: """Test methods specific to the Entry sub-class. """ test = TestCmd(workdir='') @@ -2472,11 +2472,11 @@ class EntryTestCase(_tempdirTestCase): assert not exists, "e4n exists?" class MyCalc: - def __init__(self, val): + def __init__(self, val) -> None: self.max_drift = 0 class M: - def __init__(self, val): + def __init__(self, val) -> None: self.val = val def collect(self, args): @@ -2493,7 +2493,7 @@ class EntryTestCase(_tempdirTestCase): test.subdir('e5d') test.write('e5f', "e5f\n") - def test_Entry_Entry_lookup(self): + def test_Entry_Entry_lookup(self) -> None: """Test looking up an Entry within another Entry""" self.fs.Entry('#topdir') self.fs.Entry('#topdir/a/b/c') @@ -2501,7 +2501,7 @@ class EntryTestCase(_tempdirTestCase): class FileTestCase(_tempdirTestCase): - def test_subclass(self): + def test_subclass(self) -> None: """Test looking up subclass of File nodes""" class FileSubclass(SCons.Node.FS.File): @@ -2510,7 +2510,7 @@ class FileTestCase(_tempdirTestCase): sd = self.fs._lookup('special_file', None, FileSubclass, create=1) sd.must_be_same(SCons.Node.FS.File) - def test_Dirs(self): + def test_Dirs(self) -> None: """Test the File.Dirs() method""" fff = self.fs.File('subdir/fff') # This simulates that the SConscript file that defined @@ -2521,7 +2521,7 @@ class FileTestCase(_tempdirTestCase): dirs = fff.Dirs(['d1', 'd2']) assert dirs == [d1, d2], list(map(str, dirs)) - def test_exists(self): + def test_exists(self) -> None: """Test the File.exists() method""" fs = self.fs test = self.test @@ -2553,7 +2553,7 @@ class FileTestCase(_tempdirTestCase): assert not os.path.exists(build_f1.get_abspath()), "%s did not get removed after %s was removed" % ( build_f1, src_f1) - def test_changed(self): + def test_changed(self) -> None: """ Verify that changes between BuildInfo's list of souces, depends, and implicit dependencies do not corrupt content signature values written to .SConsign @@ -2567,7 +2567,7 @@ class FileTestCase(_tempdirTestCase): # N implicits (for example ['alpha.h', 'beta.h', 'gamma.h', '/usr/bin/g++']) class ChangedNode(SCons.Node.FS.File): - def __init__(self, name, directory=None, fs=None): + def __init__(self, name, directory=None, fs=None) -> None: super().__init__(name, directory, fs) self.name = name self.Tag('found_includes', []) @@ -2607,12 +2607,12 @@ class FileTestCase(_tempdirTestCase): class ChangedEnvironment(SCons.Environment.Base): - def __init__(self): + def __init__(self) -> None: super().__init__() self.decide_source = self._changed_timestamp_then_content class FakeNodeInfo: - def __init__(self, csig, timestamp): + def __init__(self, csig, timestamp) -> None: self.csig = csig self.timestamp = timestamp @@ -2693,7 +2693,7 @@ class FileTestCase(_tempdirTestCase): class GlobTestCase(_tempdirTestCase): - def setUp(self): + def setUp(self) -> None: _tempdirTestCase.setUp(self) fs = SCons.Node.FS.FS() @@ -2758,7 +2758,7 @@ class GlobTestCase(_tempdirTestCase): self.sub_dir3_jjj = self.sub_dir3.File('jjj') self.sub_dir3_lll = self.sub_dir3.File('lll') - def do_cases(self, cases, **kwargs): + def do_cases(self, cases, **kwargs) -> None: # First, execute all of the cases with string=True and verify # that we get the expected strings returned. We do this first @@ -2800,7 +2800,7 @@ class GlobTestCase(_tempdirTestCase): pprint.pprint(list(map(fmt, r))) self.fail() - def test_exact_match(self): + def test_exact_match(self) -> None: """Test globbing for exact Node matches""" join = os.path.join @@ -2820,7 +2820,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_subdir_matches(self): + def test_subdir_matches(self) -> None: """Test globbing for exact Node matches in subdirectories""" join = os.path.join @@ -2836,7 +2836,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_asterisk1(self): + def test_asterisk1(self) -> None: """Test globbing for simple asterisk Node matches (1)""" cases = ( ('h*', @@ -2858,7 +2858,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases, ondisk=False) - def test_asterisk2(self): + def test_asterisk2(self) -> None: """Test globbing for simple asterisk Node matches (2)""" cases = ( ('disk-b*', @@ -2882,7 +2882,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_question_mark(self): + def test_question_mark(self) -> None: """Test globbing for simple question-mark Node matches""" join = os.path.join @@ -2906,7 +2906,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_does_not_exist(self): + def test_does_not_exist(self) -> None: """Test globbing for things that don't exist""" cases = ( @@ -2917,7 +2917,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_subdir_asterisk(self): + def test_subdir_asterisk(self) -> None: """Test globbing for asterisk Node matches in subdirectories""" join = os.path.join @@ -2979,7 +2979,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_subdir_question(self): + def test_subdir_question(self) -> None: """Test globbing for question-mark Node matches in subdirectories""" join = os.path.join @@ -3003,7 +3003,7 @@ class GlobTestCase(_tempdirTestCase): self.do_cases(cases) - def test_sort(self): + def test_sort(self) -> None: """Test whether globbing sorts""" join = os.path.join # At least sometimes this should return out-of-order items @@ -3025,7 +3025,7 @@ class GlobTestCase(_tempdirTestCase): class RepositoryTestCase(_tempdirTestCase): - def setUp(self): + def setUp(self) -> None: _tempdirTestCase.setUp(self) self.test.subdir('rep1', 'rep2', 'rep3', 'work') @@ -3039,7 +3039,7 @@ class RepositoryTestCase(_tempdirTestCase): self.fs = SCons.Node.FS.FS() self.fs.Repository(self.rep1, self.rep2, self.rep3) - def test_getRepositories(self): + def test_getRepositories(self) -> None: """Test the Dir.getRepositories() method""" self.fs.Repository('foo') self.fs.Repository(os.path.join('foo', 'bar')) @@ -3060,7 +3060,7 @@ class RepositoryTestCase(_tempdirTestCase): r = [os.path.normpath(str(x)) for x in rep] assert r == expect, r - def test_get_all_rdirs(self): + def test_get_all_rdirs(self) -> None: """Test the Dir.get_all_rdirs() method""" self.fs.Repository('foo') self.fs.Repository(os.path.join('foo', 'bar')) @@ -3082,7 +3082,7 @@ class RepositoryTestCase(_tempdirTestCase): r = [os.path.normpath(str(x)) for x in rep] assert r == expect, r - def test_rentry(self): + def test_rentry(self) -> None: """Test the Base.entry() method""" return_true = lambda: 1 return_false = lambda: 0 @@ -3150,13 +3150,13 @@ class RepositoryTestCase(_tempdirTestCase): r = str(r) assert r == os.path.join(self.rep2, 'f3'), r - def test_rdir(self): + def test_rdir(self) -> None: """Test the Dir.rdir() method""" - def return_true(obj): + def return_true(obj) -> int: return 1 - def return_false(obj): + def return_false(obj) -> int: return 0 SCons.Node._exists_map[5] = return_true @@ -3206,13 +3206,13 @@ class RepositoryTestCase(_tempdirTestCase): r = e2.rdir() assert r is re2, r - def test_rfile(self): + def test_rfile(self) -> None: """Test the File.rfile() method""" - def return_true(obj): + def return_true(obj) -> int: return 1 - def return_false(obj): + def return_false(obj) -> int: return 0 SCons.Node._exists_map[5] = return_true @@ -3262,7 +3262,7 @@ class RepositoryTestCase(_tempdirTestCase): r = e2.rfile() assert r is re2, r - def test_Rfindalldirs(self): + def test_Rfindalldirs(self) -> None: """Test the Rfindalldirs() methods""" fs = self.fs test = self.test @@ -3299,7 +3299,7 @@ class RepositoryTestCase(_tempdirTestCase): r = fs.Top.Rfindalldirs(('d1', d2)) assert r == [d1, rep1_d1, rep2_d1, rep3_d1, d2], list(map(str, r)) - def test_rexists(self): + def test_rexists(self) -> None: """Test the Entry.rexists() method""" fs = self.fs test = self.test @@ -3325,7 +3325,7 @@ class RepositoryTestCase(_tempdirTestCase): f2 = fs.File(os.path.join('build', 'f2')) assert f2.rexists() - def test_FAT_timestamps(self): + def test_FAT_timestamps(self) -> None: """Test repository timestamps on FAT file systems""" fs = self.fs test = self.test @@ -3345,7 +3345,7 @@ class RepositoryTestCase(_tempdirTestCase): finally: test.unlink(["rep2", "tstamp"]) - def test_get_contents(self): + def test_get_contents(self) -> None: """Ensure get_contents() returns binary contents from Repositories""" fs = self.fs test = self.test @@ -3357,7 +3357,7 @@ class RepositoryTestCase(_tempdirTestCase): finally: test.unlink(["rep3", "contents"]) - def test_get_text_contents(self): + def test_get_text_contents(self) -> None: """Ensure get_text_contents() returns text contents from Repositories""" fs = self.fs @@ -3395,7 +3395,7 @@ class RepositoryTestCase(_tempdirTestCase): class find_fileTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Testing find_file function""" test = TestCmd(workdir='') test.write('./foo', 'Some file\n') @@ -3468,7 +3468,7 @@ class find_fileTestCase(unittest.TestCase): class StringDirTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test using a string as the second argument of File() and Dir()""" @@ -3485,7 +3485,7 @@ class StringDirTestCase(unittest.TestCase): class stored_infoTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test how we store build information""" test = TestCmd(workdir='') test.subdir('sub') @@ -3498,7 +3498,7 @@ class stored_infoTestCase(unittest.TestCase): class MySConsign: class Null: - def __init__(self): + def __init__(self) -> None: self.xyzzy = 7 def get_entry(self, name): @@ -3515,7 +3515,7 @@ class stored_infoTestCase(unittest.TestCase): class has_src_builderTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test the has_src_builder() method""" test = TestCmd(workdir='') fs = SCons.Node.FS.FS(test.workpath('')) @@ -3552,7 +3552,7 @@ class has_src_builderTestCase(unittest.TestCase): class prepareTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test the prepare() method""" class MyFile(SCons.Node.FS.File): @@ -3573,10 +3573,10 @@ class prepareTestCase(unittest.TestCase): assert exc_caught, "Should have caught a StopError." class MkdirAction(Action): - def __init__(self, dir_made): + def __init__(self, dir_made) -> None: self.dir_made = dir_made - def __call__(self, target, source, env, executor=None): + def __call__(self, target, source, env, executor=None) -> None: if executor: target = executor.get_all_targets() source = executor.get_all_sources() @@ -3603,7 +3603,7 @@ class prepareTestCase(unittest.TestCase): @unittest.skipUnless(hasattr(os, 'symlink'), "Platform doesn't support symlink") class CleanSymlinksTestCase(_tempdirTestCase): - def test_cleans_symlinks(self): + def test_cleans_symlinks(self) -> None: """Test the prepare() method will cleanup symlinks.""" test = self.test @@ -3629,7 +3629,7 @@ class CleanSymlinksTestCase(_tempdirTestCase): except FileNotFoundError: test.fail('Real file %s should not be removed'%test.workpath('foo')) - def test_cleans_dangling_symlinks(self): + def test_cleans_dangling_symlinks(self) -> None: """Test the prepare() method will cleanup dangling symlinks.""" test = self.test @@ -3660,7 +3660,7 @@ class CleanSymlinksTestCase(_tempdirTestCase): class SConstruct_dirTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test setting the SConstruct directory""" fs = SCons.Node.FS.FS() @@ -3670,7 +3670,7 @@ class SConstruct_dirTestCase(unittest.TestCase): class CacheDirTestCase(unittest.TestCase): - def test_get_cachedir_csig(self): + def test_get_cachedir_csig(self) -> None: fs = SCons.Node.FS.FS() f9 = fs.File('f9') @@ -3680,7 +3680,7 @@ class CacheDirTestCase(unittest.TestCase): class clearTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test clearing FS nodes of cached data.""" fs = SCons.Node.FS.FS() test = TestCmd(workdir='') @@ -3735,7 +3735,7 @@ class clearTestCase(unittest.TestCase): class disambiguateTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test calling the disambiguate() method.""" test = TestCmd(workdir='') @@ -3797,7 +3797,7 @@ class disambiguateTestCase(unittest.TestCase): class postprocessTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test calling the postprocess() method.""" fs = SCons.Node.FS.FS() @@ -3812,7 +3812,7 @@ class postprocessTestCase(unittest.TestCase): class SpecialAttrTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test special attributes of file nodes.""" test = TestCmd(workdir='') fs = SCons.Node.FS.FS(test.workpath('work')) @@ -3970,7 +3970,7 @@ class SpecialAttrTestCase(unittest.TestCase): class SaveStringsTestCase(unittest.TestCase): - def runTest(self): + def runTest(self) -> None: """Test caching string values of nodes.""" test = TestCmd(workdir='') @@ -3990,7 +3990,7 @@ class SaveStringsTestCase(unittest.TestCase): return [d0_f, d1_f, d0_b, d1_b] - def modify(nodes): + def modify(nodes) -> None: d0_f, d1_f, d0_b, d1_b = nodes d1_f.duplicate = 0 d1_b.duplicate = 0 @@ -4030,7 +4030,7 @@ class SaveStringsTestCase(unittest.TestCase): class AbsolutePathTestCase(unittest.TestCase): - def test_root_lookup_equivalence(self): + def test_root_lookup_equivalence(self) -> None: """Test looking up /fff vs. fff in the / directory""" test = TestCmd(workdir='') diff --git a/SCons/Node/NodeTests.py b/SCons/Node/NodeTests.py index ee4d08007..e7c9e9adc 100644 --- a/SCons/Node/NodeTests.py +++ b/SCons/Node/NodeTests.py @@ -60,10 +60,10 @@ class MyActionBase: return _actionAppend(other, self) class MyAction(MyActionBase): - def __init__(self): + def __init__(self) -> None: self.order = 0 - def __call__(self, target, source, env, executor=None): + def __call__(self, target, source, env, executor=None) -> int: global built_it, built_target, built_source, built_args, built_order if executor: target = executor.get_all_targets() @@ -80,23 +80,23 @@ class MyAction(MyActionBase): return [] class MyExecutor: - def __init__(self, env=None, targets=[], sources=[]): + def __init__(self, env=None, targets=[], sources=[]) -> None: self.env = env self.targets = targets self.sources = sources def get_build_env(self): return self.env - def get_build_scanner_path(self, scanner): + def get_build_scanner_path(self, scanner) -> str: return 'executor would call %s' % scanner - def cleanup(self): + def cleanup(self) -> None: self.cleaned_up = 1 - def scan_targets(self, scanner): + def scan_targets(self, scanner) -> None: if not scanner: return d = scanner(self.targets) for t in self.targets: t.implicit.extend(d) - def scan_sources(self, scanner): + def scan_sources(self, scanner) -> None: if not scanner: return d = scanner(self.sources) @@ -104,14 +104,14 @@ class MyExecutor: t.implicit.extend(d) class MyListAction(MyActionBase): - def __init__(self, list): + def __init__(self, list) -> None: self.list = list - def __call__(self, target, source, env): + def __call__(self, target, source, env) -> None: for A in self.list: A(target, source, env) class Environment: - def __init__(self, **kw): + def __init__(self, **kw) -> None: self._dict = {} self._dict.update(kw) def __getitem__(self, key): @@ -124,7 +124,7 @@ class Environment: d = self._dict.copy() d.update(overrides) return Environment(**d) - def _update(self, dict): + def _update(self, dict) -> None: self._dict.update(dict) def get_factory(self, factory): return factory or MyNode @@ -137,7 +137,7 @@ class Environment: return [] class Builder: - def __init__(self, env=None, is_explicit=1): + def __init__(self, env=None, is_explicit: int=1) -> None: if env is None: env = Environment() self.env = env self.overrides = {} @@ -150,7 +150,7 @@ class Builder: return [t] def get_actions(self): return [self.action] - def get_contents(self, target, source, env): + def get_contents(self, target, source, env) -> int: return 7 class NoneBuilder(Builder): @@ -159,7 +159,7 @@ class NoneBuilder(Builder): return None class ListBuilder(Builder): - def __init__(self, *nodes): + def __init__(self, *nodes) -> None: super().__init__() self.nodes = nodes def execute(self, target, source, env): @@ -171,7 +171,7 @@ class ListBuilder(Builder): self.status = Builder.execute(self, target, source, env) class FailBuilder: - def execute(self, target, source, env): + def execute(self, target, source, env) -> int: return 1 class ExceptBuilder: @@ -199,20 +199,20 @@ class MyNode(SCons.Node.Node): we expect to be overridden by real, functional Node subclasses. So simulate a real, functional Node subclass. """ - def __init__(self, name): + def __init__(self, name) -> None: super().__init__() self.name = name self.Tag('found_includes', []) - def __str__(self): + def __str__(self) -> str: return self.name def get_found_includes(self, env, scanner, target): return scanner(self) class Calculator: - def __init__(self, val): + def __init__(self, val) -> None: self.max_drift = 0 class M: - def __init__(self, val): + def __init__(self, val) -> None: self.val = val def signature(self, args): return self.val @@ -230,7 +230,7 @@ class NodeInfoBaseTestCase(unittest.TestCase): # the merge and format test (arbitrary attributes do not work). Do it with a # derived class that does provide the slots. - def test_merge(self): + def test_merge(self) -> None: """Test merging NodeInfoBase attributes""" class TestNodeInfo(SCons.Node.NodeInfoBase): @@ -250,12 +250,12 @@ class NodeInfoBaseTestCase(unittest.TestCase): assert ni1.a2 == 222, ni1.a2 assert ni1.a3 == 333, ni1.a3 - def test_update(self): + def test_update(self) -> None: """Test the update() method""" ni = SCons.Node.NodeInfoBase() ni.update(SCons.Node.Node()) - def test_format(self): + def test_format(self) -> None: """Test the NodeInfoBase.format() method""" class TestNodeInfo(SCons.Node.NodeInfoBase): @@ -278,13 +278,13 @@ class NodeInfoBaseTestCase(unittest.TestCase): class BuildInfoBaseTestCase(unittest.TestCase): - def test___init__(self): + def test___init__(self) -> None: """Test BuildInfoBase initialization""" n = SCons.Node.Node() bi = SCons.Node.BuildInfoBase() assert bi - def test_merge(self): + def test_merge(self) -> None: """Test merging BuildInfoBase attributes""" n1 = SCons.Node.Node() bi1 = SCons.Node.BuildInfoBase() @@ -305,7 +305,7 @@ class BuildInfoBaseTestCase(unittest.TestCase): class NodeTestCase(unittest.TestCase): - def test_build(self): + def test_build(self) -> None: """Test building a node """ global built_it, built_order @@ -379,7 +379,7 @@ class NodeTestCase(unittest.TestCase): assert built_args["on"] == 3, built_args assert built_args["off"] == 4, built_args - def test_get_build_scanner_path(self): + def test_get_build_scanner_path(self) -> None: """Test the get_build_scanner_path() method""" n = SCons.Node.Node() x = MyExecutor() @@ -387,7 +387,7 @@ class NodeTestCase(unittest.TestCase): p = n.get_build_scanner_path('fake_scanner') assert p == "executor would call fake_scanner", p - def test_get_executor(self): + def test_get_executor(self) -> None: """Test the get_executor() method""" n = SCons.Node.Node() @@ -414,13 +414,13 @@ class NodeTestCase(unittest.TestCase): x = n.get_executor() assert x.env == 'env2', x.env - def test_set_executor(self): + def test_set_executor(self) -> None: """Test the set_executor() method""" n = SCons.Node.Node() n.set_executor(1) assert n.executor == 1, n.executor - def test_executor_cleanup(self): + def test_executor_cleanup(self) -> None: """Test letting the executor cleanup its cache""" n = SCons.Node.Node() x = MyExecutor() @@ -428,7 +428,7 @@ class NodeTestCase(unittest.TestCase): n.executor_cleanup() assert x.cleaned_up - def test_reset_executor(self): + def test_reset_executor(self) -> None: """Test the reset_executor() method""" n = SCons.Node.Node() n.set_executor(1) @@ -436,14 +436,14 @@ class NodeTestCase(unittest.TestCase): n.reset_executor() assert not hasattr(n, 'executor'), "unexpected executor attribute" - def test_built(self): + def test_built(self) -> None: """Test the built() method""" class SubNodeInfo(SCons.Node.NodeInfoBase): __slots__ = ('updated',) - def update(self, node): + def update(self, node) -> None: self.updated = 1 class SubNode(SCons.Node.Node): - def clear(self): + def clear(self) -> None: self.cleared = 1 n = SubNode() @@ -452,19 +452,19 @@ class NodeTestCase(unittest.TestCase): assert n.cleared, n.cleared assert n.ninfo.updated, n.ninfo.cleared - def test_push_to_cache(self): + def test_push_to_cache(self) -> None: """Test the base push_to_cache() method""" n = SCons.Node.Node() r = n.push_to_cache() assert r is None, r - def test_retrieve_from_cache(self): + def test_retrieve_from_cache(self) -> None: """Test the base retrieve_from_cache() method""" n = SCons.Node.Node() r = n.retrieve_from_cache() assert r == 0, r - def test_visited(self): + def test_visited(self) -> None: """Test the base visited() method Just make sure it's there and we can call it. @@ -472,7 +472,7 @@ class NodeTestCase(unittest.TestCase): n = SCons.Node.Node() n.visited() - def test_builder_set(self): + def test_builder_set(self) -> None: """Test setting a Node's Builder """ node = SCons.Node.Node() @@ -480,7 +480,7 @@ class NodeTestCase(unittest.TestCase): node.builder_set(b) assert node.builder == b - def test_has_builder(self): + def test_has_builder(self) -> None: """Test the has_builder() method """ n1 = SCons.Node.Node() @@ -488,7 +488,7 @@ class NodeTestCase(unittest.TestCase): n1.builder_set(Builder()) assert n1.has_builder() == 1 - def test_has_explicit_builder(self): + def test_has_explicit_builder(self) -> None: """Test the has_explicit_builder() method """ n1 = SCons.Node.Node() @@ -498,7 +498,7 @@ class NodeTestCase(unittest.TestCase): n1.set_explicit(None) assert not n1.has_explicit_builder() - def test_get_builder(self): + def test_get_builder(self) -> None: """Test the get_builder() method""" n1 = SCons.Node.Node() b = n1.get_builder() @@ -511,7 +511,7 @@ class NodeTestCase(unittest.TestCase): b = n1.get_builder(999) assert b == 888, b - def test_multiple_side_effect_has_builder(self): + def test_multiple_side_effect_has_builder(self) -> None: """Test the multiple_side_effect_has_builder() method """ n1 = SCons.Node.Node() @@ -519,7 +519,7 @@ class NodeTestCase(unittest.TestCase): n1.builder_set(Builder()) assert n1.multiple_side_effect_has_builder() == 1 - def test_is_derived(self): + def test_is_derived(self) -> None: """Test the is_derived() method """ n1 = SCons.Node.Node() @@ -533,7 +533,7 @@ class NodeTestCase(unittest.TestCase): assert n2.is_derived() == 1 assert n3.is_derived() == 1 - def test_alter_targets(self): + def test_alter_targets(self) -> None: """Test the alter_targets() method """ n = SCons.Node.Node() @@ -541,13 +541,13 @@ class NodeTestCase(unittest.TestCase): assert t == [], t assert m is None, m - def test_is_up_to_date(self): + def test_is_up_to_date(self) -> None: """Test the default is_up_to_date() method """ node = SCons.Node.Node() assert node.is_up_to_date() is None - def test_children_are_up_to_date(self): + def test_children_are_up_to_date(self) -> None: """Test the children_are_up_to_date() method used by subclasses """ n1 = SCons.Node.Node() @@ -562,7 +562,7 @@ class NodeTestCase(unittest.TestCase): n1.always_build = 1 assert not n1.children_are_up_to_date(), "expected not up to date" - def test_env_set(self): + def test_env_set(self) -> None: """Test setting a Node's Environment """ node = SCons.Node.Node() @@ -570,7 +570,7 @@ class NodeTestCase(unittest.TestCase): node.env_set(e) assert node.env == e - def test_get_actions(self): + def test_get_actions(self) -> None: """Test fetching a Node's action list """ node = SCons.Node.Node() @@ -578,7 +578,7 @@ class NodeTestCase(unittest.TestCase): a = node.builder.get_actions() assert isinstance(a[0], MyAction), a[0] - def test_get_csig(self): + def test_get_csig(self) -> None: """Test generic content signature calculation """ @@ -586,7 +586,7 @@ class NodeTestCase(unittest.TestCase): __slots__ = ('csig',) try: SCons.Node.Node.NodeInfo = TestNodeInfo - def my_contents(obj): + def my_contents(obj) -> int: return 444 SCons.Node._get_contents_map[4] = my_contents node = SCons.Node.Node() @@ -596,14 +596,14 @@ class NodeTestCase(unittest.TestCase): finally: SCons.Node.Node.NodeInfo = SCons.Node.NodeInfoBase - def test_get_cachedir_csig(self): + def test_get_cachedir_csig(self) -> None: """Test content signature calculation for CacheDir """ class TestNodeInfo(SCons.Node.NodeInfoBase): __slots__ = ('csig',) try: SCons.Node.Node.NodeInfo = TestNodeInfo - def my_contents(obj): + def my_contents(obj) -> int: return 555 SCons.Node._get_contents_map[4] = my_contents node = SCons.Node.Node() @@ -613,7 +613,7 @@ class NodeTestCase(unittest.TestCase): finally: SCons.Node.Node.NodeInfo = SCons.Node.NodeInfoBase - def test_get_binfo(self): + def test_get_binfo(self) -> None: """Test fetching/creating a build information structure """ class TestNodeInfo(SCons.Node.NodeInfoBase): @@ -643,11 +643,11 @@ class NodeTestCase(unittest.TestCase): assert binfo.bimplicit == [i] assert hasattr(binfo, 'bimplicitsigs') - def test_explain(self): + def test_explain(self) -> None: """Test explaining why a Node must be rebuilt """ class testNode(SCons.Node.Node): - def __str__(self): return 'xyzzy' + def __str__(self) -> str: return 'xyzzy' node = testNode() node.exists = lambda: None # Can't do this with new-style classes (python bug #1066490) @@ -656,7 +656,7 @@ class NodeTestCase(unittest.TestCase): assert result == "building `xyzzy' because it doesn't exist\n", result class testNode2(SCons.Node.Node): - def __str__(self): return 'null_binfo' + def __str__(self) -> str: return 'null_binfo' class FS: pass node = testNode2() @@ -668,7 +668,7 @@ class NodeTestCase(unittest.TestCase): def get_null_info(): class Null_SConsignEntry: class Null_BuildInfo: - def prepare_dependencies(self): + def prepare_dependencies(self) -> None: pass binfo = Null_BuildInfo() return Null_SConsignEntry() @@ -688,20 +688,20 @@ class NodeTestCase(unittest.TestCase): # node.del_binfo() # assert not hasattr(node, 'binfo'), node - def test_store_info(self): + def test_store_info(self) -> None: """Test calling the method to store build information """ node = SCons.Node.Node() SCons.Node.store_info_map[node.store_info](node) - def test_get_stored_info(self): + def test_get_stored_info(self) -> None: """Test calling the method to fetch stored build information """ node = SCons.Node.Node() result = node.get_stored_info() assert result is None, result - def test_set_always_build(self): + def test_set_always_build(self) -> None: """Test setting a Node's always_build value """ node = SCons.Node.Node() @@ -710,7 +710,7 @@ class NodeTestCase(unittest.TestCase): node.set_always_build(3) assert node.always_build == 3 - def test_set_noclean(self): + def test_set_noclean(self) -> None: """Test setting a Node's noclean value """ node = SCons.Node.Node() @@ -723,7 +723,7 @@ class NodeTestCase(unittest.TestCase): node.set_noclean(None) assert node.noclean == 0, node.noclean - def test_set_precious(self): + def test_set_precious(self) -> None: """Test setting a Node's precious value """ node = SCons.Node.Node() @@ -732,7 +732,7 @@ class NodeTestCase(unittest.TestCase): node.set_precious(7) assert node.precious == 7 - def test_set_pseudo(self): + def test_set_pseudo(self) -> None: """Test setting a Node's pseudo value """ node = SCons.Node.Node() @@ -741,14 +741,14 @@ class NodeTestCase(unittest.TestCase): node.set_pseudo(False) assert not node.pseudo - def test_exists(self): + def test_exists(self) -> None: """Test evaluating whether a Node exists. """ node = SCons.Node.Node() e = node.exists() assert e == 1, e - def test_exists_repo(self): + def test_exists_repo(self) -> None: """Test evaluating whether a Node exists locally or in a repository. """ node = SCons.Node.Node() @@ -756,14 +756,14 @@ class NodeTestCase(unittest.TestCase): assert e == 1, e class MyNode(SCons.Node.Node): - def exists(self): + def exists(self) -> str: return 'xyz' node = MyNode() e = node.rexists() assert e == 'xyz', e - def test_prepare(self): + def test_prepare(self) -> None: """Test preparing a node to be built By extension, this also tests the missing() method. @@ -902,7 +902,7 @@ class NodeTestCase(unittest.TestCase): raise Exception("did not catch expected exception") assert node.ignore == [zero, one, two, three, four] - def test_get_found_includes(self): + def test_get_found_includes(self) -> None: """Test the default get_found_includes() method """ node = SCons.Node.Node() @@ -911,7 +911,7 @@ class NodeTestCase(unittest.TestCase): deps = node.get_found_includes(e, None, target) assert deps == [], deps - def test_get_implicit_deps(self): + def test_get_implicit_deps(self) -> None: """Test get_implicit_deps() """ node = MyNode("nnn") @@ -958,7 +958,7 @@ class NodeTestCase(unittest.TestCase): deps = node.get_implicit_deps(env, s, s.path) assert deps == [d1, d2], list(map(str, deps)) - def test_get_env_scanner(self): + def test_get_env_scanner(self) -> None: """Test fetching the environment scanner for a Node """ node = SCons.Node.Node() @@ -969,7 +969,7 @@ class NodeTestCase(unittest.TestCase): s = node.get_env_scanner(env, {'X':1}) assert s == scanner, s - def test_get_target_scanner(self): + def test_get_target_scanner(self) -> None: """Test fetching the target scanner for a Node """ s = Scanner() @@ -980,7 +980,7 @@ class NodeTestCase(unittest.TestCase): x = n.get_target_scanner() assert x is s, x - def test_get_source_scanner(self): + def test_get_source_scanner(self) -> None: """Test fetching the source scanner for a Node """ target = SCons.Node.Node() @@ -998,7 +998,7 @@ class NodeTestCase(unittest.TestCase): r.builder = self return [r] class Builder2(Builder1): - def __init__(self, scanner): + def __init__(self, scanner) -> None: self.source_scanner = scanner builder = Builder2(ts1) @@ -1020,7 +1020,7 @@ class NodeTestCase(unittest.TestCase): assert s is ts3, s - def test_scan(self): + def test_scan(self) -> None: """Test Scanner functionality """ env = Environment() @@ -1068,11 +1068,11 @@ class NodeTestCase(unittest.TestCase): SCons.Node.implicit_deps_changed = save_implicit_deps_changed SCons.Node.implicit_deps_unchanged = save_implicit_deps_unchanged - def test_scanner_key(self): + def test_scanner_key(self) -> None: """Test that a scanner_key() method exists""" assert SCons.Node.Node().scanner_key() is None - def test_children(self): + def test_children(self) -> None: """Test fetching the non-ignored "children" of a Node. """ node = SCons.Node.Node() @@ -1103,7 +1103,7 @@ class NodeTestCase(unittest.TestCase): for kid in [n2, n5, n8, n11]: assert kid not in kids, kid - def test_all_children(self): + def test_all_children(self) -> None: """Test fetching all the "children" of a Node. """ node = SCons.Node.Node() @@ -1132,7 +1132,7 @@ class NodeTestCase(unittest.TestCase): for kid in [n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12]: assert kid in kids, kid - def test_state(self): + def test_state(self) -> None: """Test setting and getting the state of a node """ node = SCons.Node.Node() @@ -1144,7 +1144,7 @@ class NodeTestCase(unittest.TestCase): assert SCons.Node.up_to_date < SCons.Node.executed assert SCons.Node.executed < SCons.Node.failed - def test_walker(self): + def test_walker(self) -> None: """Test walking a Node tree. """ @@ -1194,7 +1194,7 @@ class NodeTestCase(unittest.TestCase): n8.add_dependency([n3]) n7.add_dependency([n8]) - def cycle(node, stack): + def cycle(node, stack) -> None: global cycle_detected cycle_detected = 1 @@ -1212,20 +1212,20 @@ class NodeTestCase(unittest.TestCase): n = nw.get_next() assert nw.get_next() is None - def test_abspath(self): + def test_abspath(self) -> None: """Test the get_abspath() method.""" n = MyNode("foo") assert n.get_abspath() == str(n), n.get_abspath() - def test_for_signature(self): + def test_for_signature(self) -> None: """Test the for_signature() method.""" n = MyNode("foo") assert n.for_signature() == str(n), n.get_abspath() - def test_get_string(self): + def test_get_string(self) -> None: """Test the get_string() method.""" class TestNode(MyNode): - def __init__(self, name, sig): + def __init__(self, name, sig) -> None: super().__init__(name) self.sig = sig @@ -1236,12 +1236,12 @@ class NodeTestCase(unittest.TestCase): assert n.get_string(0) == "foo", n.get_string(0) assert n.get_string(1) == "bar", n.get_string(1) - def test_literal(self): + def test_literal(self) -> None: """Test the is_literal() function.""" n=SCons.Node.Node() assert n.is_literal() - def test_sconscripts(self): + def test_sconscripts(self) -> None: """Test the is_sconscript() function.""" # check nodes are not sconscript unless added to the list n=SCons.Node.Node() @@ -1254,7 +1254,7 @@ class NodeTestCase(unittest.TestCase): assert not n.is_sconscript() assert n2.is_sconscript() - def test_conftests(self): + def test_conftests(self) -> None: """Test the is_conftest() function.""" # check nodes are not sconscript unless added to the list n=SCons.Node.Node() @@ -1267,9 +1267,9 @@ class NodeTestCase(unittest.TestCase): assert not n.is_conftest() assert n2.is_conftest() - def test_Annotate(self): + def test_Annotate(self) -> None: """Test using an interface-specific Annotate function.""" - def my_annotate(node, self=self): + def my_annotate(node, self=self) -> None: node.Tag('annotation', self.node_string) save_Annotate = SCons.Node.Annotate @@ -1288,7 +1288,7 @@ class NodeTestCase(unittest.TestCase): finally: SCons.Node.Annotate = save_Annotate - def test_clear(self): + def test_clear(self) -> None: """Test clearing all cached state information.""" n = SCons.Node.Node() @@ -1308,25 +1308,25 @@ class NodeTestCase(unittest.TestCase): assert n.cached == 0, n.cached assert x.cleaned_up - def test_get_subst_proxy(self): + def test_get_subst_proxy(self) -> None: """Test the get_subst_proxy method.""" n = MyNode("test") assert n.get_subst_proxy() == n, n.get_subst_proxy() - def test_new_binfo(self): + def test_new_binfo(self) -> None: """Test the new_binfo() method""" n = SCons.Node.Node() result = n.new_binfo() assert isinstance(result, SCons.Node.BuildInfoBase), result - def test_get_suffix(self): + def test_get_suffix(self) -> None: """Test the base Node get_suffix() method""" n = SCons.Node.Node() s = n.get_suffix() assert s == '', s - def test_postprocess(self): + def test_postprocess(self) -> None: """Test calling the base Node postprocess() method""" n = SCons.Node.Node() n.waiting_parents = {'foo', 'bar'} @@ -1334,7 +1334,7 @@ class NodeTestCase(unittest.TestCase): n.postprocess() assert n.waiting_parents == set(), n.waiting_parents - def test_add_to_waiting_parents(self): + def test_add_to_waiting_parents(self) -> None: """Test the add_to_waiting_parents() method""" n1 = SCons.Node.Node() n2 = SCons.Node.Node() @@ -1347,7 +1347,7 @@ class NodeTestCase(unittest.TestCase): class NodeListTestCase(unittest.TestCase): - def test___str__(self): + def test___str__(self) -> None: """Test""" n1 = MyNode("n1") n2 = MyNode("n2") diff --git a/SCons/Node/Python.py b/SCons/Node/Python.py index 57416ef0b..008787a85 100644 --- a/SCons/Node/Python.py +++ b/SCons/Node/Python.py @@ -58,7 +58,7 @@ class ValueNodeInfo(SCons.Node.NodeInfoBase): return state - def __setstate__(self, state): + def __setstate__(self, state) -> None: """ Restore the attributes from a pickled state. """ @@ -87,7 +87,7 @@ class Value(SCons.Node.Node): NodeInfo = ValueNodeInfo BuildInfo = ValueBuildInfo - def __init__(self, value, built_value=None, name=None): + def __init__(self, value, built_value=None, name=None) -> None: super().__init__() self.value = value self.changed_since_last_build = 6 @@ -105,25 +105,25 @@ class Value(SCons.Node.Node): def str_for_display(self): return repr(self.value) - def __str__(self): + def __str__(self) -> str: return str(self.value) - def make_ready(self): + def make_ready(self) -> None: self.get_csig() - def build(self, **kw): + def build(self, **kw) -> None: if not hasattr(self, 'built_value'): SCons.Node.Node.build(self, **kw) is_up_to_date = SCons.Node.Node.children_are_up_to_date - def is_under(self, dir): + def is_under(self, dir) -> int: # Make Value nodes get built regardless of # what directory scons was run from. Value nodes # are outside the filesystem: return 1 - def write(self, built_value): + def write(self, built_value) -> None: """Set the value of the node.""" self.built_value = built_value diff --git a/SCons/Node/PythonTests.py b/SCons/Node/PythonTests.py index b6a3f7930..2be2b292f 100644 --- a/SCons/Node/PythonTests.py +++ b/SCons/Node/PythonTests.py @@ -28,7 +28,7 @@ import SCons.Node.Python class ValueTestCase(unittest.TestCase): - def test_Value(self): + def test_Value(self) -> None: """Test creating a Value() object """ v1 = SCons.Node.Python.Value('a') @@ -45,11 +45,11 @@ class ValueTestCase(unittest.TestCase): v3 = SCons.Node.Python.Value('c', 'cb') assert v3.built_value == 'cb' - def test_build(self): + def test_build(self) -> None: """Test "building" a Value Node """ class fake_executor: - def __call__(self, node): + def __call__(self, node) -> None: node.write('faked') v1 = SCons.Node.Python.Value('b', 'built') @@ -68,14 +68,14 @@ class ValueTestCase(unittest.TestCase): assert v3.name == 'name', v3.name assert v3.built_value == 'faked', v3.built_value - def test_read(self): + def test_read(self) -> None: """Test the Value.read() method """ v1 = SCons.Node.Python.Value('a') x = v1.read() assert x == 'a', x - def test_write(self): + def test_write(self) -> None: """Test the Value.write() method """ v1 = SCons.Node.Python.Value('a') @@ -86,7 +86,7 @@ class ValueTestCase(unittest.TestCase): assert v1.value == 'a', v1.value assert v1.built_value == 'new', v1.built_value - def test_get_csig(self): + def test_get_csig(self) -> None: """Test calculating the content signature of a Value() object """ v1 = SCons.Node.Python.Value('aaa') @@ -106,21 +106,21 @@ class ValueTestCase(unittest.TestCase): class ValueNodeInfoTestCase(unittest.TestCase): - def test___init__(self): + def test___init__(self) -> None: """Test ValueNodeInfo initialization""" vvv = SCons.Node.Python.Value('vvv') ni = SCons.Node.Python.ValueNodeInfo() class ValueBuildInfoTestCase(unittest.TestCase): - def test___init__(self): + def test___init__(self) -> None: """Test ValueBuildInfo initialization""" vvv = SCons.Node.Python.Value('vvv') bi = SCons.Node.Python.ValueBuildInfo() class ValueChildTestCase(unittest.TestCase): - def test___init__(self): + def test___init__(self) -> None: """Test support for a Value() being an implicit dependency of a Node""" value = SCons.Node.Python.Value('v') node = SCons.Node.Node() @@ -132,7 +132,7 @@ class ValueChildTestCase(unittest.TestCase): class ValueMemoTestCase(unittest.TestCase): - def test_memo(self): + def test_memo(self) -> None: """Test memoization""" # First confirm that ValueWithMemo does memoization. value1 = SCons.Node.Python.ValueWithMemo('vvv') @@ -145,13 +145,13 @@ class ValueMemoTestCase(unittest.TestCase): value3 = ni.str_to_node('vvv') assert value1 is value3 - def test_built_value(self): + def test_built_value(self) -> None: """Confirm that built values are not memoized.""" v1 = SCons.Node.Python.ValueWithMemo('c', 'ca') v2 = SCons.Node.Python.ValueWithMemo('c', 'ca') assert v1 is not v2 - def test_non_primitive_values(self): + def test_non_primitive_values(self) -> None: """Confirm that non-primitive values are not memoized.""" d = {'a': 1} v1 = SCons.Node.Python.ValueWithMemo(d) @@ -163,7 +163,7 @@ class ValueMemoTestCase(unittest.TestCase): v4 = SCons.Node.Python.ValueWithMemo(a) assert v3 is not v4 - def test_value_set_name(self): + def test_value_set_name(self) -> None: """ Confirm setting name and caching takes the name into account """ v1 = SCons.Node.Python.ValueWithMemo(b'\x00\x0F', name='name') diff --git a/SCons/Node/__init__.py b/SCons/Node/__init__.py index bb0986859..81ff2ffc5 100644 --- a/SCons/Node/__init__.py +++ b/SCons/Node/__init__.py @@ -94,7 +94,7 @@ implicit_deps_changed = 0 # A variable that can be set to an interface-specific function be called # to annotate a Node with information about its creation. -def do_nothing_node(node): pass +def do_nothing_node(node) -> None: pass Annotate = do_nothing_node @@ -121,10 +121,10 @@ _is_derived_map = {0 : is_derived_none, def exists_none(node): raise NotImplementedError -def exists_always(node): +def exists_always(node) -> int: return 1 -def exists_base(node): +def exists_base(node) -> bool: return node.stat() is not None def exists_entry(node): @@ -326,10 +326,10 @@ do_store_info = True # First, the single info functions # -def store_info_pass(node): +def store_info_pass(node) -> None: pass -def store_info_file(node): +def store_info_file(node) -> None: # Merge our build information into the already-stored entry. # This accommodates "chained builds" where a file that's a target # in one build (SConstruct file) is a source in a different build. @@ -353,7 +353,7 @@ class NodeInfoBase: __slots__ = ('__weakref__',) current_version_id = 2 - def update(self, node): + def update(self, node) -> None: try: field_list = self.field_list except AttributeError: @@ -370,10 +370,10 @@ class NodeInfoBase: else: setattr(self, f, func()) - def convert(self, node, val): + def convert(self, node, val) -> None: pass - def merge(self, other): + def merge(self, other) -> None: """ Merge the fields of another object into this object. Already existing information is overwritten by the other instance's data. @@ -383,7 +383,7 @@ class NodeInfoBase: state = other.__getstate__() self.__setstate__(state) - def format(self, field_list=None, names=0): + def format(self, field_list=None, names: int=0): if field_list is None: try: field_list = self.field_list @@ -426,7 +426,7 @@ class NodeInfoBase: pass return state - def __setstate__(self, state): + def __setstate__(self, state) -> None: """ Restore the attributes from a pickled state. The version is discarded. """ @@ -452,7 +452,7 @@ class BuildInfoBase: "bsources", "bdepends", "bact", "bimplicit", "__weakref__") current_version_id = 2 - def __init__(self): + def __init__(self) -> None: # Create an object attribute from the class attribute so it ends up # in the pickled data in the .sconsign file. self.bsourcesigs = [] @@ -460,7 +460,7 @@ class BuildInfoBase: self.bimplicitsigs = [] self.bactsig = None - def merge(self, other): + def merge(self, other) -> None: """ Merge the fields of another object into this object. Already existing information is overwritten by the other instance's data. @@ -490,7 +490,7 @@ class BuildInfoBase: pass return state - def __setstate__(self, state): + def __setstate__(self, state) -> None: """ Restore the attributes from a pickled state. """ @@ -553,7 +553,7 @@ class Node(object, metaclass=NoSlotsPyPy): __slots__ = ('shared', '__dict__') - def __init__(self): + def __init__(self) -> None: if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.Node') # Note that we no longer explicitly initialize a self.builder # attribute to None here. That's because the self.builder @@ -615,7 +615,7 @@ class Node(object, metaclass=NoSlotsPyPy): def disambiguate(self, must_exist=None): return self - def get_suffix(self): + def get_suffix(self) -> str: return '' @SCons.Memoize.CountMethodCall @@ -634,11 +634,11 @@ class Node(object, metaclass=NoSlotsPyPy): """Fetch the appropriate scanner path for this node.""" return self.get_executor().get_build_scanner_path(scanner) - def set_executor(self, executor): + def set_executor(self, executor) -> None: """Set the action executor for this node.""" self.executor = executor - def get_executor(self, create=1): + def get_executor(self, create: int=1): """Fetch the action executor for this node. Create one if there isn't already one, and requested to do so.""" try: @@ -659,7 +659,7 @@ class Node(object, metaclass=NoSlotsPyPy): self.executor = executor return executor - def executor_cleanup(self): + def executor_cleanup(self) -> None: """Let the executor clean up any cached information.""" try: executor = self.get_executor(create=None) @@ -669,19 +669,19 @@ class Node(object, metaclass=NoSlotsPyPy): if executor is not None: executor.cleanup() - def reset_executor(self): + def reset_executor(self) -> None: """Remove cached executor; forces recompute when needed.""" try: delattr(self, 'executor') except AttributeError: pass - def push_to_cache(self): + def push_to_cache(self) -> None: """Try to push a node into a cache """ pass - def retrieve_from_cache(self): + def retrieve_from_cache(self) -> int: """Try to retrieve the node's content from a cache This method is called from multiple threads in a parallel build, @@ -696,7 +696,7 @@ class Node(object, metaclass=NoSlotsPyPy): # Taskmaster interface subsystem # - def make_ready(self): + def make_ready(self) -> None: """Get a Node ready for evaluation. This is called before the Taskmaster decides if the Node is @@ -795,7 +795,7 @@ class Node(object, metaclass=NoSlotsPyPy): "Cannot find target " + str(self) + " after building") self.ninfo.update(self) - def visited(self): + def visited(self) -> None: """Called just after this node has been visited (with or without a build).""" try: @@ -808,7 +808,7 @@ class Node(object, metaclass=NoSlotsPyPy): self.ninfo.update(self) SCons.Node.store_info_map[self.store_info](self) - def release_target_info(self): + def release_target_info(self) -> None: """Called just after this node has been marked up-to-date or was built completely. @@ -825,10 +825,10 @@ class Node(object, metaclass=NoSlotsPyPy): """ pass - def add_to_waiting_s_e(self, node): + def add_to_waiting_s_e(self, node) -> None: self.waiting_s_e.add(node) - def add_to_waiting_parents(self, node): + def add_to_waiting_parents(self, node) -> int: """ Returns the number of nodes added to our waiting parents list: 1 if we add a unique waiting parent, 0 if not. (Note that the @@ -842,13 +842,13 @@ class Node(object, metaclass=NoSlotsPyPy): wp.add(node) return 1 - def postprocess(self): + def postprocess(self) -> None: """Clean up anything we don't need to hang onto after we've been built.""" self.executor_cleanup() self.waiting_parents = set() - def clear(self): + def clear(self) -> None: """Completely clear a Node of all its cached state (so that it can be re-evaluated by interfaces that do continuous integration builds). @@ -868,17 +868,17 @@ class Node(object, metaclass=NoSlotsPyPy): self.cached = 0 self.includes = None - def clear_memoized_values(self): + def clear_memoized_values(self) -> None: self._memo = {} - def builder_set(self, builder): + def builder_set(self, builder) -> None: self.builder = builder try: del self.executor except AttributeError: pass - def has_builder(self): + def has_builder(self) -> bool: """Return whether this Node has a builder or not. In Boolean tests, this turns out to be a *lot* more efficient @@ -897,7 +897,7 @@ class Node(object, metaclass=NoSlotsPyPy): b = self.builder = None return b is not None - def set_explicit(self, is_explicit): + def set_explicit(self, is_explicit) -> None: self.is_explicit = is_explicit def has_explicit_builder(self): @@ -934,11 +934,11 @@ class Node(object, metaclass=NoSlotsPyPy): """ return _is_derived_map[self._func_is_derived](self) - def is_sconscript(self): + def is_sconscript(self) -> bool: """ Returns true if this node is an sconscript """ return self in SConscriptNodes - def is_conftest(self): + def is_conftest(self) -> bool: """ Returns true if this node is an conftest node""" try: self.attributes.conftest_node @@ -1050,14 +1050,14 @@ class Node(object, metaclass=NoSlotsPyPy): scanner = scanner.select(node) return scanner - def add_to_implicit(self, deps): + def add_to_implicit(self, deps) -> None: if not hasattr(self, 'implicit') or self.implicit is None: self.implicit = [] self.implicit_set = set() self._children_reset() self._add_child(self.implicit, self.implicit_set, deps) - def scan(self): + def scan(self) -> None: """Scan this node's dependents for implicit dependencies.""" # Don't bother scanning non-derived files, because we don't # care what their dependencies are. @@ -1119,7 +1119,7 @@ class Node(object, metaclass=NoSlotsPyPy): """ return scanner.select(self) - def env_set(self, env, safe=0): + def env_set(self, env, safe: int=0) -> None: if safe and self.env: return self.env = env @@ -1197,7 +1197,7 @@ class Node(object, metaclass=NoSlotsPyPy): return binfo - def del_binfo(self): + def del_binfo(self) -> None: """Delete the build info from this node.""" try: delattr(self, 'binfo') @@ -1226,27 +1226,27 @@ class Node(object, metaclass=NoSlotsPyPy): # # - def set_precious(self, precious = 1): + def set_precious(self, precious: int = 1) -> None: """Set the Node's precious value.""" self.precious = precious - def set_pseudo(self, pseudo = True): + def set_pseudo(self, pseudo: bool = True) -> None: """Set the Node's precious value.""" self.pseudo = pseudo - def set_noclean(self, noclean = 1): + def set_noclean(self, noclean: int = 1) -> None: """Set the Node's noclean value.""" # Make sure noclean is an integer so the --debug=stree # output in Util.py can use it as an index. self.noclean = noclean and 1 or 0 - def set_nocache(self, nocache = 1): + def set_nocache(self, nocache: int = 1) -> None: """Set the Node's nocache value.""" # Make sure nocache is an integer so the --debug=stree # output in Util.py can use it as an index. self.nocache = nocache and 1 or 0 - def set_always_build(self, always_build = 1): + def set_always_build(self, always_build: int = 1) -> None: """Set the Node's always_build value.""" self.always_build = always_build @@ -1263,7 +1263,7 @@ class Node(object, metaclass=NoSlotsPyPy): """Fetch the contents of the entry.""" return _get_contents_map[self._func_get_contents](self) - def missing(self): + def missing(self) -> bool: return not self.is_derived() and \ not self.linked and \ not self.rexists() @@ -1284,7 +1284,7 @@ class Node(object, metaclass=NoSlotsPyPy): s = str(e) raise SCons.Errors.UserError("attempted to add a non-Node dependency to %s:\n\t%s is a %s, not a Node" % (str(self), s, type(e))) - def add_prerequisite(self, prerequisite): + def add_prerequisite(self, prerequisite) -> None: """Adds prerequisites""" if self.prerequisites is None: self.prerequisites = UniqueList() @@ -1317,7 +1317,7 @@ class Node(object, metaclass=NoSlotsPyPy): s = str(e) raise SCons.Errors.UserError("attempted to add a non-Node as source of %s:\n\t%s is a %s, not a Node" % (str(self), s, type(e))) - def _add_child(self, collection, set, child): + def _add_child(self, collection, set, child) -> None: """Adds 'child' to 'collection', first checking 'set' to see if it's already present.""" added = None @@ -1329,16 +1329,16 @@ class Node(object, metaclass=NoSlotsPyPy): if added: self._children_reset() - def set_specific_source(self, source): + def set_specific_source(self, source) -> None: self.add_source(source) self._specific_sources = True - def add_wkid(self, wkid): + def add_wkid(self, wkid) -> None: """Add a node to the list of kids waiting to be evaluated""" if self.wkids is not None: self.wkids.append(wkid) - def _children_reset(self): + def _children_reset(self) -> None: self.clear_memoized_values() # We need to let the Executor clear out any calculated # build info that it's cached so we can re-calculate it. @@ -1381,7 +1381,7 @@ class Node(object, metaclass=NoSlotsPyPy): self._memo['_children_get'] = children return children - def all_children(self, scan=1): + def all_children(self, scan: int=1): """Return a list of all the node's direct children.""" if scan: self.scan() @@ -1405,14 +1405,14 @@ class Node(object, metaclass=NoSlotsPyPy): # internally anyway...) return list(chain.from_iterable([_f for _f in [self.sources, self.depends, self.implicit] if _f])) - def children(self, scan=1): + def children(self, scan: int=1): """Return a list of the node's direct children, minus those that are ignored by this node.""" if scan: self.scan() return self._children_get() - def set_state(self, state): + def set_state(self, state) -> None: self.state = state def get_state(self): @@ -1425,7 +1425,7 @@ class Node(object, metaclass=NoSlotsPyPy): env = SCons.Defaults.DefaultEnvironment() return env - def Decider(self, function): + def Decider(self, function) -> None: foundkey = None for k, v in _decider_map.items(): if v == function: @@ -1436,7 +1436,7 @@ class Node(object, metaclass=NoSlotsPyPy): _decider_map[foundkey] = function self.changed_since_last_build = foundkey - def Tag(self, key, value): + def Tag(self, key, value) -> None: """ Add a user-defined tag. """ if not self._tags: self._tags = {} @@ -1448,7 +1448,7 @@ class Node(object, metaclass=NoSlotsPyPy): return None return self._tags.get(key, None) - def changed(self, node=None, allowcache=False): + def changed(self, node=None, allowcache: bool=False): """ Returns if the node is up-to-date with respect to the BuildInfo stored last time it was built. The default behavior is to compare @@ -1534,7 +1534,7 @@ class Node(object, metaclass=NoSlotsPyPy): state = s return (state == 0 or state == SCons.Node.up_to_date) - def is_literal(self): + def is_literal(self) -> int: """Always pass the string representation of a Node to the command interpreter literally.""" return 1 @@ -1710,12 +1710,12 @@ class Node(object, metaclass=NoSlotsPyPy): return ( ' '*11).join(lines) class NodeList(collections.UserList): - def __str__(self): + def __str__(self) -> str: return str(list(map(str, self.data))) def get_children(node, parent): return node.children() -def ignore_cycle(node, stack): pass -def do_nothing(node, parent): pass +def ignore_cycle(node, stack) -> None: pass +def do_nothing(node, parent) -> None: pass class Walker: """An iterator for walking a Node tree. @@ -1732,7 +1732,7 @@ class Walker: """ def __init__(self, node, kids_func=get_children, cycle_func=ignore_cycle, - eval_func=do_nothing): + eval_func=do_nothing) -> None: self.kids_func = kids_func self.cycle_func = cycle_func self.eval_func = eval_func @@ -1771,7 +1771,7 @@ class Walker: return node return None - def is_done(self): + def is_done(self) -> bool: return not self.stack |