diff options
Diffstat (limited to 'SCons/Variables')
-rw-r--r-- | SCons/Variables/BoolVariableTests.py | 6 | ||||
-rw-r--r-- | SCons/Variables/EnumVariable.py | 2 | ||||
-rw-r--r-- | SCons/Variables/EnumVariableTests.py | 10 | ||||
-rw-r--r-- | SCons/Variables/ListVariable.py | 4 | ||||
-rw-r--r-- | SCons/Variables/ListVariableTests.py | 6 | ||||
-rw-r--r-- | SCons/Variables/PackageVariableTests.py | 6 | ||||
-rw-r--r-- | SCons/Variables/PathVariableTests.py | 4 | ||||
-rw-r--r-- | SCons/Variables/VariablesTests.py | 44 | ||||
-rw-r--r-- | SCons/Variables/__init__.py | 4 |
9 files changed, 43 insertions, 43 deletions
diff --git a/SCons/Variables/BoolVariableTests.py b/SCons/Variables/BoolVariableTests.py index 868e7e085..9cf3ae137 100644 --- a/SCons/Variables/BoolVariableTests.py +++ b/SCons/Variables/BoolVariableTests.py @@ -27,7 +27,7 @@ import SCons.Errors import SCons.Variables class BoolVariableTestCase(unittest.TestCase): - def test_BoolVariable(self): + def test_BoolVariable(self) -> None: """Test BoolVariable creation""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.BoolVariable('test', 'test option help', False)) @@ -39,7 +39,7 @@ class BoolVariableTestCase(unittest.TestCase): assert o.validator is not None, o.validator assert o.converter is not None, o.converter - def test_converter(self): + def test_converter(self) -> None: """Test the BoolVariable converter""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.BoolVariable('test', 'test option help', False)) @@ -80,7 +80,7 @@ class BoolVariableTestCase(unittest.TestCase): caught = True assert caught, "did not catch expected ValueError for 'x'" - def test_validator(self): + def test_validator(self) -> None: """Test the BoolVariable validator""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.BoolVariable('test', 'test option help', False)) diff --git a/SCons/Variables/EnumVariable.py b/SCons/Variables/EnumVariable.py index e39eb0283..1a4f3fbde 100644 --- a/SCons/Variables/EnumVariable.py +++ b/SCons/Variables/EnumVariable.py @@ -56,7 +56,7 @@ def _validator(key, val, env, vals) -> None: 'Invalid value for option %s: %s. Valid values are: %s' % (key, val, vals)) -def EnumVariable(key, help, default, allowed_values, map={}, ignorecase=0) -> Tuple[str, str, str, Callable, Callable]: +def EnumVariable(key, help, default, allowed_values, map={}, ignorecase: int=0) -> Tuple[str, str, str, Callable, Callable]: """Return a tuple describing an enumaration SCons Variable. The input parameters describe an option with only certain values diff --git a/SCons/Variables/EnumVariableTests.py b/SCons/Variables/EnumVariableTests.py index 75bb54f1f..cc004f881 100644 --- a/SCons/Variables/EnumVariableTests.py +++ b/SCons/Variables/EnumVariableTests.py @@ -27,7 +27,7 @@ import SCons.Errors import SCons.Variables class EnumVariableTestCase(unittest.TestCase): - def test_EnumVariable(self): + def test_EnumVariable(self) -> None: """Test EnumVariable creation""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.EnumVariable('test', 'test option help', 0, @@ -41,7 +41,7 @@ class EnumVariableTestCase(unittest.TestCase): assert o.validator is not None, o.validator assert o.converter is not None, o.converter - def test_converter(self): + def test_converter(self) -> None: """Test the EnumVariable converter""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.EnumVariable('test', 'test option help', 0, @@ -127,7 +127,7 @@ class EnumVariableTestCase(unittest.TestCase): x = o2.converter(k) assert x == l[2], "o2 got %s, expected %s" % (x, l[2]) - def test_validator(self): + def test_validator(self) -> None: """Test the EnumVariable validator""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.EnumVariable('test0', 'test option help', 0, @@ -153,10 +153,10 @@ class EnumVariableTestCase(unittest.TestCase): o1 = opts.options[1] o2 = opts.options[2] - def valid(o, v): + def valid(o, v) -> None: o.validator('X', v, {}) - def invalid(o, v): + def invalid(o, v) -> None: caught = None try: o.validator('X', v, {}) diff --git a/SCons/Variables/ListVariable.py b/SCons/Variables/ListVariable.py index 7bd6053d0..bfa48f5eb 100644 --- a/SCons/Variables/ListVariable.py +++ b/SCons/Variables/ListVariable.py @@ -61,7 +61,7 @@ __all__ = ['ListVariable',] class _ListVariable(collections.UserList): - def __init__(self, initlist=None, allowedElems=None): + def __init__(self, initlist=None, allowedElems=None) -> None: if initlist is None: initlist = [] if allowedElems is None: @@ -87,7 +87,7 @@ class _ListVariable(collections.UserList): def __lt__(self, other): raise NotImplementedError - def __str__(self): + def __str__(self) -> str: if not len(self): return 'none' self.data.sort() diff --git a/SCons/Variables/ListVariableTests.py b/SCons/Variables/ListVariableTests.py index c73cef326..172a54ff0 100644 --- a/SCons/Variables/ListVariableTests.py +++ b/SCons/Variables/ListVariableTests.py @@ -28,7 +28,7 @@ import SCons.Errors import SCons.Variables class ListVariableTestCase(unittest.TestCase): - def test_ListVariable(self): + def test_ListVariable(self) -> None: """Test ListVariable creation""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.ListVariable('test', 'test option help', 'all', @@ -49,7 +49,7 @@ class ListVariableTestCase(unittest.TestCase): o = opts.options[0] assert o.default == 'one,three' - def test_converter(self): + def test_converter(self) -> None: """Test the ListVariable converter""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.ListVariable('test', 'test option help', 'all', @@ -108,7 +108,7 @@ class ListVariableTestCase(unittest.TestCase): caught = 1 assert caught, "did not catch expected ValueError" - def test_copy(self): + def test_copy(self) -> None: """Test copying a ListVariable like an Environment would""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.ListVariable('test', 'test option help', 'all', diff --git a/SCons/Variables/PackageVariableTests.py b/SCons/Variables/PackageVariableTests.py index 988fbe01d..ad5ba0612 100644 --- a/SCons/Variables/PackageVariableTests.py +++ b/SCons/Variables/PackageVariableTests.py @@ -29,7 +29,7 @@ import SCons.Variables import TestCmd class PackageVariableTestCase(unittest.TestCase): - def test_PackageVariable(self): + def test_PackageVariable(self) -> None: """Test PackageVariable creation""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.PackageVariable('test', 'test option help', '/default/path')) @@ -41,7 +41,7 @@ class PackageVariableTestCase(unittest.TestCase): assert o.validator is not None, o.validator assert o.converter is not None, o.converter - def test_converter(self): + def test_converter(self) -> None: """Test the PackageVariable converter""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.PackageVariable('test', 'test option help', '/default/path')) @@ -82,7 +82,7 @@ class PackageVariableTestCase(unittest.TestCase): x = o.converter(str(False)) assert not x, "converter returned a string when given str(False)" - def test_validator(self): + def test_validator(self) -> None: """Test the PackageVariable validator""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.PackageVariable('test', 'test option help', '/default/path')) diff --git a/SCons/Variables/PathVariableTests.py b/SCons/Variables/PathVariableTests.py index a9aa8f035..aacfc9ea7 100644 --- a/SCons/Variables/PathVariableTests.py +++ b/SCons/Variables/PathVariableTests.py @@ -30,7 +30,7 @@ import SCons.Variables import TestCmd class PathVariableTestCase(unittest.TestCase): - def test_PathVariable(self): + def test_PathVariable(self) -> None: """Test PathVariable creation""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.PathVariable('test', @@ -164,7 +164,7 @@ class PathVariableTestCase(unittest.TestCase): except: raise Exception("did not catch expected UserError") - def test_PathAccept(self): + def test_PathAccept(self) -> None: """Test the PathAccept validator""" opts = SCons.Variables.Variables() opts.Add(SCons.Variables.PathVariable('test', diff --git a/SCons/Variables/VariablesTests.py b/SCons/Variables/VariablesTests.py index 4672cdd8a..fcc1e1417 100644 --- a/SCons/Variables/VariablesTests.py +++ b/SCons/Variables/VariablesTests.py @@ -32,24 +32,24 @@ from SCons.Util import cmp class Environment: - def __init__(self): + def __init__(self) -> None: self.dict = {} def subst(self, x): return SCons.Subst.scons_subst(x, self, gvars=self.dict) - def __setitem__(self, key, value): + def __setitem__(self, key, value) -> None: self.dict[key] = value def __getitem__(self, key): return self.dict[key] - def __contains__(self, key): + def __contains__(self, key) -> bool: return key in self.dict -def check(key, value, env): +def check(key, value, env) -> None: assert int(value) == 6 * 9, "key %s = %s" % (key, repr(value)) # Check saved option file by executing and comparing against # the expected dictionary -def checkSave(file, expected): +def checkSave(file, expected) -> None: gdict = {} ldict = {} with open(file, 'r') as f: @@ -59,7 +59,7 @@ def checkSave(file, expected): class VariablesTestCase(unittest.TestCase): - def test_keys(self): + def test_keys(self) -> None: """Test the Variables.keys() method""" opts = SCons.Variables.Variables() @@ -72,7 +72,7 @@ class VariablesTestCase(unittest.TestCase): keys = list(opts.keys()) assert keys == ['VAR1', 'VAR2'], keys - def test_Add(self): + def test_Add(self) -> None: """Test adding to a Variables object""" opts = SCons.Variables.Variables() @@ -96,7 +96,7 @@ class VariablesTestCase(unittest.TestCase): assert o.default == "42" o.validator(o.key, o.converter(o.default), {}) - def test_it(var, opts=opts): + def test_it(var, opts=opts) -> None: exc_caught = None try: opts.Add(var) @@ -107,7 +107,7 @@ class VariablesTestCase(unittest.TestCase): test_it('foo-bar') test_it('foo.bar') - def test_AddVariables(self): + def test_AddVariables(self) -> None: """Test adding a list of options to a Variables object""" opts = SCons.Variables.Variables() @@ -131,7 +131,7 @@ class VariablesTestCase(unittest.TestCase): assert o.default == "42", o.default o.validator(o.key, o.converter(o.default), {}) - def test_Update(self): + def test_Update(self) -> None: """Test updating an Environment""" # Test that a default value is validated correctly. @@ -270,7 +270,7 @@ class VariablesTestCase(unittest.TestCase): opts.Update(env, {}) assert 'ANSWER' not in env - def test_noaggregation(self): + def test_noaggregation(self) -> None: """Test that the 'files' and 'args' attributes of the Variables class don't aggregate entries from one instance to another. This used to be a bug in SCons version 2.4.1 and earlier. @@ -286,7 +286,7 @@ class VariablesTestCase(unittest.TestCase): assert len(nopts.files) == 0 assert len(nopts.args) == 0 - def test_args(self): + def test_args(self) -> None: """Test updating an Environment with arguments overridden""" # Test that a bad (command-line) argument is used @@ -343,7 +343,7 @@ class VariablesTestCase(unittest.TestCase): opts.Update(env, {'ANSWER':42}) assert env['ANSWER'] == 54 - def test_Save(self): + def test_Save(self) -> None: """Testing saving Variables""" test = TestSCons.TestSCons() @@ -396,9 +396,9 @@ class VariablesTestCase(unittest.TestCase): # Test against some old bugs class Foo: - def __init__(self, x): + def __init__(self, x) -> None: self.x = x - def __str__(self): + def __str__(self) -> str: return self.x test = TestSCons.TestSCons() @@ -426,7 +426,7 @@ class VariablesTestCase(unittest.TestCase): 'THIS_ALSO_BROKE' : "\\Escape\nSequences\t", 'THIS_SHOULD_WORK' : 'baz' }) - def test_GenerateHelpText(self): + def test_GenerateHelpText(self) -> None: """Test generating the default format help text""" opts = SCons.Variables.Variables() @@ -507,11 +507,11 @@ A: a - alpha test expectBackwards, ) - def test_FormatVariableHelpText(self): + def test_FormatVariableHelpText(self) -> None: """Test generating custom format help text""" opts = SCons.Variables.Variables() - def my_format(env, opt, help, default, actual, aliases): + def my_format(env, opt, help, default, actual, aliases) -> str: return '%s %s %s %s %s\n' % (opt, default, actual, help, aliases) opts.FormatVariableHelpText = my_format @@ -554,7 +554,7 @@ B 42 54 b - alpha test ['B'] text = opts.GenerateHelpText(env, sort=cmp) assert text == expectAlpha, text - def test_Aliases(self): + def test_Aliases(self) -> None: """Test option aliases""" # test alias as a tuple opts = SCons.Variables.Variables() @@ -595,7 +595,7 @@ B 42 54 b - alpha test ['B'] class UnknownVariablesTestCase(unittest.TestCase): - def test_unknown(self): + def test_unknown(self) -> None: """Test the UnknownVariables() method""" opts = SCons.Variables.Variables() @@ -615,7 +615,7 @@ class UnknownVariablesTestCase(unittest.TestCase): assert r == {'UNKNOWN' : 'unknown'}, r assert env['ANSWER'] == 'answer', env['ANSWER'] - def test_AddOptionUpdatesUnknown(self): + def test_AddOptionUpdatesUnknown(self) -> None: """Test updating of the 'unknown' dict""" opts = SCons.Variables.Variables() @@ -650,7 +650,7 @@ class UnknownVariablesTestCase(unittest.TestCase): assert len(r) == 0, r assert env['ADDEDLATER'] == 'added', env['ADDEDLATER'] - def test_AddOptionWithAliasUpdatesUnknown(self): + def test_AddOptionWithAliasUpdatesUnknown(self) -> None: """Test updating of the 'unknown' dict (with aliases)""" opts = SCons.Variables.Variables() diff --git a/SCons/Variables/__init__.py b/SCons/Variables/__init__.py index fc78de553..4d40986bd 100644 --- a/SCons/Variables/__init__.py +++ b/SCons/Variables/__init__.py @@ -57,7 +57,7 @@ class Variables: """ instance = None - def __init__(self, files=None, args=None, is_global=True): + def __init__(self, files=None, args=None, is_global: bool=True) -> None: if args is None: args = {} self.options = [] @@ -76,7 +76,7 @@ class Variables: if not Variables.instance: Variables.instance=self - def _do_add(self, key, help="", default=None, validator=None, converter=None, **kwargs) -> None: + def _do_add(self, key, help: str="", default=None, validator=None, converter=None, **kwargs) -> None: class Variable: pass |