From dd4694c16d5750aee679b97ce59b7de70f4724c0 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 18 Dec 2022 11:50:11 -0700 Subject: Util splitup: do some work to quiet sider Adds a .flake8 file to somewhat control the checking. Signed-off-by: Mats Wichmann --- .flake8 | 22 ++++++++++++++++++++++ SCons/Util/__init__.py | 17 ++++++++--------- SCons/Util/hashes.py | 6 +++--- SCons/Util/types.py | 5 +++-- 4 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..d10d72d --- /dev/null +++ b/.flake8 @@ -0,0 +1,22 @@ +[flake8] +show-source = True +# don't complain about work black has done +max-line-length = 88 +extend-exclude = + bin, + bench, + doc, + src, + template, + testing, + test, + timings, + SCons/Tool/docbook/docbook-xsl-1.76.1, + bootstrap.py, + runtest.py +extend-ignore = + E302, + E305 +per-file-ignores = + # module symbols made available for compat - ignore "unused" warns + SCons/Util/__init__.py: F401 diff --git a/SCons/Util/__init__.py b/SCons/Util/__init__.py index 6b48d05..0281e1e 100644 --- a/SCons/Util/__init__.py +++ b/SCons/Util/__init__.py @@ -383,7 +383,7 @@ def print_tree( cross = BOX_VERT_RIGHT + BOX_HORIZ # sign used to point to the leaf. # check if this is the last leaf of the branch if lastChild: - #if this if the last leaf, then terminate: + # if this if the last leaf, then terminate: cross = BOX_UP_RIGHT + BOX_HORIZ # sign for the last leaf # if this branch has children then split it @@ -395,7 +395,7 @@ def print_tree( cross += BOX_HORIZ_DOWN if prune and rname in visited and children: - sys.stdout.write(''.join(tags + margins + [cross,'[', rname, ']']) + '\n') + sys.stdout.write(''.join(tags + margins + [cross, '[', rname, ']']) + '\n') return sys.stdout.write(''.join(tags + margins + [cross, rname]) + '\n') @@ -892,7 +892,7 @@ class Selector(OrderedDict): # Try to perform Environment substitution on the keys of # the dictionary before giving up. s_dict = {} - for (k,v) in self.items(): + for (k, v) in self.items(): if k is not None: s_k = env.subst(k) if s_k in s_dict: @@ -901,7 +901,7 @@ class Selector(OrderedDict): # and a variable suffix contains this literal, # the literal wins and we don't raise an error. raise KeyError(s_dict[s_k][0], k, s_k) - s_dict[s_k] = (k,v) + s_dict[s_k] = (k, v) try: return s_dict[ext][1] except KeyError: @@ -947,7 +947,6 @@ def adjustixes(fname, pre, suf, ensure_suffix=False) -> str: return fname - # From Tim Peters, # https://code.activestate.com/recipes/52560 # ASPN: Python Cookbook: Remove duplicates from a sequence @@ -1212,9 +1211,9 @@ def make_path_relative(path) -> str: drive_s, path = os.path.splitdrive(path) if not drive_s: - path=re.compile(r"/*(.*)").findall(path)[0] + path = re.compile(r"/*(.*)").findall(path)[0] else: - path=path[1:] + path = path[1:] assert not os.path.isabs(path), path return path @@ -1263,7 +1262,7 @@ def wait_for_process_to_die(pid): if sys.platform == 'win32': import ctypes # pylint: disable=import-outside-toplevel PROCESS_QUERY_INFORMATION = 0x1000 - processHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION, 0,pid) + processHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid) if processHandle == 0: break ctypes.windll.kernel32.CloseHandle(processHandle) @@ -1290,7 +1289,7 @@ class DispatchingFormatter(Formatter): def sanitize_shell_env(execution_env: dict) -> dict: """Sanitize all values in *execution_env* - The execution environment (typically comes from (env['ENV']) is + The execution environment (typically comes from (env['ENV']) is propagated to the shell, and may need to be cleaned first. Args: diff --git a/SCons/Util/hashes.py b/SCons/Util/hashes.py index 4771c44..b97cd4d 100644 --- a/SCons/Util/hashes.py +++ b/SCons/Util/hashes.py @@ -212,9 +212,9 @@ def set_hash_format(hash_format, hashlib_used=hashlib, sys_used=sys): ) # pylint: disable=import-outside-toplevel raise UserError( - 'Hash format "%s" is not available in your Python interpreter. ' - 'Expected to be supported algorithm by set_allowed_viable_default_hashes, ' - 'Assertion error in SCons.' % hash_format_lower + f'Hash format "{hash_format_lower}" is not available in your ' + 'Python interpreter. Expected to be supported algorithm by ' + 'set_allowed_viable_default_hashes. Assertion error in SCons.' ) else: # Set the default hash format based on what is available, defaulting diff --git a/SCons/Util/types.py b/SCons/Util/types.py index 53dacd1..9aef13e 100644 --- a/SCons/Util/types.py +++ b/SCons/Util/types.py @@ -230,8 +230,9 @@ def to_String_for_signature( # pylint: disable=redefined-outer-name,redefined-b except AttributeError: if isinstance(obj, dict): # pprint will output dictionary in key sorted order - # with py3.5 the order was randomized. In general depending on dictionary order - # which was undefined until py3.6 (where it's by insertion order) was not wise. + # with py3.5 the order was randomized. Depending on dict order + # which was undefined until py3.6 (where it's by insertion order) + # was not wise. # TODO: Change code when floor is raised to PY36 return pprint.pformat(obj, width=1000000) return to_String_for_subst(obj) -- cgit v0.12