diff options
author | Mats Wichmann <mats@linux.com> | 2023-05-01 11:54:48 -0600 |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2023-05-01 12:06:45 -0600 |
commit | 1a103470a13a83590b3fc06e8779494e2b99751d (patch) | |
tree | ab4b5fcdbc2504ff1436387dbe82db2dcedff22b /SCons/SConfTests.py | |
parent | 0ef81fc03600cd275a8e6733aeca26e0db268dad (diff) | |
download | scons-git-1a103470a13a83590b3fc06e8779494e2b99751d.tar.gz |
Add some cheap return and parameter annotations
Use: https://github.com/JelleZijlstra/autotyping
to add "safe" return annotations.
Where a parameter has a default value that is an obvious scalar type
(bool, int, str, etc.) add those annotations as well.
Also fixed two small bugs that popped up when sanity-checking with
mypy. One in FortranCommon, where a return had been previously
annotated to be a tuple of Action, which should be ActionBase -
Action is the factory function, not the base class. The other was
a typo in the error raised in _add_cppdefines - the message was
formatted with the value of "define" which should have been "defines".
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'SCons/SConfTests.py')
-rw-r--r-- | SCons/SConfTests.py | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/SCons/SConfTests.py b/SCons/SConfTests.py index 5d0984833..e8e0fc72b 100644 --- a/SCons/SConfTests.py +++ b/SCons/SConfTests.py @@ -40,13 +40,13 @@ else: class SConfTestCase(unittest.TestCase): - def setUp(self): + def setUp(self) -> None: # we always want to start with a clean directory self.save_cwd = os.getcwd() self.test = TestCmd.TestCmd(workdir = '') os.chdir(self.test.workpath('')) - def tearDown(self): + def tearDown(self) -> None: self.test.cleanup() import SCons.SConsign SCons.SConsign.Reset() @@ -91,7 +91,7 @@ class SConfTestCase(unittest.TestCase): global existing_lib existing_lib = 'm' - def _baseTryXXX(self, TryFunc): + def _baseTryXXX(self, TryFunc) -> None: # TryCompile and TryLink are much the same, so we can test them # in one method, we pass the function as a string ('TryCompile', # 'TryLink'), so we are aware of reloading modules. @@ -148,7 +148,7 @@ class SConfTestCase(unittest.TestCase): finally: sconf.Finish() - def test_TryBuild(self): + def test_TryBuild(self) -> None: """Test SConf.TryBuild """ # 1 test that we can try a builder that returns a list of nodes @@ -160,14 +160,14 @@ class SConfTestCase(unittest.TestCase): import SCons.Node class MyAction: - def get_contents(self, target, source, env): + def get_contents(self, target, source, env) -> str: return 'MyBuilder-MyAction $SOURCE $TARGET' class Attrs: __slots__ = ('shared', '__dict__') class MyBuilder(SCons.Builder.BuilderBase): - def __init__(self): + def __init__(self) -> None: self.prefix = '' self.suffix = '' # need action because temporary file name uses hash of actions get_contents() @@ -175,7 +175,7 @@ class SConfTestCase(unittest.TestCase): def __call__(self, env, target, source, *args, **kw): class MyNode: - def __init__(self, name): + def __init__(self, name) -> None: self.name = name self.state = SCons.Node.no_state self.waiting_parents = set() @@ -185,45 +185,45 @@ class SConfTestCase(unittest.TestCase): self.attributes = Attrs() def disambiguate(self): return self - def has_builder(self): + def has_builder(self) -> int: return 1 - def add_pre_action(self, *actions): + def add_pre_action(self, *actions) -> None: pass - def add_post_action(self, *actions): + def add_post_action(self, *actions) -> None: pass - def children(self, scan = 1): + def children(self, scan: int = 1): return [] def get_state(self): return self.state - def set_state(self, state): + def set_state(self, state) -> None: self.state = state def alter_targets(self): return [], None def depends_on(self, nodes): return None - def postprocess(self): + def postprocess(self) -> None: pass - def clear(self): + def clear(self) -> None: pass def is_up_to_date(self): return None - def prepare(self): + def prepare(self) -> None: pass - def push_to_cache(self): + def push_to_cache(self) -> None: pass - def retrieve_from_cache(self): + def retrieve_from_cache(self) -> int: return 0 - def build(self, **kw): + def build(self, **kw) -> None: return - def built(self): + def built(self) -> None: pass - def get_stored_info(self): + def get_stored_info(self) -> None: pass - def is_conftest(self): + def is_conftest(self) -> bool: return True def get_executor(self): class Executor: - def __init__(self, targets): + def __init__(self, targets) -> None: self.targets = targets def get_all_targets(self): return self.targets @@ -235,17 +235,17 @@ class SConfTestCase(unittest.TestCase): finally: sconf.Finish() - def test_TryCompile(self): + def test_TryCompile(self) -> None: """Test SConf.TryCompile """ self._baseTryXXX( "TryCompile" ) #self.SConf.SConf.TryCompile ) - def test_TryLink(self): + def test_TryLink(self) -> None: """Test SConf.TryLink """ self._baseTryXXX( "TryLink" ) #self.SConf.SConf.TryLink ) - def test_TryRun(self): + def test_TryRun(self) -> None: """Test SConf.TryRun """ def checks(sconf): @@ -293,14 +293,14 @@ int main(void) { assert secondOcc is None, log - def test_TryAction(self): + def test_TryAction(self) -> None: """Test SConf.TryAction """ def actionOK(target, source, env): with open(str(target[0]), "w") as f: f.write("RUN OK\n") return None - def actionFAIL(target, source, env): + def actionFAIL(target, source, env) -> int: return 1 @@ -318,7 +318,7 @@ int main(void) { finally: sconf.Finish() - def _test_check_compilers(self, comp, func, name): + def _test_check_compilers(self, comp, func, name) -> None: """This is the implementation for CheckCC and CheckCXX tests.""" from copy import deepcopy @@ -413,7 +413,7 @@ int main(void) { sconf.Finish() - def test_CheckHeader(self): + def test_CheckHeader(self) -> None: """Test SConf.CheckHeader() """ self._resetSConfState() @@ -434,7 +434,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckCHeader(self): + def test_CheckCHeader(self) -> None: """Test SConf.CheckCHeader() """ self._resetSConfState() @@ -454,7 +454,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckCXXHeader(self): + def test_CheckCXXHeader(self) -> None: """Test SConf.CheckCXXHeader() """ self._resetSConfState() @@ -474,7 +474,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckLib(self): + def test_CheckLib(self) -> None: """Test SConf.CheckLib() """ self._resetSConfState() @@ -565,7 +565,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckLibWithHeader(self): + def test_CheckLibWithHeader(self) -> None: """Test SConf.CheckLibWithHeader() """ self._resetSConfState() @@ -664,7 +664,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckFunc(self): + def test_CheckFunc(self) -> None: """Test SConf.CheckFunc() """ self._resetSConfState() @@ -684,7 +684,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckProg(self): + def test_CheckProg(self) -> None: """Test SConf.CheckProg() """ self._resetSConfState() @@ -708,7 +708,7 @@ int main(void) { sconf.Finish() - def test_Define(self): + def test_Define(self) -> None: """Test SConf.Define() """ self._resetSConfState() @@ -744,7 +744,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckTypeSize(self): + def test_CheckTypeSize(self) -> None: """Test SConf.CheckTypeSize() """ self._resetSConfState() @@ -778,7 +778,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckDeclaration(self): + def test_CheckDeclaration(self) -> None: """Test SConf.CheckDeclaration() """ self._resetSConfState() @@ -799,7 +799,7 @@ int main(void) { finally: sconf.Finish() - def test_CheckMember(self): + def test_CheckMember(self) -> None: """Test SConf.CheckMember() """ self._resetSConfState() @@ -820,7 +820,7 @@ int main(void) { sconf.Finish() - def test_(self): + def test_(self) -> None: """Test SConf.CheckType() """ self._resetSConfState() @@ -837,7 +837,7 @@ int main(void) { finally: sconf.Finish() - def test_CustomChecks(self): + def test_CustomChecks(self) -> None: """Test Custom Checks """ def CheckCustom(test): |