summaryrefslogtreecommitdiff
path: root/SCons/Scanner
diff options
context:
space:
mode:
Diffstat (limited to 'SCons/Scanner')
-rw-r--r--SCons/Scanner/C.py12
-rw-r--r--SCons/Scanner/CTests.py44
-rw-r--r--SCons/Scanner/D.py2
-rw-r--r--SCons/Scanner/DTests.py28
-rw-r--r--SCons/Scanner/DirTests.py8
-rw-r--r--SCons/Scanner/Fortran.py4
-rw-r--r--SCons/Scanner/FortranTests.py44
-rw-r--r--SCons/Scanner/IDLTests.py36
-rw-r--r--SCons/Scanner/Java.py2
-rw-r--r--SCons/Scanner/JavaTests.py36
-rw-r--r--SCons/Scanner/LaTeX.py10
-rw-r--r--SCons/Scanner/LaTeXTests.py12
-rw-r--r--SCons/Scanner/ProgTests.py32
-rw-r--r--SCons/Scanner/PythonTests.py38
-rw-r--r--SCons/Scanner/RCTests.py12
-rw-r--r--SCons/Scanner/ScannerTests.py92
-rw-r--r--SCons/Scanner/__init__.py20
17 files changed, 216 insertions, 216 deletions
diff --git a/SCons/Scanner/C.py b/SCons/Scanner/C.py
index 31ab7e62e..5fa1bbb9f 100644
--- a/SCons/Scanner/C.py
+++ b/SCons/Scanner/C.py
@@ -41,11 +41,11 @@ class SConsCPPScanner(SCons.cpp.PreProcessor):
by Nodes, not strings; 2) we can keep track of the files that are
missing.
"""
- def __init__(self, *args, **kwargs):
+ def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.missing = []
- def initialize_result(self, fname):
+ def initialize_result(self, fname) -> None:
self.result = SCons.Util.UniqueList([fname])
def finalize_result(self, fname):
@@ -131,7 +131,7 @@ class SConsCPPScannerWrapper:
evaluation of #if/#ifdef/#else/#elif lines.
"""
- def __init__(self, name, variable):
+ def __init__(self, name, variable) -> None:
self.name = name
self.path = FindPathDirs(variable)
@@ -185,12 +185,12 @@ class SConsCPPConditionalScanner(SCons.cpp.PreProcessor):
missing.
"""
- def __init__(self, *args, **kwargs):
+ def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.missing = []
self._known_paths = []
- def initialize_result(self, fname):
+ def initialize_result(self, fname) -> None:
self.result = SCons.Util.UniqueList([fname])
def find_include_file(self, t):
@@ -228,7 +228,7 @@ class SConsCPPConditionalScannerWrapper:
evaluation of #if/#ifdef/#else/#elif lines.
"""
- def __init__(self, name, variable):
+ def __init__(self, name, variable) -> None:
self.name = name
self.path = FindPathDirs(variable)
diff --git a/SCons/Scanner/CTests.py b/SCons/Scanner/CTests.py
index 0f62198d6..6860a10ce 100644
--- a/SCons/Scanner/CTests.py
+++ b/SCons/Scanner/CTests.py
@@ -201,7 +201,7 @@ test.write("f5b.h", "\n")
# define some helpers:
class DummyEnvironment(collections.UserDict):
- def __init__(self, **kwargs):
+ def __init__(self, **kwargs) -> None:
super().__init__()
self.data.update(kwargs)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -241,7 +241,7 @@ if os.path.normcase('foo') == os.path.normcase('FOO'):
else:
my_normpath = os.path.normpath
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
global my_normpath
scanned = list(map(my_normpath, list(map(str, deps))))
expect = list(map(my_normpath, headers))
@@ -250,7 +250,7 @@ def deps_match(self, deps, headers):
# define some tests:
class CScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find local files with no CPPPATH"""
env = DummyEnvironment(CPPPATH=[])
s = SCons.Scanner.C.CScanner()
@@ -260,7 +260,7 @@ class CScannerTestCase1(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find a file in a CPPPATH directory"""
env = DummyEnvironment(CPPPATH=[test.workpath("d1")])
s = SCons.Scanner.C.CScanner()
@@ -270,7 +270,7 @@ class CScannerTestCase2(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in explicit subdirectories, ignore missing file"""
env = DummyEnvironment(CPPPATH=[test.workpath("d1")])
s = SCons.Scanner.C.CScanner()
@@ -280,7 +280,7 @@ class CScannerTestCase3(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase4(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in explicit subdirectories"""
env = DummyEnvironment(CPPPATH=[test.workpath("d1"), test.workpath("d1/d2")])
s = SCons.Scanner.C.CScanner()
@@ -290,7 +290,7 @@ class CScannerTestCase4(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase5(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Make sure files in repositories will get scanned"""
env = DummyEnvironment(CPPPATH=[])
s = SCons.Scanner.C.CScanner()
@@ -315,7 +315,7 @@ class CScannerTestCase5(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase6(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find a same-named file in different directories when CPPPATH changes"""
env1 = DummyEnvironment(CPPPATH=[test.workpath("d1")])
env2 = DummyEnvironment(CPPPATH=[test.workpath("d1/d2")])
@@ -330,7 +330,7 @@ class CScannerTestCase6(unittest.TestCase):
deps_match(self, deps2, headers2)
class CScannerTestCase8(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in a subdirectory relative to the current directory"""
env = DummyEnvironment(CPPPATH=["include"])
s = SCons.Scanner.C.CScanner()
@@ -347,11 +347,11 @@ class CScannerTestCase8(unittest.TestCase):
deps_match(self, deps2, headers2)
class CScannerTestCase9(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Generate a warning when we can't find a #included file"""
SCons.Warnings.enableWarningClass(SCons.Warnings.DependencyWarning)
class TestOut:
- def __call__(self, x):
+ def __call__(self, x) -> None:
self.out = x
to = TestOut()
@@ -372,7 +372,7 @@ class CScannerTestCase9(unittest.TestCase):
test.unlink('fa.h')
class CScannerTestCase10(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in the local directory when the scanned file is elsewhere"""
fs = SCons.Node.FS.FS(test.workpath(''))
fs.chdir(fs.Dir('include'))
@@ -387,7 +387,7 @@ class CScannerTestCase10(unittest.TestCase):
test.unlink('include/fa.cpp')
class CScannerTestCase11(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Handle dependencies on a derived .h file in a non-existent directory"""
os.chdir(test.workpath('work'))
fs = SCons.Node.FS.FS(test.workpath('work'))
@@ -407,7 +407,7 @@ class CScannerTestCase11(unittest.TestCase):
os.chdir(test.workpath(''))
class CScannerTestCase12(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in VariantDir() directories"""
os.chdir(test.workpath('work'))
fs = SCons.Node.FS.FS(test.workpath('work'))
@@ -429,7 +429,7 @@ class CScannerTestCase12(unittest.TestCase):
os.chdir(test.workpath(''))
class CScannerTestCase13(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in directories named in a substituted environment variable"""
class SubstEnvironment(DummyEnvironment):
def subst(self, arg, target=None, source=None, conv=None, test=test):
@@ -445,7 +445,7 @@ class CScannerTestCase13(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase14(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files when there's no space between "#include" and the name"""
env = DummyEnvironment(CPPPATH=[])
s = SCons.Scanner.C.CScanner()
@@ -455,7 +455,7 @@ class CScannerTestCase14(unittest.TestCase):
deps_match(self, deps, headers)
class CScannerTestCase15(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Verify scanner initialization with the suffixes in $CPPSUFFIXES"""
suffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
".h", ".H", ".hxx", ".hpp", ".hh",
@@ -468,7 +468,7 @@ class CScannerTestCase15(unittest.TestCase):
class CConditionalScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find local files with no CPPPATH"""
env = DummyEnvironment(CPPPATH=[])
s = SCons.Scanner.C.CConditionalScanner()
@@ -479,7 +479,7 @@ class CConditionalScannerTestCase1(unittest.TestCase):
class CConditionalScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find local files with no CPPPATH based on #ifdef"""
env = DummyEnvironment(CPPPATH=[], CPPDEFINES=["INCLUDE_F2"])
s = SCons.Scanner.C.CConditionalScanner()
@@ -490,7 +490,7 @@ class CConditionalScannerTestCase2(unittest.TestCase):
class CConditionalScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Find files in explicit subdirectories, ignore missing file"""
env = DummyEnvironment(
CPPPATH=[test.workpath("d1")],
@@ -513,7 +513,7 @@ class CConditionalScannerTestCase3(unittest.TestCase):
class CConditionalScannerTestCase4(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Test that dependency is detected if #include uses a macro."""
with self.subTest("macro defined in the source file"):
@@ -533,7 +533,7 @@ class CConditionalScannerTestCase4(unittest.TestCase):
class dictify_CPPDEFINESTestCase(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""Make sure CPPDEFINES converts correctly.
Various types and combinations of types could fail if not handled
diff --git a/SCons/Scanner/D.py b/SCons/Scanner/D.py
index c9b1e36d9..f4366dfc5 100644
--- a/SCons/Scanner/D.py
+++ b/SCons/Scanner/D.py
@@ -35,7 +35,7 @@ def DScanner():
return ds
class D(Classic):
- def __init__(self):
+ def __init__(self) -> None:
super().__init__(
name="DScanner",
suffixes='$DSUFFIXES',
diff --git a/SCons/Scanner/DTests.py b/SCons/Scanner/DTests.py
index 25ccca330..358014d3e 100644
--- a/SCons/Scanner/DTests.py
+++ b/SCons/Scanner/DTests.py
@@ -33,7 +33,7 @@ test = TestCmd.TestCmd(workdir = '')
class DummyEnvironment(collections.UserDict):
- def __init__(self, **kwargs):
+ def __init__(self, **kwargs) -> None:
super().__init__()
self.data.update(kwargs)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -73,7 +73,7 @@ if os.path.normcase('foo') == os.path.normcase('FOO'):
else:
my_normpath = os.path.normpath
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
global my_normpath
scanned = list(map(my_normpath, list(map(str, deps))))
expect = list(map(my_normpath, headers))
@@ -222,44 +222,44 @@ void main() {}
""")
class DScannerTestCase(unittest.TestCase):
- def helper(self, filename, headers):
+ def helper(self, filename, headers) -> None:
env = DummyEnvironment()
s = SCons.Scanner.D.DScanner()
path = s.path(env)
deps = s(env.File(filename), env, path)
deps_match(self, deps, headers)
- def test_BasicImport(self):
+ def test_BasicImport(self) -> None:
self.helper('basic.d', ['A.d'])
- def test_StaticImport(self):
+ def test_StaticImport(self) -> None:
self.helper('static.d', ['A.d'])
- def test_publicImport(self):
+ def test_publicImport(self) -> None:
self.helper('public.d', ['A.d'])
- def test_RenameImport(self):
+ def test_RenameImport(self) -> None:
self.helper('rename.d', ['A.d'])
- def test_SelectiveImport(self):
+ def test_SelectiveImport(self) -> None:
self.helper('selective.d', ['A.d'])
- def test_RenameAndSelectiveImport(self):
+ def test_RenameAndSelectiveImport(self) -> None:
self.helper('renameAndSelective.d', ['A.d'])
- def test_ScopedImport(self):
+ def test_ScopedImport(self) -> None:
self.helper('scoped.d', ['A.d'])
- def test_CombinatorialImport(self):
+ def test_CombinatorialImport(self) -> None:
self.helper('combinatorial.d', ['A.d', 'B.d', 'C.d', 'D.d'])
- def test_SubdirsImport(self):
+ def test_SubdirsImport(self) -> None:
self.helper('subdirs.d', [os.path.join('X','X','X.d'), os.path.join('X','Y.d'), os.path.join('X','Z.d')])
- def test_MultipleImport(self):
+ def test_MultipleImport(self) -> None:
self.helper('multiple.d', ['A.d', 'B.d', 'C.d', os.path.join('X','Y.d')])
- def test_MultilineImport(self):
+ def test_MultilineImport(self) -> None:
self.helper('multiline.d', ['A.d'])
if __name__ == "__main__":
diff --git a/SCons/Scanner/DirTests.py b/SCons/Scanner/DirTests.py
index 1c46c6c3f..32355f352 100644
--- a/SCons/Scanner/DirTests.py
+++ b/SCons/Scanner/DirTests.py
@@ -41,7 +41,7 @@ from SCons.SConsign import current_sconsign_filename
# return self.fs.Entry(name)
class DummyEnvironment:
- def __init__(self, root):
+ def __init__(self, root) -> None:
self.fs = SCons.Node.FS.FS(root)
def Dir(self, name):
return self.fs.Dir(name)
@@ -53,7 +53,7 @@ class DummyEnvironment:
return factory or self.fs.Entry
class DirScannerTestBase(unittest.TestCase):
- def setUp(self):
+ def setUp(self) -> None:
self.test = TestCmd.TestCmd(workdir = '')
self.test.subdir('dir', ['dir', 'sub'])
@@ -79,7 +79,7 @@ class DirScannerTestBase(unittest.TestCase):
self.test.write(['dir', 'sub', '{}.pag'.format(sconsign)], "dir/{}.pag\n".format(sconsign))
class DirScannerTestCase(DirScannerTestBase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(self.test.workpath())
s = SCons.Scanner.Dir.DirScanner()
@@ -102,7 +102,7 @@ class DirScannerTestCase(DirScannerTestBase):
assert sss == expect, "Found {}, expected {}".format(sss, expect)
class DirEntryScannerTestCase(DirScannerTestBase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(self.test.workpath())
s = SCons.Scanner.Dir.DirEntryScanner()
diff --git a/SCons/Scanner/Fortran.py b/SCons/Scanner/Fortran.py
index 9cf5b220d..14df5fc96 100644
--- a/SCons/Scanner/Fortran.py
+++ b/SCons/Scanner/Fortran.py
@@ -48,7 +48,7 @@ class F90Scanner(Classic):
"""
def __init__(self, name, suffixes, path_variable,
- use_regex, incl_regex, def_regex, *args, **kwargs):
+ use_regex, incl_regex, def_regex, *args, **kwargs) -> None:
self.cre_use = re.compile(use_regex, re.M)
self.cre_incl = re.compile(incl_regex, re.M)
@@ -119,7 +119,7 @@ class F90Scanner(Classic):
return [pair[1] for pair in sorted(nodes)]
-def FortranScan(path_variable="FORTRANPATH"):
+def FortranScan(path_variable: str="FORTRANPATH"):
"""Return a prototype Scanner instance for scanning source files
for Fortran USE & INCLUDE statements"""
diff --git a/SCons/Scanner/FortranTests.py b/SCons/Scanner/FortranTests.py
index 729e91a18..d2f608906 100644
--- a/SCons/Scanner/FortranTests.py
+++ b/SCons/Scanner/FortranTests.py
@@ -202,7 +202,7 @@ test.write(['modules', 'use.mod'], "\n")
# define some helpers:
class DummyEnvironment:
- def __init__(self, listCppPath):
+ def __init__(self, listCppPath) -> None:
self.path = listCppPath
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -214,16 +214,16 @@ class DummyEnvironment:
else:
raise KeyError("Dummy environment only has FORTRANPATH attribute.")
- def __contains__(self, key):
+ def __contains__(self, key) -> bool:
return key in self.Dictionary()
def __getitem__(self, key):
return self.Dictionary()[key]
- def __setitem__(self, key, value):
+ def __setitem__(self, key, value) -> None:
self.Dictionary()[key] = value
- def __delitem__(self, key):
+ def __delitem__(self, key) -> None:
del self.Dictionary()[key]
def subst(self, arg, target=None, source=None, conv=None):
@@ -249,7 +249,7 @@ class DummyEnvironment:
return self.fs.File(filename)
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
scanned = list(map(os.path.normpath, list(map(str, deps))))
expect = list(map(os.path.normpath, headers))
self.assertTrue(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
@@ -258,7 +258,7 @@ def deps_match(self, deps, headers):
# define some tests:
class FortranScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write('f1.f', "\n")
test.write('f2.f', " INCLUDE 'fi.f'\n")
env = DummyEnvironment([])
@@ -272,7 +272,7 @@ class FortranScannerTestCase1(unittest.TestCase):
class FortranScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write('f1.f', "\n")
test.write('f2.f', " INCLUDE 'fi.f'\n")
env = DummyEnvironment([test.workpath("d1")])
@@ -286,7 +286,7 @@ class FortranScannerTestCase2(unittest.TestCase):
class FortranScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
@@ -296,7 +296,7 @@ class FortranScannerTestCase3(unittest.TestCase):
class FortranScannerTestCase4(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write(['d1', 'f2.f'], " INCLUDE 'fi.f'\n")
env = DummyEnvironment([test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
@@ -308,7 +308,7 @@ class FortranScannerTestCase4(unittest.TestCase):
class FortranScannerTestCase5(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
@@ -318,7 +318,7 @@ class FortranScannerTestCase5(unittest.TestCase):
class FortranScannerTestCase6(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write('f2.f', "\n")
env = DummyEnvironment([test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
@@ -330,7 +330,7 @@ class FortranScannerTestCase6(unittest.TestCase):
class FortranScannerTestCase7(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([test.workpath("d1/d2"), test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
@@ -340,7 +340,7 @@ class FortranScannerTestCase7(unittest.TestCase):
class FortranScannerTestCase8(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write('f2.f', "\n")
env = DummyEnvironment([test.workpath("d1/d2"), test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
@@ -352,7 +352,7 @@ class FortranScannerTestCase8(unittest.TestCase):
class FortranScannerTestCase9(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write('f3.f', "\n")
env = DummyEnvironment([])
s = SCons.Scanner.Fortran.FortranScan()
@@ -380,7 +380,7 @@ class FortranScannerTestCase9(unittest.TestCase):
class FortranScannerTestCase10(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(["include"])
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
@@ -397,11 +397,11 @@ class FortranScannerTestCase10(unittest.TestCase):
class FortranScannerTestCase11(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
SCons.Warnings.enableWarningClass(SCons.Warnings.DependencyWarning)
class TestOut:
- def __call__(self, x):
+ def __call__(self, x) -> None:
self.out = x
to = TestOut()
@@ -419,7 +419,7 @@ class FortranScannerTestCase11(unittest.TestCase):
class FortranScannerTestCase12(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([])
env.fs.chdir(env.Dir('include'))
s = SCons.Scanner.Fortran.FortranScan()
@@ -432,7 +432,7 @@ class FortranScannerTestCase12(unittest.TestCase):
class FortranScannerTestCase13(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
os.chdir(test.workpath('work'))
fs = SCons.Node.FS.FS(test.workpath('work'))
fs.Repository(test.workpath('repository'))
@@ -451,7 +451,7 @@ class FortranScannerTestCase13(unittest.TestCase):
class FortranScannerTestCase14(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
os.chdir(test.workpath('work'))
fs = SCons.Node.FS.FS(test.workpath('work'))
fs.VariantDir('build1', 'src', 1)
@@ -473,7 +473,7 @@ class FortranScannerTestCase14(unittest.TestCase):
class FortranScannerTestCase15(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
class SubstEnvironment(DummyEnvironment):
def subst(self, arg, target=None, source=None, conv=None, test=test):
if arg == "$junk":
@@ -492,7 +492,7 @@ class FortranScannerTestCase15(unittest.TestCase):
class FortranScannerTestCase16(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
test.write('f1.f', "\n")
test.write('f2.f', "\n")
test.write('f3.f', "\n")
diff --git a/SCons/Scanner/IDLTests.py b/SCons/Scanner/IDLTests.py
index 28433d1c8..b70115bdc 100644
--- a/SCons/Scanner/IDLTests.py
+++ b/SCons/Scanner/IDLTests.py
@@ -187,7 +187,7 @@ test.write([ 'repository', 'src', 'ddd.idl'], "\n")
# define some helpers:
class DummyEnvironment:
- def __init__(self, listCppPath):
+ def __init__(self, listCppPath) -> None:
self.path = listCppPath
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -207,16 +207,16 @@ class DummyEnvironment:
path = [path]
return list(map(self.subst, path))
- def __contains__(self, key):
+ def __contains__(self, key) -> bool:
return key in self.Dictionary()
def __getitem__(self,key):
return self.Dictionary()[key]
- def __setitem__(self,key,value):
+ def __setitem__(self,key,value) -> None:
self.Dictionary()[key] = value
- def __delitem__(self,key):
+ def __delitem__(self,key) -> None:
del self.Dictionary()[key]
def get_calculator(self):
@@ -237,7 +237,7 @@ my_normpath = os.path.normpath
if os.path.normcase('foo') == os.path.normcase('FOO'):
my_normpath = os.path.normcase
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
scanned = list(map(my_normpath, list(map(str, deps))))
expect = list(map(my_normpath, headers))
self.assertTrue(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
@@ -245,7 +245,7 @@ def deps_match(self, deps, headers):
# define some tests:
class IDLScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([])
s = SCons.Scanner.IDL.IDLScan()
path = s.path(env)
@@ -254,7 +254,7 @@ class IDLScannerTestCase1(unittest.TestCase):
deps_match(self, deps, headers)
class IDLScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([test.workpath("d1")])
s = SCons.Scanner.IDL.IDLScan()
path = s.path(env)
@@ -263,7 +263,7 @@ class IDLScannerTestCase2(unittest.TestCase):
deps_match(self, deps, headers)
class IDLScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([test.workpath("d1")])
s = SCons.Scanner.IDL.IDLScan()
path = s.path(env)
@@ -272,7 +272,7 @@ class IDLScannerTestCase3(unittest.TestCase):
deps_match(self, deps, headers)
class IDLScannerTestCase4(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([test.workpath("d1"), test.workpath("d1/d2")])
s = SCons.Scanner.IDL.IDLScan()
path = s.path(env)
@@ -281,7 +281,7 @@ class IDLScannerTestCase4(unittest.TestCase):
deps_match(self, deps, headers)
class IDLScannerTestCase5(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([])
s = SCons.Scanner.IDL.IDLScan()
path = s.path(env)
@@ -306,7 +306,7 @@ class IDLScannerTestCase5(unittest.TestCase):
deps_match(self, deps, headers)
class IDLScannerTestCase6(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env1 = DummyEnvironment([test.workpath("d1")])
env2 = DummyEnvironment([test.workpath("d1/d2")])
s = SCons.Scanner.IDL.IDLScan()
@@ -320,7 +320,7 @@ class IDLScannerTestCase6(unittest.TestCase):
deps_match(self, deps2, headers2)
class IDLScannerTestCase7(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(["include"])
s = SCons.Scanner.IDL.IDLScan()
path = s.path(env)
@@ -336,10 +336,10 @@ class IDLScannerTestCase7(unittest.TestCase):
deps_match(self, deps2, headers2)
class IDLScannerTestCase8(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
SCons.Warnings.enableWarningClass(SCons.Warnings.DependencyWarning)
class TestOut:
- def __call__(self, x):
+ def __call__(self, x) -> None:
self.out = x
to = TestOut()
@@ -358,7 +358,7 @@ class IDLScannerTestCase8(unittest.TestCase):
test.unlink('fa.idl')
class IDLScannerTestCase9(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment([])
env.fs.chdir(env.Dir('include'))
s = SCons.Scanner.IDL.IDLScan()
@@ -370,7 +370,7 @@ class IDLScannerTestCase9(unittest.TestCase):
test.unlink('include/t4.idl')
class IDLScannerTestCase10(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
os.chdir(test.workpath('work'))
fs = SCons.Node.FS.FS(test.workpath('work'))
fs.Repository(test.workpath('repository'))
@@ -389,7 +389,7 @@ class IDLScannerTestCase10(unittest.TestCase):
os.chdir(test.workpath(''))
class IDLScannerTestCase11(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
os.chdir(test.workpath('work'))
fs = SCons.Node.FS.FS(test.workpath('work'))
fs.VariantDir('build1', 'src', 1)
@@ -410,7 +410,7 @@ class IDLScannerTestCase11(unittest.TestCase):
os.chdir(test.workpath(''))
class IDLScannerTestCase12(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
class SubstEnvironment(DummyEnvironment):
def subst(self, arg, target=None, source=None, conv=None, test=test):
if arg == "$blah":
diff --git a/SCons/Scanner/Java.py b/SCons/Scanner/Java.py
index e6c2db978..4a66c9de9 100644
--- a/SCons/Scanner/Java.py
+++ b/SCons/Scanner/Java.py
@@ -52,7 +52,7 @@ def _subst_paths(env, paths) -> list:
return paths
-def _collect_classes(classlist, dirname, files):
+def _collect_classes(classlist, dirname, files) -> None:
for fname in files:
if fname.endswith(".class"):
classlist.append(os.path.join(str(dirname), fname))
diff --git a/SCons/Scanner/JavaTests.py b/SCons/Scanner/JavaTests.py
index faa0c49ea..cf4ca8384 100644
--- a/SCons/Scanner/JavaTests.py
+++ b/SCons/Scanner/JavaTests.py
@@ -54,7 +54,7 @@ for fname in subfiles:
test.write(fname.split('/'), "\n")
class DummyEnvironment(collections.UserDict):
- def __init__(self,**kw):
+ def __init__(self,**kw) -> None:
collections.UserDict.__init__(self)
self.data.update(kw)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -73,7 +73,7 @@ class DummyEnvironment(collections.UserDict):
path = [path]
return list(map(self.subst, path))
- def has_key(self, key):
+ def has_key(self, key) -> bool:
return key in self.Dictionary()
def get_calculator(self):
@@ -93,13 +93,13 @@ class DummyEnvironment(collections.UserDict):
class DummyNode:
- def __init__(self, name):
+ def __init__(self, name) -> None:
self.name = name
- def rexists(self):
+ def rexists(self) -> int:
return 1
- def __str__(self):
+ def __str__(self) -> str:
return self.name
@@ -109,14 +109,14 @@ my_normpath = os.path.normpath
if os.path.normcase('foo') == os.path.normcase('FOO'):
my_normpath = os.path.normcase
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
scanned = sorted(map(my_normpath, list(map(str, deps))))
expect = sorted(map(my_normpath, headers))
self.assertTrue(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
class JavaScannerEmptyClasspath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
path = []
env = DummyEnvironment(JAVASUFFIXES=['.java'], JAVACLASSPATH=path)
s = SCons.Scanner.Java.JavaScanner()
@@ -126,7 +126,7 @@ class JavaScannerEmptyClasspath(unittest.TestCase):
class JavaScannerClasspath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(JAVASUFFIXES=['.java'],
JAVACLASSPATH=[test.workpath('classpath.jar')])
s = SCons.Scanner.Java.JavaScanner()
@@ -136,7 +136,7 @@ class JavaScannerClasspath(unittest.TestCase):
class JavaScannerWildcardClasspath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(JAVASUFFIXES=['.java'],
JAVACLASSPATH=[test.workpath('*')])
s = SCons.Scanner.Java.JavaScanner()
@@ -146,7 +146,7 @@ class JavaScannerWildcardClasspath(unittest.TestCase):
class JavaScannerDirClasspath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(JAVASUFFIXES=['.java'],
JAVACLASSPATH=[test.workpath()])
s = SCons.Scanner.Java.JavaScanner()
@@ -156,7 +156,7 @@ class JavaScannerDirClasspath(unittest.TestCase):
class JavaScannerNamedDirClasspath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(
JAVASUFFIXES=['.java'],
JAVACLASSPATH=[test.workpath('com'), test.workpath('java space')],
@@ -168,7 +168,7 @@ class JavaScannerNamedDirClasspath(unittest.TestCase):
class JavaScannerSearchPathClasspath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(
JAVASUFFIXES=['.java'],
JAVACLASSPATH=os.pathsep.join([test.workpath('com'), test.workpath('java space')]),
@@ -180,7 +180,7 @@ class JavaScannerSearchPathClasspath(unittest.TestCase):
class JavaScannerEmptyProcessorpath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
path = []
env = DummyEnvironment(JAVASUFFIXES=['.java'], JAVAPROCESSORPATH=path)
s = SCons.Scanner.Java.JavaScanner()
@@ -190,7 +190,7 @@ class JavaScannerEmptyProcessorpath(unittest.TestCase):
class JavaScannerProcessorpath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(JAVASUFFIXES=['.java'],
JAVAPROCESSORPATH=[test.workpath('classpath.jar')])
s = SCons.Scanner.Java.JavaScanner()
@@ -200,7 +200,7 @@ class JavaScannerProcessorpath(unittest.TestCase):
class JavaScannerWildcardProcessorpath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(JAVASUFFIXES=['.java'],
JAVAPROCESSORPATH=[test.workpath('*')])
s = SCons.Scanner.Java.JavaScanner()
@@ -210,7 +210,7 @@ class JavaScannerWildcardProcessorpath(unittest.TestCase):
class JavaScannerDirProcessorpath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(JAVASUFFIXES=['.java'],
JAVAPROCESSORPATH=[test.workpath()])
s = SCons.Scanner.Java.JavaScanner()
@@ -220,7 +220,7 @@ class JavaScannerDirProcessorpath(unittest.TestCase):
class JavaScannerNamedDirProcessorpath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(
JAVASUFFIXES=['.java'],
JAVAPROCESSORPATH=[test.workpath('com'), test.workpath('java space')],
@@ -232,7 +232,7 @@ class JavaScannerNamedDirProcessorpath(unittest.TestCase):
class JavaScannerSearchPathProcessorpath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(
JAVASUFFIXES=['.java'],
JAVAPROCESSORPATH=os.pathsep.join([test.workpath('com'), test.workpath('java space')]),
diff --git a/SCons/Scanner/LaTeX.py b/SCons/Scanner/LaTeX.py
index 700b7cbe7..6abe7362d 100644
--- a/SCons/Scanner/LaTeX.py
+++ b/SCons/Scanner/LaTeX.py
@@ -78,7 +78,7 @@ class FindENVPathDirs:
A class to bind a specific E{*}PATH variable name to a function that
will return all of the E{*}path directories.
"""
- def __init__(self, variable):
+ def __init__(self, variable) -> None:
self.variable = variable
def __call__(self, env, dir=None, target=None, source=None, argument=None):
@@ -175,7 +175,7 @@ class LaTeX(ScannerBase):
'includefrom', 'subincludefrom',
'inputfrom', 'subinputfrom']
- def __init__(self, name, suffixes, graphics_extensions, *args, **kwargs):
+ def __init__(self, name, suffixes, graphics_extensions, *args, **kwargs) -> None:
regex = r'''
\\(
include
@@ -219,7 +219,7 @@ class LaTeX(ScannerBase):
back and uses a dictionary of tuples rather than a single tuple
of paths.
"""
- def __init__(self, dictionary):
+ def __init__(self, dictionary) -> None:
self.dictionary = {}
for k,n in dictionary.items():
self.dictionary[k] = (FindPathDirs(n), FindENVPathDirs(n))
@@ -241,7 +241,7 @@ class LaTeX(ScannerBase):
Do not scan *.eps, *.pdf, *.jpg, etc.
"""
- def __init__(self, suffixes):
+ def __init__(self, suffixes) -> None:
self.suffixes = suffixes
def __call__(self, node, env):
@@ -331,7 +331,7 @@ class LaTeX(ScannerBase):
line_continues_a_comment = len(comment) > 0
return '\n'.join(out).rstrip()+'\n'
- def scan(self, node, subdir='.'):
+ def scan(self, node, subdir: str='.'):
# Modify the default scan function to allow for the regular
# expression to return a comma separated list of file names
# as can be the case with the bibliography keyword.
diff --git a/SCons/Scanner/LaTeXTests.py b/SCons/Scanner/LaTeXTests.py
index 252d8d451..ae3ae6659 100644
--- a/SCons/Scanner/LaTeXTests.py
+++ b/SCons/Scanner/LaTeXTests.py
@@ -81,7 +81,7 @@ test.write('incNO.tex', "\n")
# define some helpers:
# copied from CTest.py
class DummyEnvironment(collections.UserDict):
- def __init__(self, **kw):
+ def __init__(self, **kw) -> None:
super().__init__()
self.data.update(kw)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -121,7 +121,7 @@ if os.path.normcase('foo') == os.path.normcase('FOO'):
else:
my_normpath = os.path.normpath
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
global my_normpath
scanned = list(map(my_normpath, list(map(str, deps))))
expect = list(map(my_normpath, headers))
@@ -129,7 +129,7 @@ def deps_match(self, deps, headers):
class LaTeXScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
s = SCons.Scanner.LaTeX.LaTeXScanner()
path = s.path(env)
@@ -141,7 +141,7 @@ class LaTeXScannerTestCase1(unittest.TestCase):
deps_match(self, deps, headers)
class LaTeXScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")],LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
s = SCons.Scanner.LaTeX.LaTeXScanner()
path = s.path(env)
@@ -150,7 +150,7 @@ class LaTeXScannerTestCase2(unittest.TestCase):
deps_match(self, deps, headers)
class LaTeXScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")],LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
s = SCons.Scanner.LaTeX.LaTeXScanner()
path = s.path(env)
@@ -159,7 +159,7 @@ class LaTeXScannerTestCase3(unittest.TestCase):
deps_match(self, deps, files)
class LaTeXScannerTestCase4(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")],LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
s = SCons.Scanner.LaTeX.LaTeXScanner()
path = s.path(env)
diff --git a/SCons/Scanner/ProgTests.py b/SCons/Scanner/ProgTests.py
index 5aa057128..2798ab6cd 100644
--- a/SCons/Scanner/ProgTests.py
+++ b/SCons/Scanner/ProgTests.py
@@ -44,7 +44,7 @@ for h in libs:
# define some helpers:
class DummyEnvironment:
- def __init__(self, **kw):
+ def __init__(self, **kw) -> None:
self._dict = {'LIBSUFFIXES' : '.lib'}
self._dict.update(kw)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -57,16 +57,16 @@ class DummyEnvironment:
else:
return [self._dict[x] for x in args]
- def __contains__(self, key):
+ def __contains__(self, key) -> bool:
return key in self.Dictionary()
def __getitem__(self,key):
return self.Dictionary()[key]
- def __setitem__(self,key,value):
+ def __setitem__(self,key,value) -> None:
self.Dictionary()[key] = value
- def __delitem__(self,key):
+ def __delitem__(self,key) -> None:
del self.Dictionary()[key]
def subst(self, s, target=None, source=None, conv=None):
@@ -87,11 +87,11 @@ class DummyEnvironment:
return self.fs.File(test.workpath(filename))
class DummyNode:
- def __init__(self, name):
+ def __init__(self, name) -> None:
self.name = name
- def rexists(self):
+ def rexists(self) -> int:
return 1
- def __str__(self):
+ def __str__(self) -> str:
return self.name
def deps_match(deps, libs):
@@ -102,7 +102,7 @@ def deps_match(deps, libs):
# define some tests:
class ProgramScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=[ test.workpath("") ],
LIBS=[ 'l1', 'l2', 'l3' ])
s = SCons.Scanner.Prog.ProgramScanner()
@@ -135,7 +135,7 @@ class ProgramScannerTestCase1(unittest.TestCase):
class ProgramScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=list(map(test.workpath,
["", "d1", "d1/d2" ])),
LIBS=[ 'l1', 'l2', 'l3' ])
@@ -145,7 +145,7 @@ class ProgramScannerTestCase2(unittest.TestCase):
assert deps_match(deps, ['l1.lib', 'd1/l2.lib', 'd1/d2/l3.lib' ]), list(map(str, deps))
class ProgramScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"),
test.workpath("d1")],
LIBS='l2 l3'.split())
@@ -155,7 +155,7 @@ class ProgramScannerTestCase3(unittest.TestCase):
assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), list(map(str, deps))
class ProgramScannerTestCase5(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
class SubstEnvironment(DummyEnvironment):
def subst(self, arg, target=None, source=None, conv=None, path=test.workpath("d1")):
if arg == "$blah":
@@ -170,7 +170,7 @@ class ProgramScannerTestCase5(unittest.TestCase):
assert deps_match(deps, [ 'd1/l2.lib' ]), list(map(str, deps))
class ProgramScannerTestCase6(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
LIBS=['foo', 'sub/libbar', 'xyz.other'],
LIBPREFIXES=['lib'],
@@ -181,7 +181,7 @@ class ProgramScannerTestCase6(unittest.TestCase):
assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), list(map(str, deps))
class ProgramScannerTestCase7(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
LIBS=['foo', '$LIBBAR', '$XYZ'],
LIBPREFIXES=['lib'],
@@ -194,7 +194,7 @@ class ProgramScannerTestCase7(unittest.TestCase):
assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), list(map(str, deps))
class ProgramScannerTestCase8(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
n1 = DummyNode('n1')
env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
@@ -217,7 +217,7 @@ class ProgramScannerTestCase8(unittest.TestCase):
assert deps == [n1, n2], deps
class ProgramScannerTestCase9(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
LIBS=['foo', '$LIBBAR'],
LIBPREFIXES=['lib'],
@@ -229,7 +229,7 @@ class ProgramScannerTestCase9(unittest.TestCase):
assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), list(map(str, deps))
class ProgramScannerTestCase10(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
LIBS=['foo', '$LIBBAR'],
LIBPREFIXES=['lib'],
diff --git a/SCons/Scanner/PythonTests.py b/SCons/Scanner/PythonTests.py
index 1a4f5b430..03e4e1031 100644
--- a/SCons/Scanner/PythonTests.py
+++ b/SCons/Scanner/PythonTests.py
@@ -56,7 +56,7 @@ else:
my_normpath = os.path.normpath
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
global my_normpath
scanned = list(map(my_normpath, list(map(str, deps))))
expect = list(map(my_normpath, headers))
@@ -66,7 +66,7 @@ def deps_match(self, deps, headers):
# Copied from LaTeXTests.py.
class DummyEnvironment(collections.UserDict):
- def __init__(self, **kwargs):
+ def __init__(self, **kwargs) -> None:
super().__init__()
self.data.update(kwargs)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -104,7 +104,7 @@ class DummyEnvironment(collections.UserDict):
class PythonScannerTestPythonPath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
env['ENV']['PYTHONPATH'] = test.workpath('')
@@ -115,7 +115,7 @@ class PythonScannerTestPythonPath(unittest.TestCase):
class PythonScannerTestPythonCallablePath(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
env['ENV']['PYTHONPATH'] = test.workpath('')
@@ -126,7 +126,7 @@ class PythonScannerTestPythonCallablePath(unittest.TestCase):
class PythonScannerTestImportSimplePackage(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('imports_simple_package.py')
@@ -141,7 +141,7 @@ class PythonScannerTestImportSimplePackage(unittest.TestCase):
class PythonScannerTestImportSimplePackageModule1As(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('import_simple_package_module1_as.py')
@@ -152,7 +152,7 @@ class PythonScannerTestImportSimplePackageModule1As(unittest.TestCase):
class PythonScannerTestImportSimplePackageModuleAs(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('import_simple_package_module1.py')
@@ -163,7 +163,7 @@ class PythonScannerTestImportSimplePackageModuleAs(unittest.TestCase):
class PythonScannerTestFromImportSimplePackageModule1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('from_import_simple_package_module1.py')
@@ -174,7 +174,7 @@ class PythonScannerTestFromImportSimplePackageModule1(unittest.TestCase):
class PythonScannerTestFromImportSimplePackageModule1As(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('from_import_simple_package_module1_as.py')
@@ -186,7 +186,7 @@ class PythonScannerTestFromImportSimplePackageModule1As(unittest.TestCase):
class PythonScannerTestFromImportSimplePackageModulesNoSpace(
unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('from_import_simple_package_modules_no_space.py')
@@ -199,7 +199,7 @@ class PythonScannerTestFromImportSimplePackageModulesNoSpace(
class PythonScannerTestFromImportSimplePackageModulesWithSpace(
unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('from_import_simple_package_modules_with_space.py')
@@ -211,7 +211,7 @@ class PythonScannerTestFromImportSimplePackageModulesWithSpace(
class PythonScannerTestCurdirReferenceScript(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.Dir('curdir_reference').File('script.py')
@@ -222,7 +222,7 @@ class PythonScannerTestCurdirReferenceScript(unittest.TestCase):
class PythonScannerTestImportsNested3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File('imports_nested3.py')
@@ -234,7 +234,7 @@ class PythonScannerTestImportsNested3(unittest.TestCase):
class PythonScannerTestImportsGrandparentModule(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File(
@@ -246,7 +246,7 @@ class PythonScannerTestImportsGrandparentModule(unittest.TestCase):
class PythonScannerTestImportsParentModule(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File(
@@ -258,7 +258,7 @@ class PythonScannerTestImportsParentModule(unittest.TestCase):
class PythonScannerTestImportsParentThenSubmodule(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
env = DummyEnvironment()
s = SCons.Scanner.Python.PythonScanner
node = env.File(
@@ -270,7 +270,7 @@ class PythonScannerTestImportsParentThenSubmodule(unittest.TestCase):
class PythonScannerTestImportsModuleWithFunc(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""
This test case tests the following import statement:
`from simple_package.module1 import somefunc` with somefunc.py existing
@@ -287,7 +287,7 @@ class PythonScannerTestImportsModuleWithFunc(unittest.TestCase):
class PythonScannerTestFromNested1ImportNested2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""
This test case tests the following import statement:
`from nested1 import module, nested2`. In this test, module is a Python
@@ -305,7 +305,7 @@ class PythonScannerTestFromNested1ImportNested2(unittest.TestCase):
class PythonScannerTestImportUnknownFiles(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
"""
This test case tests importing files that are not found. If Python
really can't find those files, it will fail. But this is intended to
diff --git a/SCons/Scanner/RCTests.py b/SCons/Scanner/RCTests.py
index 3655269e9..120c7f84b 100644
--- a/SCons/Scanner/RCTests.py
+++ b/SCons/Scanner/RCTests.py
@@ -71,7 +71,7 @@ for h in headers:
# define some helpers:
class DummyEnvironment(collections.UserDict):
- def __init__(self, **kwargs):
+ def __init__(self, **kwargs) -> None:
super().__init__()
self.data.update(kwargs)
self.fs = SCons.Node.FS.FS(test.workpath(''))
@@ -89,7 +89,7 @@ class DummyEnvironment(collections.UserDict):
path = [path]
return list(map(self.subst, path))
- def __contains__(self, key):
+ def __contains__(self, key) -> bool:
return key in self.data
def get_calculator(self):
@@ -110,7 +110,7 @@ my_normpath = os.path.normpath
if os.path.normcase('foo') == os.path.normcase('FOO'):
my_normpath = os.path.normcase
-def deps_match(self, deps, headers):
+def deps_match(self, deps, headers) -> None:
scanned = sorted(map(my_normpath, list(map(str, deps))))
expect = sorted(map(my_normpath, headers))
self.assertTrue(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
@@ -118,7 +118,7 @@ def deps_match(self, deps, headers):
# define some tests:
class RCScannerTestCase1(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
path = []
env = DummyEnvironment(RCSUFFIXES=['.rc','.rc2'],
CPPPATH=path)
@@ -128,7 +128,7 @@ class RCScannerTestCase1(unittest.TestCase):
deps_match(self, deps, headers)
class RCScannerTestCase2(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
path = []
env = DummyEnvironment(RCSUFFIXES=['.rc','.rc2'],
CPPPATH=path)
@@ -145,7 +145,7 @@ class RCScannerTestCase2(unittest.TestCase):
deps_match(self, deps, headers)
class RCScannerTestCase3(unittest.TestCase):
- def runTest(self):
+ def runTest(self) -> None:
path = []
env = DummyEnvironment(RCSUFFIXES=['.rc','.rc2'],
CPPPATH=path)
diff --git a/SCons/Scanner/ScannerTests.py b/SCons/Scanner/ScannerTests.py
index b9cb209f6..1fbbb62bc 100644
--- a/SCons/Scanner/ScannerTests.py
+++ b/SCons/Scanner/ScannerTests.py
@@ -35,7 +35,7 @@ class DummyFS:
return DummyNode(name)
class DummyEnvironment(collections.UserDict):
- def __init__(self, mapping=None, **kwargs):
+ def __init__(self, mapping=None, **kwargs) -> None:
super().__init__(mapping)
self.data.update(kwargs)
self.fs = DummyFS()
@@ -55,31 +55,31 @@ class DummyEnvironment(collections.UserDict):
return factory or self.fs.File
class DummyNode:
- def __init__(self, name, search_result=()):
+ def __init__(self, name, search_result=()) -> None:
self.name = name
self.search_result = tuple(search_result)
- def rexists(self):
+ def rexists(self) -> bool:
return True
- def __str__(self):
+ def __str__(self) -> str:
return self.name
def Rfindalldirs(self, pathlist):
return self.search_result + pathlist
- def __repr__(self):
+ def __repr__(self) -> str:
return self.name
def __eq__(self, other):
return self.name == other.name
- def __repr__(self):
+ def __repr__(self) -> str:
return self.name
def __eq__(self, other):
return self.name == other.name
class FindPathDirsTestCase(unittest.TestCase):
- def test_FindPathDirs(self):
+ def test_FindPathDirs(self) -> None:
"""Test the FindPathDirs callable class"""
env = DummyEnvironment(LIBPATH = [ 'foo' ])
@@ -95,9 +95,9 @@ class FindPathDirsTestCase(unittest.TestCase):
class ScannerTestCase(unittest.TestCase):
- def test_creation(self):
+ def test_creation(self) -> None:
"""Test creation of Scanner objects"""
- def func(self):
+ def func(self) -> None:
pass
s = ScannerBase(func)
assert isinstance(s, ScannerBase), s
@@ -120,11 +120,11 @@ class ScannerTestCase(unittest.TestCase):
class ScannerBaseTestCase(unittest.TestCase):
class skey_node:
- def __init__(self, key):
+ def __init__(self, key) -> None:
self.key = key
def scanner_key(self):
return self.key
- def rexists(self):
+ def rexists(self) -> int:
return 1
def func(self, filename, env, target, *args):
@@ -137,7 +137,7 @@ class ScannerBaseTestCase(unittest.TestCase):
return self.deps
- def test(self, scanner, env, filename, deps, *args):
+ def test(self, scanner, env, filename, deps, *args) -> None:
self.deps = deps
path = scanner.path(env)
scanned = scanner(filename, env, path)
@@ -154,7 +154,7 @@ class ScannerBaseTestCase(unittest.TestCase):
else:
self.assertFalse(hasattr(self, "arg"), "an argument was given when it shouldn't have been")
- def test___call__dict(self):
+ def test___call__dict(self) -> None:
"""Test calling ScannerBase objects with a dictionary"""
called = []
def s1func(node, env, path, called=called):
@@ -177,9 +177,9 @@ class ScannerBaseTestCase(unittest.TestCase):
selector(ny, env, [])
assert called == ['s2func', ny], called
- def test_path(self):
+ def test_path(self) -> None:
"""Test the ScannerBase path() method"""
- def pf(env, cwd, target, source, argument=None):
+ def pf(env, cwd, target, source, argument=None) -> str:
return "pf: %s %s %s %s %s" % \
(env.VARIABLE, cwd, target[0], source[0], argument)
@@ -196,7 +196,7 @@ class ScannerBaseTestCase(unittest.TestCase):
p = s.path(env, 'here', [target], [source])
assert p == "pf: v1 here target source xyz", p
- def test_positional(self):
+ def test_positional(self) -> None:
"""Test the ScannerBase class using positional arguments"""
s = ScannerBase(self.func, "Pos")
env = DummyEnvironment()
@@ -207,7 +207,7 @@ class ScannerBaseTestCase(unittest.TestCase):
env.VARIABLE = "i1"
self.test(s, env, DummyNode('i1.cpp'), ['i1.h', 'i1.hpp'])
- def test_keywords(self):
+ def test_keywords(self) -> None:
"""Test the ScannerBase class using keyword arguments"""
s = ScannerBase(function = self.func, name = "Key")
env = DummyEnvironment()
@@ -219,7 +219,7 @@ class ScannerBaseTestCase(unittest.TestCase):
self.test(s, env, DummyNode('i2.cpp'), ['i2.h', 'i2.hpp'])
- def test_pos_opt(self):
+ def test_pos_opt(self) -> None:
"""Test the ScannerBase class using both position and optional arguments"""
arg = "this is the argument"
s = ScannerBase(self.func, "PosArg", arg)
@@ -231,7 +231,7 @@ class ScannerBaseTestCase(unittest.TestCase):
env.VARIABLE = "i3"
self.test(s, env, DummyNode('i3.cpp'), ['i3.h', 'i3.hpp'], arg)
- def test_key_opt(self):
+ def test_key_opt(self) -> None:
"""Test the ScannerBase class using both keyword and optional arguments"""
arg = "this is another argument"
s = ScannerBase(function = self.func, name = "KeyArg", argument = arg)
@@ -243,12 +243,12 @@ class ScannerBaseTestCase(unittest.TestCase):
env.VARIABLE = "i4"
self.test(s, env, DummyNode('i4.cpp'), ['i4.h', 'i4.hpp'], arg)
- def test___cmp__(self):
+ def test___cmp__(self) -> None:
"""Test the ScannerBase class __cmp__() method"""
s = ScannerBase(self.func, "Cmp")
assert s is not None
- def test_hash(self):
+ def test_hash(self) -> None:
"""Test the ScannerBase class __hash__() method"""
s = ScannerBase(self.func, "Hash")
mapping = {}
@@ -258,11 +258,11 @@ class ScannerBaseTestCase(unittest.TestCase):
self.assertTrue(h == i,
"hash Scanner base class expected %s, got %s" % (i, h))
- def test_scan_check(self):
+ def test_scan_check(self) -> None:
"""Test the ScannerBase class scan_check() method"""
def my_scan(filename, env, target, *args):
return []
- def check(node, env, s=self):
+ def check(node, env, s=self) -> int:
s.checked[str(node)] = 1
return 1
env = DummyEnvironment()
@@ -273,7 +273,7 @@ class ScannerBaseTestCase(unittest.TestCase):
self.assertTrue(self.checked['x'] == 1,
"did not call check function")
- def test_recursive(self):
+ def test_recursive(self) -> None:
"""Test the ScannerBase class recursive flag"""
nodes = [1, 2, 3, 4]
@@ -295,7 +295,7 @@ class ScannerBaseTestCase(unittest.TestCase):
n = s.recurse_nodes(nodes)
self.assertTrue(n == [1, 3], "recursive = 1 didn't return all nodes: %s" % n)
- def test_get_skeys(self):
+ def test_get_skeys(self) -> None:
"""Test the ScannerBase get_skeys() method"""
s = ScannerBase(function = self.func)
sk = s.get_skeys()
@@ -310,7 +310,7 @@ class ScannerBaseTestCase(unittest.TestCase):
sk = s.get_skeys(env)
self.assertTrue(sk == ['.3', '.4'], "sk was %s, not ['.3', '.4']")
- def test_select(self):
+ def test_select(self) -> None:
"""Test the ScannerBase select() method"""
scanner = ScannerBase(function = self.func)
s = scanner.select('.x')
@@ -324,7 +324,7 @@ class ScannerBaseTestCase(unittest.TestCase):
s = selector.select(self.skey_node('.z'))
assert s is None, s
- def test_add_scanner(self):
+ def test_add_scanner(self) -> None:
"""Test the ScannerBase add_scanner() method"""
selector = ScannerBase({'.x' : 1, '.y' : 2})
s = selector.select(self.skey_node('.z'))
@@ -333,7 +333,7 @@ class ScannerBaseTestCase(unittest.TestCase):
s = selector.select(self.skey_node('.z'))
assert s == 3, s
- def test___str__(self):
+ def test___str__(self) -> None:
"""Test the ScannerBase __str__() method"""
scanner = ScannerBase(function = self.func)
s = str(scanner)
@@ -344,20 +344,20 @@ class ScannerBaseTestCase(unittest.TestCase):
class SelectorTestCase(unittest.TestCase):
class skey_node:
- def __init__(self, key):
+ def __init__(self, key) -> None:
self.key = key
def scanner_key(self):
return self.key
- def rexists(self):
+ def rexists(self) -> int:
return 1
- def test___init__(self):
+ def test___init__(self) -> None:
"""Test creation of Scanner.Selector object"""
s = Selector({})
assert isinstance(s, Selector), s
assert s.mapping == {}, s.mapping
- def test___call__(self):
+ def test___call__(self) -> None:
"""Test calling Scanner.Selector objects"""
called = []
def s1func(node, env, path, called=called):
@@ -380,7 +380,7 @@ class SelectorTestCase(unittest.TestCase):
selector(ny, env, [])
assert called == ['s2func', ny], called
- def test_select(self):
+ def test_select(self) -> None:
"""Test the Scanner.Selector select() method"""
selector = Selector({'.x' : 1, '.y' : 2})
s = selector.select(self.skey_node('.x'))
@@ -390,7 +390,7 @@ class SelectorTestCase(unittest.TestCase):
s = selector.select(self.skey_node('.z'))
assert s is None, s
- def test_add_scanner(self):
+ def test_add_scanner(self) -> None:
"""Test the Scanner.Selector add_scanner() method"""
selector = Selector({'.x' : 1, '.y' : 2})
s = selector.select(self.skey_node('.z'))
@@ -400,31 +400,31 @@ class SelectorTestCase(unittest.TestCase):
assert s == 3, s
class CurrentTestCase(unittest.TestCase):
- def test_class(self):
+ def test_class(self) -> None:
"""Test the Scanner.Current class"""
class MyNode:
- def __init__(self):
+ def __init__(self) -> None:
self.called_has_builder = None
self.called_is_up_to_date = None
self.func_called = None
- def rexists(self):
+ def rexists(self) -> int:
return 1
class HasNoBuilder(MyNode):
def has_builder(self):
self.called_has_builder = 1
return None
class IsNotCurrent(MyNode):
- def has_builder(self):
+ def has_builder(self) -> int:
self.called_has_builder = 1
return 1
def is_up_to_date(self):
self.called_is_up_to_date = 1
return None
class IsCurrent(MyNode):
- def has_builder(self):
+ def has_builder(self) -> int:
self.called_has_builder = 1
return 1
- def is_up_to_date(self):
+ def is_up_to_date(self) -> int:
self.called_is_up_to_date = 1
return 1
def func(node, env, path):
@@ -461,7 +461,7 @@ class ClassicTestCase(unittest.TestCase):
return self.deps
- def test_find_include(self):
+ def test_find_include(self) -> None:
"""Test the Scanner.Classic find_include() method"""
env = DummyEnvironment()
s = Classic("t", ['.suf'], 'MYPATH', r'^my_inc (\S+)')
@@ -480,15 +480,15 @@ class ClassicTestCase(unittest.TestCase):
finally:
SCons.Node.FS.find_file = save
- def test_name(self):
+ def test_name(self) -> None:
"""Test setting the Scanner.Classic name"""
s = Classic("my_name", ['.s'], 'MYPATH', r'^my_inc (\S+)')
assert s.name == "my_name", s.name
- def test_scan(self):
+ def test_scan(self) -> None:
"""Test the Scanner.Classic scan() method"""
class MyNode:
- def __init__(self, name):
+ def __init__(self, name) -> None:
self.name = name
self._rfile = self
self.includes = None
@@ -562,7 +562,7 @@ class ClassicTestCase(unittest.TestCase):
ret = s.function(n, env, ('foo5',))
assert ret == ['jkl', 'mno'], ret
- def test_recursive(self):
+ def test_recursive(self) -> None:
"""Test the Scanner.Classic class recursive flag"""
nodes = [1, 2, 3, 4]
@@ -582,7 +582,7 @@ class ClassicTestCase(unittest.TestCase):
class ClassicCPPTestCase(unittest.TestCase):
- def test_find_include(self):
+ def test_find_include(self) -> None:
"""Test the Scanner.ClassicCPP find_include() method"""
env = DummyEnvironment()
s = ClassicCPP("Test", [], None, "")
diff --git a/SCons/Scanner/__init__.py b/SCons/Scanner/__init__.py
index fe44ee0fc..c8c2732be 100644
--- a/SCons/Scanner/__init__.py
+++ b/SCons/Scanner/__init__.py
@@ -59,7 +59,7 @@ class FindPathDirs:
"""Class to bind a specific E{*}PATH variable name to a function that
will return all of the E{*}path directories.
"""
- def __init__(self, variable):
+ def __init__(self, variable) -> None:
self.variable = variable
def __call__(self, env, dir=None, target=None, source=None, argument=None):
@@ -149,7 +149,7 @@ class ScannerBase:
def __init__(
self,
function,
- name="NONE",
+ name: str="NONE",
argument=_null,
skeys=_null,
path_function=None,
@@ -159,7 +159,7 @@ class ScannerBase:
node_factory=None,
scan_check=None,
recursive=None,
- ):
+ ) -> None:
"""Construct a new scanner object given a scanner function."""
# Note: this class could easily work with scanner functions that take
# something other than a filename as an argument (e.g. a database
@@ -238,10 +238,10 @@ class ScannerBase:
def __hash__(self):
return id(self)
- def __str__(self):
+ def __str__(self) -> str:
return self.name
- def add_skey(self, skey):
+ def add_skey(self, skey) -> None:
"""Add a skey to the list of skeys"""
self.skeys.append(skey)
@@ -270,7 +270,7 @@ class ScannerBase:
# recurse_nodes = _recurse_no_nodes
- def add_scanner(self, skey, scanner):
+ def add_scanner(self, skey, scanner) -> None:
self.function[skey] = scanner
self.add_skey(skey)
@@ -292,7 +292,7 @@ class Selector(ScannerBase):
used by various Tool modules and therefore was likely a template
for custom modules that may be out there.)
"""
- def __init__(self, mapping, *args, **kwargs):
+ def __init__(self, mapping, *args, **kwargs) -> None:
super().__init__(None, *args, **kwargs)
self.mapping = mapping
self.skeys = list(mapping.keys())
@@ -306,7 +306,7 @@ class Selector(ScannerBase):
except KeyError:
return None
- def add_scanner(self, skey, scanner):
+ def add_scanner(self, skey, scanner) -> None:
self.mapping[skey] = scanner
self.add_skey(skey)
@@ -318,7 +318,7 @@ class Current(ScannerBase):
either locally or in a repository).
"""
- def __init__(self, *args, **kwargs):
+ def __init__(self, *args, **kwargs) -> None:
def current_check(node, env):
return not node.has_builder() or node.is_up_to_date()
@@ -337,7 +337,7 @@ class Classic(Current):
name of the include file in group 0.
"""
- def __init__(self, name, suffixes, path_variable, regex, *args, **kwargs):
+ def __init__(self, name, suffixes, path_variable, regex, *args, **kwargs) -> None:
self.cre = re.compile(regex, re.M)
def _scan(node, _, path=(), self=self):