diff --git a/multipy/runtime/test_deploy_python.py b/multipy/runtime/test_deploy_python.py index 5ba7667b..b86a42b7 100644 --- a/multipy/runtime/test_deploy_python.py +++ b/multipy/runtime/test_deploy_python.py @@ -9,6 +9,7 @@ import sys from pathlib import Path + # we've taken steps to clear out the embedded python environment, # so we have to go searching for real python to figure out where its libraries are installed. def python_path(cpath): diff --git a/scripts/auto_copyright.py b/scripts/auto_copyright.py index d017f0c9..5a69114c 100755 --- a/scripts/auto_copyright.py +++ b/scripts/auto_copyright.py @@ -9,21 +9,25 @@ import sys from typing import List, Tuple -COPYRIGHT_NOTICE_PYTHON: str = """ +COPYRIGHT_NOTICE_PYTHON: str = ( + """ # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """.strip() +) -COPYRIGHT_NOTICE_C: str = """ +COPYRIGHT_NOTICE_C: str = ( + """ // Copyright (c) Meta Platforms, Inc. and affiliates. // All rights reserved. // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. """.strip() +) def get_all_files_with_extension(directories: List[str], extensions: Tuple[str]): diff --git a/scripts/linter/adapters/black_linter.py b/scripts/linter/adapters/black_linter.py index 8459b6a1..5d2b5bab 100644 --- a/scripts/linter/adapters/black_linter.py +++ b/scripts/linter/adapters/black_linter.py @@ -199,11 +199,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/clangformat_linter.py b/scripts/linter/adapters/clangformat_linter.py index 3445dee4..0b0a59fe 100644 --- a/scripts/linter/adapters/clangformat_linter.py +++ b/scripts/linter/adapters/clangformat_linter.py @@ -201,11 +201,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/clangtidy_linter.py b/scripts/linter/adapters/clangtidy_linter.py index d7e19452..4217293d 100644 --- a/scripts/linter/adapters/clangtidy_linter.py +++ b/scripts/linter/adapters/clangtidy_linter.py @@ -22,6 +22,7 @@ PYTORCH_ROOT = result.stdout.decode("utf-8").strip() IS_WINDOWS: bool = os.name == "nt" + # Returns '/usr/local/include/python' def get_python_include_dir() -> str: return gp()["include"] @@ -149,7 +150,7 @@ def check_file( proc = run_command( [binary, f"-p={build_dir}", *include_args, filename], ) - except (OSError) as err: + except OSError as err: return [ LintMessage( path=filename, @@ -178,9 +179,12 @@ def check_file( name=match["code"], description=match["message"], line=int(match["line"]), - char=int(match["column"]) - if match["column"] is not None and not match["column"].startswith("-") - else None, + char=( + int(match["column"]) + if match["column"] is not None + and not match["column"].startswith("-") + else None + ), code="CLANGTIDY", severity=severities.get(match["severity"], LintSeverity.ERROR), original=None, @@ -225,11 +229,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/exec_linter.py b/scripts/linter/adapters/exec_linter.py index f00dc60a..0828dadf 100644 --- a/scripts/linter/adapters/exec_linter.py +++ b/scripts/linter/adapters/exec_linter.py @@ -1,6 +1,7 @@ """ EXEC: Ensure that source files are not executable. """ + import argparse import json import logging @@ -68,11 +69,11 @@ def check_file(filename: str) -> Optional[LintMessage]: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/flake8_linter.py b/scripts/linter/adapters/flake8_linter.py index 737bacf5..cb54c122 100644 --- a/scripts/linter/adapters/flake8_linter.py +++ b/scripts/linter/adapters/flake8_linter.py @@ -252,9 +252,11 @@ def check_files( try: proc = run_command( [sys.executable, "-mflake8", "--exit-zero"] + filenames, - extra_env={"FLAKE8_PLUGINS_PATH": flake8_plugins_path} - if flake8_plugins_path - else None, + extra_env=( + {"FLAKE8_PLUGINS_PATH": flake8_plugins_path} + if flake8_plugins_path + else None + ), retries=retries, ) except (OSError, subprocess.CalledProcessError) as err: @@ -295,9 +297,11 @@ def check_files( get_issue_documentation_url(match["code"]), ), line=int(match["line"]), - char=int(match["column"]) - if match["column"] is not None and not match["column"].startswith("-") - else None, + char=( + int(match["column"]) + if match["column"] is not None and not match["column"].startswith("-") + else None + ), code="FLAKE8", severity=severities.get(match["code"]) or get_issue_severity(match["code"]), original=None, @@ -341,11 +345,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/grep_linter.py b/scripts/linter/adapters/grep_linter.py index f6bd714e..46d62991 100644 --- a/scripts/linter/adapters/grep_linter.py +++ b/scripts/linter/adapters/grep_linter.py @@ -210,11 +210,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/mypy_linter.py b/scripts/linter/adapters/mypy_linter.py index 65ee8850..98db4718 100644 --- a/scripts/linter/adapters/mypy_linter.py +++ b/scripts/linter/adapters/mypy_linter.py @@ -115,9 +115,11 @@ def check_files( name=match["code"], description=match["message"], line=int(match["line"]), - char=int(match["column"]) - if match["column"] is not None and not match["column"].startswith("-") - else None, + char=( + int(match["column"]) + if match["column"] is not None and not match["column"].startswith("-") + else None + ), code="MYPY", severity=severities.get(match["severity"], LintSeverity.ERROR), original=None, @@ -157,11 +159,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/newlines_linter.py b/scripts/linter/adapters/newlines_linter.py index a2cb1c5c..5eef9bf9 100644 --- a/scripts/linter/adapters/newlines_linter.py +++ b/scripts/linter/adapters/newlines_linter.py @@ -1,6 +1,7 @@ """ NEWLINE: Checks files to make sure there are no trailing newlines. """ + import argparse import json import logging @@ -145,11 +146,11 @@ def check_file(filename: str) -> Optional[LintMessage]: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, ) diff --git a/scripts/linter/adapters/pip_init.py b/scripts/linter/adapters/pip_init.py index f177a920..3a37745f 100644 --- a/scripts/linter/adapters/pip_init.py +++ b/scripts/linter/adapters/pip_init.py @@ -1,6 +1,7 @@ """ Initializer script that installs stuff to pip. """ + import argparse import logging import os diff --git a/scripts/linter/adapters/s3_init.py b/scripts/linter/adapters/s3_init.py index 65fcef4b..5897166a 100644 --- a/scripts/linter/adapters/s3_init.py +++ b/scripts/linter/adapters/s3_init.py @@ -189,9 +189,11 @@ def download( DRY_RUN = True logging.basicConfig( - format="[DRY_RUN] %(levelname)s: %(message)s" - if DRY_RUN - else "%(levelname)s: %(message)s", + format=( + "[DRY_RUN] %(levelname)s: %(message)s" + if DRY_RUN + else "%(levelname)s: %(message)s" + ), level=logging.INFO, stream=sys.stderr, ) diff --git a/scripts/linter/adapters/ufmt_linter.py b/scripts/linter/adapters/ufmt_linter.py index 7174e832..9e89c094 100644 --- a/scripts/linter/adapters/ufmt_linter.py +++ b/scripts/linter/adapters/ufmt_linter.py @@ -115,11 +115,11 @@ def main() -> None: logging.basicConfig( format="<%(threadName)s:%(levelname)s> %(message)s", - level=logging.NOTSET - if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO, + level=( + logging.NOTSET + if args.verbose + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + ), stream=sys.stderr, )