diff options
Diffstat (limited to 'SCons/Util')
-rw-r--r-- | SCons/Util/__init__.py | 56 | ||||
-rw-r--r-- | SCons/Util/envs.py | 10 | ||||
-rw-r--r-- | SCons/Util/hashes.py | 6 | ||||
-rw-r--r-- | SCons/Util/types.py | 12 |
4 files changed, 42 insertions, 42 deletions
diff --git a/SCons/Util/__init__.py b/SCons/Util/__init__.py index 2760298b5..655c5adc8 100644 --- a/SCons/Util/__init__.py +++ b/SCons/Util/__init__.py @@ -183,10 +183,10 @@ class NodeList(UserList): ['foo', 'bar'] """ - def __bool__(self): + def __bool__(self) -> bool: return bool(self.data) - def __str__(self): + def __str__(self) -> str: return ' '.join(map(str, self.data)) def __iter__(self): @@ -214,7 +214,7 @@ class DisplayEngine: print_it = True - def __call__(self, text, append_newline=1): + def __call__(self, text, append_newline: int=1) -> None: if not self.print_it: return @@ -231,14 +231,14 @@ class DisplayEngine: with suppress(IOError): sys.stdout.write(str(text)) - def set_mode(self, mode): + def set_mode(self, mode) -> None: self.print_it = mode display = DisplayEngine() # TODO: W0102: Dangerous default value [] as argument (dangerous-default-value) -def render_tree(root, child_func, prune=0, margin=[0], visited=None) -> str: +def render_tree(root, child_func, prune: int=0, margin=[0], visited=None) -> str: """Render a tree of nodes into an ASCII tree view. Args: @@ -302,8 +302,8 @@ BOX_HORIZ_DOWN = chr(0x252c) # '┬' def print_tree( root, child_func, - prune=0, - showtags=False, + prune: int=0, + showtags: bool=False, margin=[0], visited=None, lastChild: bool = False, @@ -432,7 +432,7 @@ def do_flatten( isinstance=isinstance, StringTypes=StringTypes, SequenceTypes=SequenceTypes, -): # pylint: disable=redefined-outer-name,redefined-builtin +) -> None: # pylint: disable=redefined-outer-name,redefined-builtin for item in sequence: if isinstance(item, StringTypes) or not isinstance(item, SequenceTypes): result.append(item) @@ -564,7 +564,7 @@ class Proxy: __str__ = Delegate('__str__') """ - def __init__(self, subject): + def __init__(self, subject) -> None: """Wrap an object as a Proxy object""" self._subject = subject @@ -593,7 +593,7 @@ class Delegate: class Foo(Proxy): __str__ = Delegate('__str__') """ - def __init__(self, attribute): + def __init__(self, attribute) -> None: self.attribute = attribute def __get__(self, obj, cls): @@ -858,7 +858,7 @@ class CLVar(UserList): 6 ['--some', '--opts', 'and', 'args', 'strips', 'spaces'] """ - def __init__(self, initlist=None): + def __init__(self, initlist=None) -> None: super().__init__(Split(initlist if initlist is not None else [])) def __add__(self, other): @@ -870,7 +870,7 @@ class CLVar(UserList): def __iadd__(self, other): return super().__iadd__(CLVar(other)) - def __str__(self): + def __str__(self) -> str: # Some cases the data can contain Nodes, so make sure they # processed to string before handing them over to join. return ' '.join([str(d) for d in self.data]) @@ -923,7 +923,7 @@ else: return os.path.normcase(s1) != os.path.normcase(s2) -def adjustixes(fname, pre, suf, ensure_suffix=False) -> str: +def adjustixes(fname, pre, suf, ensure_suffix: bool=False) -> str: """Adjust filename prefixes and suffixes as needed. Add `prefix` to `fname` if specified. @@ -1050,7 +1050,7 @@ class LogicalLines: Allows us to read all "logical" lines at once from a given file object. """ - def __init__(self, fileobj): + def __init__(self, fileobj) -> None: self.fileobj = fileobj def readlines(self): @@ -1064,16 +1064,16 @@ class UniqueList(UserList): up on access by those methods which need to act on a unique list to be correct. That means things like "in" don't have to eat the uniquing time. """ - def __init__(self, initlist=None): + def __init__(self, initlist=None) -> None: super().__init__(initlist) self.unique = True - def __make_unique(self): + def __make_unique(self) -> None: if not self.unique: self.data = uniquer_hashables(self.data) self.unique = True - def __repr__(self): + def __repr__(self) -> str: self.__make_unique() return super().__repr__() @@ -1103,7 +1103,7 @@ class UniqueList(UserList): # __contains__ doesn't need to worry about uniquing, inherit - def __len__(self): + def __len__(self) -> int: self.__make_unique() return super().__len__() @@ -1111,7 +1111,7 @@ class UniqueList(UserList): self.__make_unique() return super().__getitem__(i) - def __setitem__(self, i, item): + def __setitem__(self, i, item) -> None: super().__setitem__(i, item) self.unique = False @@ -1147,11 +1147,11 @@ class UniqueList(UserList): result.unique = False return result - def append(self, item): + def append(self, item) -> None: super().append(item) self.unique = False - def insert(self, i, item): + def insert(self, i, item) -> None: super().insert(i, item) self.unique = False @@ -1163,7 +1163,7 @@ class UniqueList(UserList): self.__make_unique() return super().index(item, *args) - def reverse(self): + def reverse(self) -> None: self.__make_unique() super().reverse() @@ -1172,7 +1172,7 @@ class UniqueList(UserList): self.__make_unique() return super().sort(*args, **kwds) - def extend(self, other): + def extend(self, other) -> None: super().extend(other) self.unique = False @@ -1182,10 +1182,10 @@ class Unbuffered: Delegates everything else to the wrapped object. """ - def __init__(self, file): + def __init__(self, file) -> None: self.file = file - def write(self, arg): + def write(self, arg) -> None: # Stdout might be connected to a pipe that has been closed # by now. The most likely reason for the pipe being closed # is that the user has press ctrl-c. It this is the case, @@ -1197,7 +1197,7 @@ class Unbuffered: self.file.write(arg) self.file.flush() - def writelines(self, arg): + def writelines(self, arg) -> None: with suppress(IOError): self.file.writelines(arg) self.file.flush() @@ -1244,7 +1244,7 @@ def print_time(): return print_time -def wait_for_process_to_die(pid): +def wait_for_process_to_die(pid) -> None: """ Wait for specified process to die, or alternatively kill it NOTE: This function operates best with psutil pypi package @@ -1278,7 +1278,7 @@ def wait_for_process_to_die(pid): # From: https://stackoverflow.com/questions/1741972/how-to-use-different-formatters-with-the-same-logging-handler-in-python class DispatchingFormatter(Formatter): - def __init__(self, formatters, default_formatter): + def __init__(self, formatters, default_formatter) -> None: self._formatters = formatters self._default_formatter = default_formatter diff --git a/SCons/Util/envs.py b/SCons/Util/envs.py index 963c963a8..64e728a8c 100644 --- a/SCons/Util/envs.py +++ b/SCons/Util/envs.py @@ -16,7 +16,7 @@ from .types import is_List, is_Tuple, is_String def PrependPath( - oldpath, newpath, sep=os.pathsep, delete_existing=True, canonicalize=None + oldpath, newpath, sep=os.pathsep, delete_existing: bool=True, canonicalize=None ) -> Union[list, str]: """Prepend *newpath* path elements to *oldpath*. @@ -102,7 +102,7 @@ def PrependPath( def AppendPath( - oldpath, newpath, sep=os.pathsep, delete_existing=True, canonicalize=None + oldpath, newpath, sep=os.pathsep, delete_existing: bool=True, canonicalize=None ) -> Union[list, str]: """Append *newpath* path elements to *oldpath*. @@ -187,7 +187,7 @@ def AppendPath( return sep.join(paths) -def AddPathIfNotExists(env_dict, key, path, sep=os.pathsep): +def AddPathIfNotExists(env_dict, key, path, sep=os.pathsep) -> None: """Add a path element to a construction variable. `key` is looked up in `env_dict`, and `path` is added to it if it @@ -229,7 +229,7 @@ class MethodWrapper: a new underlying object being copied (without which we wouldn't need to save that info). """ - def __init__(self, obj, method, name=None): + def __init__(self, obj, method, name=None) -> None: if name is None: name = method.__name__ self.object = obj @@ -265,7 +265,7 @@ class MethodWrapper: # is not needed, the remaining bit is now used inline in AddMethod. -def AddMethod(obj, function, name=None): +def AddMethod(obj, function, name=None) -> None: """Add a method to an object. Adds *function* to *obj* if *obj* is a class object. diff --git a/SCons/Util/hashes.py b/SCons/Util/hashes.py index b97cd4d07..e14da012a 100644 --- a/SCons/Util/hashes.py +++ b/SCons/Util/hashes.py @@ -314,7 +314,7 @@ def hash_signature(s, hash_format=None): return m.hexdigest() -def hash_file_signature(fname, chunksize=65536, hash_format=None): +def hash_file_signature(fname, chunksize: int=65536, hash_format=None): """ Generate the md5 signature of a file @@ -358,7 +358,7 @@ def hash_collect(signatures, hash_format=None): _MD5_WARNING_SHOWN = False -def _show_md5_warning(function_name): +def _show_md5_warning(function_name) -> None: """Shows a deprecation warning for various MD5 functions.""" global _MD5_WARNING_SHOWN @@ -380,7 +380,7 @@ def MD5signature(s): return hash_signature(s) -def MD5filesignature(fname, chunksize=65536): +def MD5filesignature(fname, chunksize: int=65536): """Deprecated. Use :func:`hash_file_signature` instead.""" _show_md5_warning("MD5filesignature") diff --git a/SCons/Util/types.py b/SCons/Util/types.py index 2071217e9..44aae5f33 100644 --- a/SCons/Util/types.py +++ b/SCons/Util/types.py @@ -115,16 +115,16 @@ class Null: cls._instance = super(Null, cls).__new__(cls, *args, **kwargs) return cls._instance - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: pass def __call__(self, *args, **kwargs): return self - def __repr__(self): + def __repr__(self) -> str: return f"Null(0x{id(self):08X})" - def __bool__(self): + def __bool__(self) -> bool: return False def __getattr__(self, name): @@ -140,7 +140,7 @@ class Null: class NullSeq(Null): """A Null object that can also be iterated over.""" - def __len__(self): + def __len__(self) -> int: return 0 def __iter__(self): @@ -245,7 +245,7 @@ def to_String_for_signature( # pylint: disable=redefined-outer-name,redefined-b return f() -def get_env_bool(env, name, default=False) -> bool: +def get_env_bool(env, name, default: bool=False) -> bool: """Convert a construction variable to bool. If the value of *name* in *env* is 'true', 'yes', 'y', 'on' (case @@ -279,7 +279,7 @@ def get_env_bool(env, name, default=False) -> bool: return default -def get_os_env_bool(name, default=False) -> bool: +def get_os_env_bool(name, default: bool=False) -> bool: """Convert an environment variable to bool. Conversion is the same as for :func:`get_env_bool`. |