From b2e88c8241f613eb10c4267bc19e1584cf05ca5d Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Thu, 1 Feb 2024 09:25:03 -0800 Subject: [PATCH 01/19] chore(ci): bump black version to 24.1.1 --- .lintrunner.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintrunner.toml b/.lintrunner.toml index ab29611..a1c9981 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -166,7 +166,7 @@ init_command = [ 'run', 'pip_init', '--dry-run={{DRYRUN}}', - 'black==22.10.0', + 'black==24.1.1', 'isort==5.10.1', ] is_formatter = true From 76fc1708e1a4c439fe3cdbe906fa778063c27998 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 15:30:18 +0000 Subject: [PATCH 02/19] Use checkinput? --- lintrunner_adapters/adapters/black_isort_linter.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 5f1beb3..27eb71c 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -37,10 +37,8 @@ def check_file( timeout=timeout, check=True, ) - import_sorted = proc.stdout # Pipe isort's result to black - proc = run_command( - [ + replacement = subprocess.check_output([ sys.executable, "-mblack", *(("--pyi",) if filename.endswith(".pyi") else ()), @@ -50,11 +48,8 @@ def check_file( filename, "-", ], - stdin=None, - input=import_sorted, - retries=retries, + stdin=proc.stdout, timeout=timeout, - check=True, ) except subprocess.TimeoutExpired: return [ @@ -103,7 +98,6 @@ def check_file( ) ] - replacement = proc.stdout if original == replacement: return [] From 5489bf2eb8d8614ececfeaa2415969ff55dcbad7 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 15:30:26 +0000 Subject: [PATCH 03/19] stdin --- lintrunner_adapters/adapters/black_isort_linter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 27eb71c..f467752 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -6,6 +6,7 @@ import argparse import concurrent.futures +import io import logging import os import subprocess @@ -37,8 +38,10 @@ def check_file( timeout=timeout, check=True, ) + import_sorted_file = io.BytesIO(proc.stdout) # Pipe isort's result to black - replacement = subprocess.check_output([ + proc = run_command( + [ sys.executable, "-mblack", *(("--pyi",) if filename.endswith(".pyi") else ()), @@ -48,8 +51,10 @@ def check_file( filename, "-", ], - stdin=proc.stdout, + stdin=import_sorted_file, + retries=retries, timeout=timeout, + check=True, ) except subprocess.TimeoutExpired: return [ @@ -98,6 +103,7 @@ def check_file( ) ] + replacement = proc.stdout if original == replacement: return [] From 119f0ec4d825316d97bc7ad285daf1bfc0190a98 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 15:42:56 +0000 Subject: [PATCH 04/19] Use Popen --- .../adapters/black_isort_linter.py | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index f467752..4fe8c29 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -6,14 +6,13 @@ import argparse import concurrent.futures -import io import logging import os import subprocess import sys import lintrunner_adapters -from lintrunner_adapters import LintMessage, LintSeverity, as_posix, run_command +from lintrunner_adapters import LintMessage, LintSeverity, as_posix LINTER_CODE = "BLACK-ISORT" @@ -31,16 +30,14 @@ def check_file( with open(filename, "rb") as f: # Run isort first then black so we get consistent result # even if isort is not using the black profile - proc = run_command( + proc = subprocess.Popen( [sys.executable, "-misort", "-"], stdin=f, - retries=retries, - timeout=timeout, - check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) - import_sorted_file = io.BytesIO(proc.stdout) - # Pipe isort's result to black - proc = run_command( + # Launch second process and connect it to the first one + black_proc = subprocess.Popen( [ sys.executable, "-mblack", @@ -51,11 +48,14 @@ def check_file( filename, "-", ], - stdin=import_sorted_file, - retries=retries, - timeout=timeout, - check=True, + stdin=proc.stdout, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) + + # Let stream flow between them + replacement, _ = black_proc.communicate(timeout=timeout) + except subprocess.TimeoutExpired: return [ LintMessage( @@ -81,7 +81,7 @@ def check_file( line=None, char=None, code=LINTER_CODE, - severity=LintSeverity.ADVICE, + severity=LintSeverity.ERROR, name="command-failed", original=None, replacement=None, @@ -103,7 +103,6 @@ def check_file( ) ] - replacement = proc.stdout if original == replacement: return [] From 3082f370bdfaf1473f4d510fc2f7d2f4123e9568 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 15:43:22 +0000 Subject: [PATCH 05/19] Do not retry for now --- lintrunner_adapters/adapters/black_isort_linter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 4fe8c29..2477c04 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -24,6 +24,8 @@ def check_file( *, fast: bool = False, ) -> list[LintMessage]: + del retries # Unused + try: with open(filename, "rb") as f: original = f.read() From 6c9ebd0a4bd4f4ba5832baada0aa214a5325c62b Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 15:47:41 +0000 Subject: [PATCH 06/19] Format --- examples/pytorch/black_isort_linter.py | 10 +++---- examples/pytorch/black_linter.py | 10 +++---- examples/pytorch/clangformat_linter.py | 10 +++---- examples/pytorch/clangtidy_linter.py | 19 ++++++++------ examples/pytorch/exec_linter.py | 10 +++---- examples/pytorch/flake8_linter.py | 26 +++++++++++-------- examples/pytorch/grep_linter.py | 10 +++---- examples/pytorch/isort_linter.py | 10 +++---- examples/pytorch/mypy_linter.py | 18 +++++++------ examples/pytorch/newlines_linter.py | 10 +++---- examples/pytorch/s3_init.py | 8 +++--- examples/pytorch/ufmt_linter.py | 10 +++---- lintrunner_adapters/__init__.py | 1 + lintrunner_adapters/__main__.py | 1 + .../adapters/add_trailing_comma_linter.py | 10 +++---- .../adapters/black_isort_linter.py | 10 +++---- lintrunner_adapters/adapters/black_linter.py | 10 +++---- .../adapters/clangformat_linter.py | 10 +++---- lintrunner_adapters/adapters/clippy_linter.py | 10 +++---- .../adapters/django_upgrade_linter.py | 10 +++---- .../adapters/editorconfig_checker_linter.py | 10 +++---- lintrunner_adapters/adapters/exec_linter.py | 10 +++---- lintrunner_adapters/adapters/flake8_linter.py | 18 +++++++------ lintrunner_adapters/adapters/grep_linter.py | 10 +++---- lintrunner_adapters/adapters/isort_linter.py | 10 +++---- lintrunner_adapters/adapters/mypy_linter.py | 18 +++++++------ .../adapters/newlines_linter.py | 10 +++---- lintrunner_adapters/adapters/pylint_linter.py | 18 +++++++------ .../adapters/pyupgrade_linter.py | 10 +++---- lintrunner_adapters/adapters/refurb_linter.py | 18 +++++++------ .../adapters/requirements_txt_linter.py | 10 +++---- .../adapters/ruff_fix_linter.py | 10 +++---- .../adapters/ruff_format_linter.py | 10 +++---- lintrunner_adapters/adapters/ruff_linter.py | 10 +++---- .../adapters/rustfmt_linter.py | 10 +++---- .../adapters/toml_sort_linter.py | 10 +++---- lintrunner_adapters/adapters/ufmt_linter.py | 10 +++---- 37 files changed, 218 insertions(+), 197 deletions(-) diff --git a/examples/pytorch/black_isort_linter.py b/examples/pytorch/black_isort_linter.py index cca908d..8c39226 100644 --- a/examples/pytorch/black_isort_linter.py +++ b/examples/pytorch/black_isort_linter.py @@ -225,11 +225,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/examples/pytorch/black_linter.py b/examples/pytorch/black_linter.py index 3ed7fbd..c4c836d 100644 --- a/examples/pytorch/black_linter.py +++ b/examples/pytorch/black_linter.py @@ -200,11 +200,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/examples/pytorch/clangformat_linter.py b/examples/pytorch/clangformat_linter.py index 5a4a0b0..65cf246 100644 --- a/examples/pytorch/clangformat_linter.py +++ b/examples/pytorch/clangformat_linter.py @@ -202,11 +202,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/examples/pytorch/clangtidy_linter.py b/examples/pytorch/clangtidy_linter.py index 7ff3d03..8914e25 100644 --- a/examples/pytorch/clangtidy_linter.py +++ b/examples/pytorch/clangtidy_linter.py @@ -181,9 +181,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, @@ -228,11 +231,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/examples/pytorch/exec_linter.py b/examples/pytorch/exec_linter.py index 4a6f1e6..114793d 100644 --- a/examples/pytorch/exec_linter.py +++ b/examples/pytorch/exec_linter.py @@ -68,11 +68,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/examples/pytorch/flake8_linter.py b/examples/pytorch/flake8_linter.py index 4973cdc..98087f5 100644 --- a/examples/pytorch/flake8_linter.py +++ b/examples/pytorch/flake8_linter.py @@ -264,9 +264,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: @@ -307,9 +309,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, @@ -353,11 +357,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/examples/pytorch/grep_linter.py b/examples/pytorch/grep_linter.py index 787ffda..234bf80 100644 --- a/examples/pytorch/grep_linter.py +++ b/examples/pytorch/grep_linter.py @@ -209,11 +209,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/examples/pytorch/isort_linter.py b/examples/pytorch/isort_linter.py index f4323ed..41c91fa 100644 --- a/examples/pytorch/isort_linter.py +++ b/examples/pytorch/isort_linter.py @@ -200,11 +200,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/examples/pytorch/mypy_linter.py b/examples/pytorch/mypy_linter.py index 9d3778a..c07a188 100644 --- a/examples/pytorch/mypy_linter.py +++ b/examples/pytorch/mypy_linter.py @@ -116,9 +116,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, @@ -158,11 +160,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/examples/pytorch/newlines_linter.py b/examples/pytorch/newlines_linter.py index 510a73a..500a7af 100644 --- a/examples/pytorch/newlines_linter.py +++ b/examples/pytorch/newlines_linter.py @@ -145,11 +145,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/examples/pytorch/s3_init.py b/examples/pytorch/s3_init.py index 86d9796..85b5fd8 100644 --- a/examples/pytorch/s3_init.py +++ b/examples/pytorch/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/examples/pytorch/ufmt_linter.py b/examples/pytorch/ufmt_linter.py index 5c9636d..61c5dd9 100644 --- a/examples/pytorch/ufmt_linter.py +++ b/examples/pytorch/ufmt_linter.py @@ -116,11 +116,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/lintrunner_adapters/__init__.py b/lintrunner_adapters/__init__.py index b33786e..76ab219 100644 --- a/lintrunner_adapters/__init__.py +++ b/lintrunner_adapters/__init__.py @@ -1,4 +1,5 @@ """Adapters and tools for lintrunner.""" + from __future__ import annotations __all__ = [ diff --git a/lintrunner_adapters/__main__.py b/lintrunner_adapters/__main__.py index e042432..8be9b53 100644 --- a/lintrunner_adapters/__main__.py +++ b/lintrunner_adapters/__main__.py @@ -10,6 +10,7 @@ to list available adapters. """ + from __future__ import annotations import json diff --git a/lintrunner_adapters/adapters/add_trailing_comma_linter.py b/lintrunner_adapters/adapters/add_trailing_comma_linter.py index 89e4a0b..caf0ee3 100644 --- a/lintrunner_adapters/adapters/add_trailing_comma_linter.py +++ b/lintrunner_adapters/adapters/add_trailing_comma_linter.py @@ -114,11 +114,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/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 2477c04..346da1f 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -144,11 +144,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/lintrunner_adapters/adapters/black_linter.py b/lintrunner_adapters/adapters/black_linter.py index fb26df6..f85377c 100644 --- a/lintrunner_adapters/adapters/black_linter.py +++ b/lintrunner_adapters/adapters/black_linter.py @@ -129,11 +129,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/lintrunner_adapters/adapters/clangformat_linter.py b/lintrunner_adapters/adapters/clangformat_linter.py index b9465f1..e99e362 100644 --- a/lintrunner_adapters/adapters/clangformat_linter.py +++ b/lintrunner_adapters/adapters/clangformat_linter.py @@ -136,11 +136,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/lintrunner_adapters/adapters/clippy_linter.py b/lintrunner_adapters/adapters/clippy_linter.py index a4c723f..49b6716 100644 --- a/lintrunner_adapters/adapters/clippy_linter.py +++ b/lintrunner_adapters/adapters/clippy_linter.py @@ -219,11 +219,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/lintrunner_adapters/adapters/django_upgrade_linter.py b/lintrunner_adapters/adapters/django_upgrade_linter.py index 2422065..ff04bcd 100644 --- a/lintrunner_adapters/adapters/django_upgrade_linter.py +++ b/lintrunner_adapters/adapters/django_upgrade_linter.py @@ -121,11 +121,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/lintrunner_adapters/adapters/editorconfig_checker_linter.py b/lintrunner_adapters/adapters/editorconfig_checker_linter.py index 1863201..2d0e48d 100644 --- a/lintrunner_adapters/adapters/editorconfig_checker_linter.py +++ b/lintrunner_adapters/adapters/editorconfig_checker_linter.py @@ -99,11 +99,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/lintrunner_adapters/adapters/exec_linter.py b/lintrunner_adapters/adapters/exec_linter.py index f124795..cff959c 100644 --- a/lintrunner_adapters/adapters/exec_linter.py +++ b/lintrunner_adapters/adapters/exec_linter.py @@ -50,11 +50,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/lintrunner_adapters/adapters/flake8_linter.py b/lintrunner_adapters/adapters/flake8_linter.py index 68bb892..4e38651 100644 --- a/lintrunner_adapters/adapters/flake8_linter.py +++ b/lintrunner_adapters/adapters/flake8_linter.py @@ -252,9 +252,11 @@ def check_files( show_disable, ), 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=LINTER_CODE, severity=severities.get(match["code"]) or get_issue_severity(match["code"]), original=None, @@ -303,11 +305,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/lintrunner_adapters/adapters/grep_linter.py b/lintrunner_adapters/adapters/grep_linter.py index 5f752cf..8753f6c 100644 --- a/lintrunner_adapters/adapters/grep_linter.py +++ b/lintrunner_adapters/adapters/grep_linter.py @@ -163,11 +163,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/lintrunner_adapters/adapters/isort_linter.py b/lintrunner_adapters/adapters/isort_linter.py index 5542c6b..716a9cf 100644 --- a/lintrunner_adapters/adapters/isort_linter.py +++ b/lintrunner_adapters/adapters/isort_linter.py @@ -113,11 +113,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/lintrunner_adapters/adapters/mypy_linter.py b/lintrunner_adapters/adapters/mypy_linter.py index 928dc60..d6b55ba 100644 --- a/lintrunner_adapters/adapters/mypy_linter.py +++ b/lintrunner_adapters/adapters/mypy_linter.py @@ -101,9 +101,11 @@ def check_files( description=match["message"] + (disable_message(match["code"]) if show_disable else ""), 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=LINTER_CODE, severity=SEVERITIES.get(match["severity"], LintSeverity.ERROR), original=None, @@ -138,11 +140,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/lintrunner_adapters/adapters/newlines_linter.py b/lintrunner_adapters/adapters/newlines_linter.py index ee32997..af44b68 100644 --- a/lintrunner_adapters/adapters/newlines_linter.py +++ b/lintrunner_adapters/adapters/newlines_linter.py @@ -133,11 +133,11 @@ def check_file(filename: str) -> LintMessage | 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/lintrunner_adapters/adapters/pylint_linter.py b/lintrunner_adapters/adapters/pylint_linter.py index fa62941..89201b4 100644 --- a/lintrunner_adapters/adapters/pylint_linter.py +++ b/lintrunner_adapters/adapters/pylint_linter.py @@ -159,9 +159,11 @@ def check_files( match["message"], match["code"], match["string_code"], show_disable ), 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=LINTER_CODE, severity=SEVERITIES.get(match["code"][0], LintSeverity.ERROR), original=None, @@ -198,11 +200,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/lintrunner_adapters/adapters/pyupgrade_linter.py b/lintrunner_adapters/adapters/pyupgrade_linter.py index 539be22..2df1870 100644 --- a/lintrunner_adapters/adapters/pyupgrade_linter.py +++ b/lintrunner_adapters/adapters/pyupgrade_linter.py @@ -131,11 +131,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/lintrunner_adapters/adapters/refurb_linter.py b/lintrunner_adapters/adapters/refurb_linter.py index 5a66f1f..b0c4a76 100644 --- a/lintrunner_adapters/adapters/refurb_linter.py +++ b/lintrunner_adapters/adapters/refurb_linter.py @@ -98,9 +98,11 @@ def check_files( show_disable, ), 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=LINTER_CODE, severity=severities.get(match["code"], LintSeverity.ADVICE), original=None, @@ -137,11 +139,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/lintrunner_adapters/adapters/requirements_txt_linter.py b/lintrunner_adapters/adapters/requirements_txt_linter.py index 0791034..5cf74c3 100644 --- a/lintrunner_adapters/adapters/requirements_txt_linter.py +++ b/lintrunner_adapters/adapters/requirements_txt_linter.py @@ -171,11 +171,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/lintrunner_adapters/adapters/ruff_fix_linter.py b/lintrunner_adapters/adapters/ruff_fix_linter.py index ee4445b..c74b4d3 100644 --- a/lintrunner_adapters/adapters/ruff_fix_linter.py +++ b/lintrunner_adapters/adapters/ruff_fix_linter.py @@ -113,11 +113,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/lintrunner_adapters/adapters/ruff_format_linter.py b/lintrunner_adapters/adapters/ruff_format_linter.py index 2c4723f..e5e8c02 100644 --- a/lintrunner_adapters/adapters/ruff_format_linter.py +++ b/lintrunner_adapters/adapters/ruff_format_linter.py @@ -112,11 +112,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/lintrunner_adapters/adapters/ruff_linter.py b/lintrunner_adapters/adapters/ruff_linter.py index 38c091b..266caef 100644 --- a/lintrunner_adapters/adapters/ruff_linter.py +++ b/lintrunner_adapters/adapters/ruff_linter.py @@ -282,11 +282,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/lintrunner_adapters/adapters/rustfmt_linter.py b/lintrunner_adapters/adapters/rustfmt_linter.py index 6de09fb..041dfca 100644 --- a/lintrunner_adapters/adapters/rustfmt_linter.py +++ b/lintrunner_adapters/adapters/rustfmt_linter.py @@ -190,11 +190,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/lintrunner_adapters/adapters/toml_sort_linter.py b/lintrunner_adapters/adapters/toml_sort_linter.py index d536b10..68d5361 100644 --- a/lintrunner_adapters/adapters/toml_sort_linter.py +++ b/lintrunner_adapters/adapters/toml_sort_linter.py @@ -109,11 +109,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/lintrunner_adapters/adapters/ufmt_linter.py b/lintrunner_adapters/adapters/ufmt_linter.py index 10f5f08..e49ebb1 100644 --- a/lintrunner_adapters/adapters/ufmt_linter.py +++ b/lintrunner_adapters/adapters/ufmt_linter.py @@ -90,11 +90,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, ) From 93b3ae67c4075ec05b219ffa9cad04818ee12fc8 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 15:56:25 +0000 Subject: [PATCH 07/19] This? --- .../adapters/black_isort_linter.py | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 346da1f..ac40a35 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -29,34 +29,33 @@ def check_file( try: with open(filename, "rb") as f: original = f.read() - with open(filename, "rb") as f: + with open(filename, "rb") as f: # noqa: SIM117 # Run isort first then black so we get consistent result # even if isort is not using the black profile - proc = subprocess.Popen( + with subprocess.Popen( [sys.executable, "-misort", "-"], stdin=f, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - ) - # Launch second process and connect it to the first one - black_proc = subprocess.Popen( - [ - sys.executable, - "-mblack", - *(("--pyi",) if filename.endswith(".pyi") else ()), - *(("--ipynb",) if filename.endswith(".ipynb") else ()), - *(("--fast",) if fast else ()), - "--stdin-filename", - filename, - "-", - ], - stdin=proc.stdout, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - - # Let stream flow between them - replacement, _ = black_proc.communicate(timeout=timeout) + ) as proc: + # Launch second process and connect it to the first one + with subprocess.Popen( + [ + sys.executable, + "-mblack", + *(("--pyi",) if filename.endswith(".pyi") else ()), + *(("--ipynb",) if filename.endswith(".ipynb") else ()), + *(("--fast",) if fast else ()), + "--stdin-filename", + filename, + "-", + ], + stdin=proc.stdout, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) as black_proc: + # Let stream flow between them + replacement, _ = black_proc.communicate(timeout=timeout) except subprocess.TimeoutExpired: return [ From 705280fb70e1d305ed6ecdf940f7997595c06378 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Sun, 4 Feb 2024 16:13:01 +0000 Subject: [PATCH 08/19] Run black first --- .../adapters/black_isort_linter.py | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index ac40a35..c9f9607 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -12,7 +12,7 @@ import sys import lintrunner_adapters -from lintrunner_adapters import LintMessage, LintSeverity, as_posix +from lintrunner_adapters import LintMessage, LintSeverity, as_posix, run_command LINTER_CODE = "BLACK-ISORT" @@ -24,38 +24,36 @@ def check_file( *, fast: bool = False, ) -> list[LintMessage]: - del retries # Unused - try: with open(filename, "rb") as f: original = f.read() - with open(filename, "rb") as f: # noqa: SIM117 - # Run isort first then black so we get consistent result - # even if isort is not using the black profile - with subprocess.Popen( - [sys.executable, "-misort", "-"], + with open(filename, "rb") as f: + # Use black first because black >24.1 sees an empty stdin with + # Python 3.8/3.9 running with lintrunner on Windows + # https://github.com/justinchuby/lintrunner-adapters/issues/93 + proc = run_command( + [ + sys.executable, + "-mblack", + *(("--pyi",) if filename.endswith(".pyi") else ()), + *(("--ipynb",) if filename.endswith(".ipynb") else ()), + *(("--fast",) if fast else ()), + "--stdin-filename", + filename, + "-", + ], stdin=f, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) as proc: - # Launch second process and connect it to the first one - with subprocess.Popen( - [ - sys.executable, - "-mblack", - *(("--pyi",) if filename.endswith(".pyi") else ()), - *(("--ipynb",) if filename.endswith(".ipynb") else ()), - *(("--fast",) if fast else ()), - "--stdin-filename", - filename, - "-", - ], - stdin=proc.stdout, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) as black_proc: - # Let stream flow between them - replacement, _ = black_proc.communicate(timeout=timeout) + retries=retries, + timeout=timeout, + check=True, + ) + proc = run_command( + [sys.executable, "-misort", "-"], + input=proc.stdout, + retries=retries, + timeout=timeout, + check=True, + ) except subprocess.TimeoutExpired: return [ @@ -82,7 +80,7 @@ def check_file( line=None, char=None, code=LINTER_CODE, - severity=LintSeverity.ERROR, + severity=LintSeverity.ADVICE, name="command-failed", original=None, replacement=None, @@ -104,6 +102,7 @@ def check_file( ) ] + replacement = proc.stdout if original == replacement: return [] From e36c3ed26371e8e28b93c7ee6c69ca73d8a0c0e5 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 10:10:31 -0800 Subject: [PATCH 09/19] Update black_isort_linter.py --- examples/pytorch/black_isort_linter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/pytorch/black_isort_linter.py b/examples/pytorch/black_isort_linter.py index 8c39226..8eab869 100644 --- a/examples/pytorch/black_isort_linter.py +++ b/examples/pytorch/black_isort_linter.py @@ -113,6 +113,9 @@ def check_file( with open(filename, "rb") as f: original = f.read() with open(filename, "rb") as f: + # Resolve the file path to get around errors with Python 3.8/3.9 + # https://github.com/psf/black/issues/4209 + filename = os.path.realpath(filename) proc = run_command( [sys.executable, "-mblack", "--stdin-filename", filename, "-"], stdin=f, From be3394e6ff8aa3d1a2ca8f2a0e174145b18919db Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 10:23:28 -0800 Subject: [PATCH 10/19] Update .lintrunner.toml --- .lintrunner.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lintrunner.toml b/.lintrunner.toml index a1c9981..90d6cdc 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -346,7 +346,7 @@ init_command = [ 'run', 'pip_init', '--dry-run={{DRYRUN}}', - 'ruff==0.1.5', + 'ruff==0.2.1', ] is_formatter = true @@ -373,7 +373,7 @@ init_command = [ 'run', 'pip_init', '--dry-run={{DRYRUN}}', - 'ruff==0.1.5', + 'ruff==0.2.1', ] is_formatter = true From 7d0f40b31fa84344086a657170913d08cff5df91 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 10:25:32 -0800 Subject: [PATCH 11/19] Update black_isort_linter.py --- examples/pytorch/black_isort_linter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pytorch/black_isort_linter.py b/examples/pytorch/black_isort_linter.py index 8eab869..b5c1b68 100644 --- a/examples/pytorch/black_isort_linter.py +++ b/examples/pytorch/black_isort_linter.py @@ -115,7 +115,7 @@ def check_file( with open(filename, "rb") as f: # Resolve the file path to get around errors with Python 3.8/3.9 # https://github.com/psf/black/issues/4209 - filename = os.path.realpath(filename) + filename = str(pathlib.Path(filename).resolve()) proc = run_command( [sys.executable, "-mblack", "--stdin-filename", filename, "-"], stdin=f, From eac71792c6bc5b06918a5a6bc9b7ca2c687194ea Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 10:26:16 -0800 Subject: [PATCH 12/19] Update black_isort_linter.py --- examples/pytorch/black_isort_linter.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/pytorch/black_isort_linter.py b/examples/pytorch/black_isort_linter.py index b5c1b68..8c39226 100644 --- a/examples/pytorch/black_isort_linter.py +++ b/examples/pytorch/black_isort_linter.py @@ -113,9 +113,6 @@ def check_file( with open(filename, "rb") as f: original = f.read() with open(filename, "rb") as f: - # Resolve the file path to get around errors with Python 3.8/3.9 - # https://github.com/psf/black/issues/4209 - filename = str(pathlib.Path(filename).resolve()) proc = run_command( [sys.executable, "-mblack", "--stdin-filename", filename, "-"], stdin=f, From da177ca82409eab5d8bc021a04eb877ca907f04b Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:30:09 +0000 Subject: [PATCH 13/19] Resolve the file path to get around errors with Python 3.8/3.9 on Windows --- .../adapters/black_isort_linter.py | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index c9f9607..220d996 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -28,9 +28,21 @@ def check_file( with open(filename, "rb") as f: original = f.read() with open(filename, "rb") as f: - # Use black first because black >24.1 sees an empty stdin with - # Python 3.8/3.9 running with lintrunner on Windows - # https://github.com/justinchuby/lintrunner-adapters/issues/93 + # Run isort first then black so we get consistent result + # even if isort is not using the black profile + proc = run_command( + [sys.executable, "-misort", "-"], + stdin=f, + retries=retries, + timeout=timeout, + check=True, + ) + import_sorted = proc.stdout + # Pipe isort's result to black + + # Resolve the file path to get around errors with Python 3.8/3.9 on Windows + # https://github.com/psf/black/issues/4209 + filename = os.path.realpath(filename) proc = run_command( [ sys.executable, @@ -42,19 +54,12 @@ def check_file( filename, "-", ], - stdin=f, - retries=retries, - timeout=timeout, - check=True, - ) - proc = run_command( - [sys.executable, "-misort", "-"], - input=proc.stdout, + stdin=None, + input=import_sorted, retries=retries, timeout=timeout, check=True, ) - except subprocess.TimeoutExpired: return [ LintMessage( @@ -142,11 +147,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, ) From 586c6dea5ef16a3a37326f6b7371b777ff271b94 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:31:25 +0000 Subject: [PATCH 14/19] resolved_filename --- lintrunner_adapters/adapters/black_isort_linter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 220d996..15cdfe2 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -42,7 +42,7 @@ def check_file( # Resolve the file path to get around errors with Python 3.8/3.9 on Windows # https://github.com/psf/black/issues/4209 - filename = os.path.realpath(filename) + resolved_filename = os.path.realpath(filename) proc = run_command( [ sys.executable, @@ -51,7 +51,7 @@ def check_file( *(("--ipynb",) if filename.endswith(".ipynb") else ()), *(("--fast",) if fast else ()), "--stdin-filename", - filename, + resolved_filename, "-", ], stdin=None, From f7bb15062ae22ab6eb505faec4e147900a2cddb1 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:34:42 +0000 Subject: [PATCH 15/19] Format --- examples/pytorch/black_isort_linter.py | 4 +++- examples/pytorch/black_linter.py | 4 +++- examples/pytorch/clangformat_linter.py | 4 +++- examples/pytorch/clangtidy_linter.py | 4 +++- lintrunner_adapters/adapters/black_isort_linter.py | 10 +++++----- lintrunner_adapters/tools/convert_to_sarif.py | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/pytorch/black_isort_linter.py b/examples/pytorch/black_isort_linter.py index 8c39226..7707e19 100644 --- a/examples/pytorch/black_isort_linter.py +++ b/examples/pytorch/black_isort_linter.py @@ -228,7 +228,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/black_linter.py b/examples/pytorch/black_linter.py index c4c836d..0328883 100644 --- a/examples/pytorch/black_linter.py +++ b/examples/pytorch/black_linter.py @@ -203,7 +203,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/clangformat_linter.py b/examples/pytorch/clangformat_linter.py index 65cf246..771ebdd 100644 --- a/examples/pytorch/clangformat_linter.py +++ b/examples/pytorch/clangformat_linter.py @@ -205,7 +205,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/clangtidy_linter.py b/examples/pytorch/clangtidy_linter.py index 8914e25..3a0d471 100644 --- a/examples/pytorch/clangtidy_linter.py +++ b/examples/pytorch/clangtidy_linter.py @@ -234,7 +234,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 15cdfe2..e182c0f 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -147,11 +147,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/lintrunner_adapters/tools/convert_to_sarif.py b/lintrunner_adapters/tools/convert_to_sarif.py index 822a844..f2d1f96 100644 --- a/lintrunner_adapters/tools/convert_to_sarif.py +++ b/lintrunner_adapters/tools/convert_to_sarif.py @@ -19,7 +19,7 @@ def severity_to_github_level(severity: str) -> str: def parse_single_lintrunner_result( - lintrunner_result: dict[str, Any] + lintrunner_result: dict[str, Any], ) -> tuple[dict[str, Any], dict[str, Any]]: r"""Parse a single lintrunner result. From 9e473c394a3a8662a37617336feccd8b3c620d2d Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:40:25 +0000 Subject: [PATCH 16/19] Resolve --- examples/pytorch/clangtidy_linter.py | 4 +--- lintrunner_adapters/adapters/black_isort_linter.py | 3 ++- lintrunner_adapters/adapters/black_linter.py | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/pytorch/clangtidy_linter.py b/examples/pytorch/clangtidy_linter.py index 3a0d471..8914e25 100644 --- a/examples/pytorch/clangtidy_linter.py +++ b/examples/pytorch/clangtidy_linter.py @@ -234,9 +234,7 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG - if len(args.filenames) < 1000 - else logging.INFO + else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index e182c0f..711028d 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -8,6 +8,7 @@ import concurrent.futures import logging import os +import pathlib import subprocess import sys @@ -42,7 +43,7 @@ def check_file( # Resolve the file path to get around errors with Python 3.8/3.9 on Windows # https://github.com/psf/black/issues/4209 - resolved_filename = os.path.realpath(filename) + resolved_filename = str(pathlib.Path(filename).resolve()) proc = run_command( [ sys.executable, diff --git a/lintrunner_adapters/adapters/black_linter.py b/lintrunner_adapters/adapters/black_linter.py index f85377c..2a96a43 100644 --- a/lintrunner_adapters/adapters/black_linter.py +++ b/lintrunner_adapters/adapters/black_linter.py @@ -6,6 +6,7 @@ import concurrent.futures import logging import os +import pathlib import subprocess import sys @@ -26,6 +27,9 @@ def check_file( with open(filename, "rb") as f: original = f.read() with open(filename, "rb") as f: + # Resolve the file path to get around errors with Python 3.8/3.9 on Windows + # https://github.com/psf/black/issues/4209 + resolved_filename = str(pathlib.Path(filename).resolve()) proc = run_command( [ sys.executable, @@ -34,7 +38,7 @@ def check_file( *(("--ipynb",) if filename.endswith(".ipynb") else ()), *(("--fast",) if fast else ()), "--stdin-filename", - filename, + resolved_filename, "-", ], stdin=f, From 4a81c13344379cdc4d1349fa3280a17838310beb Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:41:59 +0000 Subject: [PATCH 17/19] Format back --- examples/pytorch/clangtidy_linter.py | 4 +++- examples/pytorch/exec_linter.py | 4 +++- examples/pytorch/flake8_linter.py | 4 +++- examples/pytorch/grep_linter.py | 4 +++- examples/pytorch/isort_linter.py | 4 +++- examples/pytorch/mypy_linter.py | 4 +++- examples/pytorch/newlines_linter.py | 4 +++- examples/pytorch/ufmt_linter.py | 4 +++- lintrunner_adapters/adapters/add_trailing_comma_linter.py | 4 +++- lintrunner_adapters/adapters/black_isort_linter.py | 4 +++- lintrunner_adapters/adapters/black_linter.py | 4 +++- lintrunner_adapters/adapters/clangformat_linter.py | 4 +++- lintrunner_adapters/adapters/clippy_linter.py | 4 +++- lintrunner_adapters/adapters/django_upgrade_linter.py | 4 +++- lintrunner_adapters/adapters/editorconfig_checker_linter.py | 4 +++- lintrunner_adapters/adapters/exec_linter.py | 4 +++- lintrunner_adapters/adapters/flake8_linter.py | 4 +++- lintrunner_adapters/adapters/grep_linter.py | 4 +++- lintrunner_adapters/adapters/isort_linter.py | 4 +++- lintrunner_adapters/adapters/mypy_linter.py | 4 +++- lintrunner_adapters/adapters/newlines_linter.py | 4 +++- lintrunner_adapters/adapters/pylint_linter.py | 4 +++- lintrunner_adapters/adapters/pyupgrade_linter.py | 4 +++- lintrunner_adapters/adapters/refurb_linter.py | 4 +++- lintrunner_adapters/adapters/requirements_txt_linter.py | 4 +++- lintrunner_adapters/adapters/ruff_fix_linter.py | 4 +++- lintrunner_adapters/adapters/ruff_format_linter.py | 4 +++- lintrunner_adapters/adapters/ruff_linter.py | 4 +++- lintrunner_adapters/adapters/rustfmt_linter.py | 4 +++- lintrunner_adapters/adapters/toml_sort_linter.py | 4 +++- lintrunner_adapters/adapters/ufmt_linter.py | 4 +++- 31 files changed, 93 insertions(+), 31 deletions(-) diff --git a/examples/pytorch/clangtidy_linter.py b/examples/pytorch/clangtidy_linter.py index 8914e25..3a0d471 100644 --- a/examples/pytorch/clangtidy_linter.py +++ b/examples/pytorch/clangtidy_linter.py @@ -234,7 +234,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/exec_linter.py b/examples/pytorch/exec_linter.py index 114793d..dcb6fec 100644 --- a/examples/pytorch/exec_linter.py +++ b/examples/pytorch/exec_linter.py @@ -71,7 +71,9 @@ def check_file(filename: str) -> Optional[LintMessage]: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/flake8_linter.py b/examples/pytorch/flake8_linter.py index 98087f5..80a4c08 100644 --- a/examples/pytorch/flake8_linter.py +++ b/examples/pytorch/flake8_linter.py @@ -360,7 +360,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/grep_linter.py b/examples/pytorch/grep_linter.py index 234bf80..af60da4 100644 --- a/examples/pytorch/grep_linter.py +++ b/examples/pytorch/grep_linter.py @@ -212,7 +212,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/isort_linter.py b/examples/pytorch/isort_linter.py index 41c91fa..a0fa19d 100644 --- a/examples/pytorch/isort_linter.py +++ b/examples/pytorch/isort_linter.py @@ -203,7 +203,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/mypy_linter.py b/examples/pytorch/mypy_linter.py index c07a188..bc07989 100644 --- a/examples/pytorch/mypy_linter.py +++ b/examples/pytorch/mypy_linter.py @@ -163,7 +163,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/newlines_linter.py b/examples/pytorch/newlines_linter.py index 500a7af..93cfb4f 100644 --- a/examples/pytorch/newlines_linter.py +++ b/examples/pytorch/newlines_linter.py @@ -148,7 +148,9 @@ def check_file(filename: str) -> Optional[LintMessage]: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/examples/pytorch/ufmt_linter.py b/examples/pytorch/ufmt_linter.py index 61c5dd9..f9a6a08 100644 --- a/examples/pytorch/ufmt_linter.py +++ b/examples/pytorch/ufmt_linter.py @@ -119,7 +119,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/add_trailing_comma_linter.py b/lintrunner_adapters/adapters/add_trailing_comma_linter.py index caf0ee3..580eecd 100644 --- a/lintrunner_adapters/adapters/add_trailing_comma_linter.py +++ b/lintrunner_adapters/adapters/add_trailing_comma_linter.py @@ -117,7 +117,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/black_isort_linter.py b/lintrunner_adapters/adapters/black_isort_linter.py index 711028d..fbc1aae 100644 --- a/lintrunner_adapters/adapters/black_isort_linter.py +++ b/lintrunner_adapters/adapters/black_isort_linter.py @@ -151,7 +151,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/black_linter.py b/lintrunner_adapters/adapters/black_linter.py index 2a96a43..e36eab4 100644 --- a/lintrunner_adapters/adapters/black_linter.py +++ b/lintrunner_adapters/adapters/black_linter.py @@ -136,7 +136,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/clangformat_linter.py b/lintrunner_adapters/adapters/clangformat_linter.py index e99e362..55d25dd 100644 --- a/lintrunner_adapters/adapters/clangformat_linter.py +++ b/lintrunner_adapters/adapters/clangformat_linter.py @@ -139,7 +139,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/clippy_linter.py b/lintrunner_adapters/adapters/clippy_linter.py index 49b6716..ddaeb95 100644 --- a/lintrunner_adapters/adapters/clippy_linter.py +++ b/lintrunner_adapters/adapters/clippy_linter.py @@ -222,7 +222,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/django_upgrade_linter.py b/lintrunner_adapters/adapters/django_upgrade_linter.py index ff04bcd..9636cac 100644 --- a/lintrunner_adapters/adapters/django_upgrade_linter.py +++ b/lintrunner_adapters/adapters/django_upgrade_linter.py @@ -124,7 +124,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/editorconfig_checker_linter.py b/lintrunner_adapters/adapters/editorconfig_checker_linter.py index 2d0e48d..30b0008 100644 --- a/lintrunner_adapters/adapters/editorconfig_checker_linter.py +++ b/lintrunner_adapters/adapters/editorconfig_checker_linter.py @@ -102,7 +102,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/exec_linter.py b/lintrunner_adapters/adapters/exec_linter.py index cff959c..2f196e0 100644 --- a/lintrunner_adapters/adapters/exec_linter.py +++ b/lintrunner_adapters/adapters/exec_linter.py @@ -53,7 +53,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/flake8_linter.py b/lintrunner_adapters/adapters/flake8_linter.py index 4e38651..9e1de6d 100644 --- a/lintrunner_adapters/adapters/flake8_linter.py +++ b/lintrunner_adapters/adapters/flake8_linter.py @@ -308,7 +308,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/grep_linter.py b/lintrunner_adapters/adapters/grep_linter.py index 8753f6c..f1493f4 100644 --- a/lintrunner_adapters/adapters/grep_linter.py +++ b/lintrunner_adapters/adapters/grep_linter.py @@ -166,7 +166,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/isort_linter.py b/lintrunner_adapters/adapters/isort_linter.py index 716a9cf..cad0a57 100644 --- a/lintrunner_adapters/adapters/isort_linter.py +++ b/lintrunner_adapters/adapters/isort_linter.py @@ -116,7 +116,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/mypy_linter.py b/lintrunner_adapters/adapters/mypy_linter.py index d6b55ba..cd116f1 100644 --- a/lintrunner_adapters/adapters/mypy_linter.py +++ b/lintrunner_adapters/adapters/mypy_linter.py @@ -143,7 +143,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/newlines_linter.py b/lintrunner_adapters/adapters/newlines_linter.py index af44b68..7808017 100644 --- a/lintrunner_adapters/adapters/newlines_linter.py +++ b/lintrunner_adapters/adapters/newlines_linter.py @@ -136,7 +136,9 @@ def check_file(filename: str) -> LintMessage | None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/pylint_linter.py b/lintrunner_adapters/adapters/pylint_linter.py index 89201b4..d716dbb 100644 --- a/lintrunner_adapters/adapters/pylint_linter.py +++ b/lintrunner_adapters/adapters/pylint_linter.py @@ -203,7 +203,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/pyupgrade_linter.py b/lintrunner_adapters/adapters/pyupgrade_linter.py index 2df1870..d942934 100644 --- a/lintrunner_adapters/adapters/pyupgrade_linter.py +++ b/lintrunner_adapters/adapters/pyupgrade_linter.py @@ -134,7 +134,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/refurb_linter.py b/lintrunner_adapters/adapters/refurb_linter.py index b0c4a76..dfb8a23 100644 --- a/lintrunner_adapters/adapters/refurb_linter.py +++ b/lintrunner_adapters/adapters/refurb_linter.py @@ -142,7 +142,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/requirements_txt_linter.py b/lintrunner_adapters/adapters/requirements_txt_linter.py index 5cf74c3..ce81630 100644 --- a/lintrunner_adapters/adapters/requirements_txt_linter.py +++ b/lintrunner_adapters/adapters/requirements_txt_linter.py @@ -174,7 +174,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/ruff_fix_linter.py b/lintrunner_adapters/adapters/ruff_fix_linter.py index c74b4d3..4f0ef0f 100644 --- a/lintrunner_adapters/adapters/ruff_fix_linter.py +++ b/lintrunner_adapters/adapters/ruff_fix_linter.py @@ -116,7 +116,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/ruff_format_linter.py b/lintrunner_adapters/adapters/ruff_format_linter.py index e5e8c02..1498b8f 100644 --- a/lintrunner_adapters/adapters/ruff_format_linter.py +++ b/lintrunner_adapters/adapters/ruff_format_linter.py @@ -115,7 +115,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/ruff_linter.py b/lintrunner_adapters/adapters/ruff_linter.py index 266caef..2c7ec50 100644 --- a/lintrunner_adapters/adapters/ruff_linter.py +++ b/lintrunner_adapters/adapters/ruff_linter.py @@ -285,7 +285,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/rustfmt_linter.py b/lintrunner_adapters/adapters/rustfmt_linter.py index 041dfca..ec72d95 100644 --- a/lintrunner_adapters/adapters/rustfmt_linter.py +++ b/lintrunner_adapters/adapters/rustfmt_linter.py @@ -193,7 +193,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/toml_sort_linter.py b/lintrunner_adapters/adapters/toml_sort_linter.py index 68d5361..b9f43b3 100644 --- a/lintrunner_adapters/adapters/toml_sort_linter.py +++ b/lintrunner_adapters/adapters/toml_sort_linter.py @@ -112,7 +112,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) diff --git a/lintrunner_adapters/adapters/ufmt_linter.py b/lintrunner_adapters/adapters/ufmt_linter.py index e49ebb1..f0716ee 100644 --- a/lintrunner_adapters/adapters/ufmt_linter.py +++ b/lintrunner_adapters/adapters/ufmt_linter.py @@ -93,7 +93,9 @@ def main() -> None: level=( logging.NOTSET if args.verbose - else logging.DEBUG if len(args.filenames) < 1000 else logging.INFO + else logging.DEBUG + if len(args.filenames) < 1000 + else logging.INFO ), stream=sys.stderr, ) From 7651cec9fd4400ab2753abccdd3860de3875e28b Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:42:45 +0000 Subject: [PATCH 18/19] 23.12.1 --- .lintrunner.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintrunner.toml b/.lintrunner.toml index 7929f96..41cb144 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -166,7 +166,7 @@ init_command = [ 'run', 'pip_init', '--dry-run={{DRYRUN}}', - 'black==24.1.1', + 'black==23.12.1', # Use 24.x when ruff styles are updated 'isort==5.10.1', ] is_formatter = true From 730f3a9bc29aef1291a11c45fa7fea113a19b25d Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 6 Feb 2024 18:46:36 +0000 Subject: [PATCH 19/19] Format --- .lintrunner.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintrunner.toml b/.lintrunner.toml index 41cb144..68224b2 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -166,7 +166,7 @@ init_command = [ 'run', 'pip_init', '--dry-run={{DRYRUN}}', - 'black==23.12.1', # Use 24.x when ruff styles are updated + 'black==23.12.1', # Use 24.x when ruff styles are updated 'isort==5.10.1', ] is_formatter = true