From bd162d65010e676fad7ada31f2065000f461efb7 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 18 Oct 2023 16:06:55 -0400 Subject: [PATCH 1/7] Replacing isort with Ruff --- .github/workflows/tests.yml | 11 ++++++- .pre-commit-config.yaml | 9 ++--- .vscode/extensions.json | 9 ++--- .vscode/settings.default.json | 8 ++--- CONTRIBUTING.md | 7 ++-- pyproject.toml | 56 +++++++++++++++----------------- requirements-tests.txt | 3 +- scripts/create_baseline_stubs.py | 7 +--- scripts/generate_proto_stubs.sh | 4 +-- scripts/runtests.py | 2 -- stdlib/csv.pyi | 2 +- tests/check_consistent.py | 2 +- 12 files changed, 56 insertions(+), 64 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0ba2fc7ab8ac..8bb998647cec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,8 +45,17 @@ jobs: python-version: "3.11" - run: ./tests/check_new_syntax.py + ruff: + name: Lint with Ruff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + with: + version: "0.0.292" # must match .pre-commit-config.yaml and requirements-test.txt + flake8: - name: Lint with flake8 + name: Lint with Flake8 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b63f3b911ab4..7bb26cc717b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,16 +14,11 @@ repos: hooks: - id: black language_version: python3.10 - - repo: https://github.com/pycqa/isort - rev: 5.12.0 # must match requirements-tests.txt - hooks: - - id: isort - name: isort (python) - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 # must match requirements-tests.txt + rev: v0.0.292 # must match requirements-tests.txt and tests.yml hooks: - id: ruff - args: [--exit-non-zero-on-fix] + args: [--exit-non-zero-on-fix, --fix-only] - repo: https://github.com/pycqa/flake8 rev: 6.1.0 # must match requirements-tests.txt hooks: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ad62d43f142a..0b218071ba3b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -7,7 +7,6 @@ "editorconfig.editorconfig", "ms-python.black-formatter", "ms-python.flake8", - "ms-python.isort", "ms-python.mypy-type-checker", "ms-python.python", "ms-python.vscode-pylance", @@ -16,17 +15,19 @@ ], "unwantedRecommendations": [ /* - * Don't recommend by default for this workspace + * Don't recommend by default for this workspace */ "christian-kohler.npm-intellisense", /* - * Must disable in this workspace - * https://github.com/microsoft/vscode/issues/40239 + * Must disable in this workspace + * https://github.com/microsoft/vscode/issues/40239 */ // even-better-toml has format on save "bungcip.better-toml", // Don't use two mypy extensions simultaneously "matangover.mypy", + // Use Ruff instead + "ms-python.isort", // We use black "ms-python.autopep8", // Not using pylint diff --git a/.vscode/settings.default.json b/.vscode/settings.default.json index 32bbd68a3924..506158875cae 100644 --- a/.vscode/settings.default.json +++ b/.vscode/settings.default.json @@ -79,7 +79,6 @@ "python.linting.prospectorEnabled": false, "python.linting.pylamaEnabled": false, "python.linting.pylintEnabled": false, - // Not using bandit "python.linting.banditEnabled": false, // python.analysis is Pylance (pyright) configurations "python.analysis.fixAll": [ @@ -108,13 +107,12 @@ "--config=.flake8" ], "flake8.importStrategy": "fromEnvironment", - "isort.check": true, - "isort.importStrategy": "fromEnvironment", "black-formatter.importStrategy": "fromEnvironment", + // Using Ruff instead of isort + "isort.check": false, "ruff.importStrategy": "fromEnvironment", "ruff.fixAll": true, - // Conflict between Ruff and isort - "ruff.organizeImports": false, + "ruff.organizeImports": true, "evenBetterToml.formatter.alignComments": false, "evenBetterToml.formatter.alignEntries": false, "evenBetterToml.formatter.allowedBlankLines": 1, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c17a07ff46f..5769e534c5e3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ it takes a bit longer. For more details, read below. Typeshed runs continuous integration (CI) on all pull requests. This means that if you file a pull request (PR), our full test suite -- including our linter, `flake8` -- is run on your PR. It also means that bots will automatically apply -changes to your PR (using `black`, `isort` and `ruff`) to fix any formatting issues. +changes to your PR (using `black` and `ruff`) to fix any formatting issues. This frees you up to ignore all local setup on your side, focus on the code and rely on the CI to fix everything, or point you to the places that need fixing. @@ -84,7 +84,7 @@ terminal to install all non-pytype requirements: ## Code formatting -The code is formatted using `black` and `isort`. Various other autofixes are +The code is formatted using `black`. Various other autofixes are also performed by `ruff`. The repository is equipped with a [`pre-commit.ci`](https://pre-commit.ci/) @@ -93,10 +93,9 @@ run the code formatters. When you push a commit, a bot will run those for you right away and add a commit to your PR. That being said, if you *want* to run the checks locally when you commit, -you're free to do so. Either run `isort`, `black` and `ruff` manually... +you're free to do so. Either run `black` and `ruff` manually... ```bash -(.venv)$ isort . (.venv)$ ruff . (.venv)$ black . ``` diff --git a/pyproject.toml b/pyproject.toml index 346619c2f119..6aded0ad9482 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,15 +7,12 @@ skip_magic_trailing_comma = true # for just these files, but doesn't seem possible yet. force-exclude = ".*_pb2.pyi" -[tool.isort] -profile = "black" -combine_as_imports = true -line_length = 130 -skip = [".git", ".github", ".venv"] -extra_standard_library = [ - "typing_extensions", +[tool.ruff.isort] +combine-as-imports = true +extra-standard-library = [ "_typeshed", - # Extra modules not recognized by isort + "typing_extensions", + # Extra modules not recognized by Ruff/isort "_ast", "_bisect", "_bootlocale", @@ -56,21 +53,21 @@ extra_standard_library = [ "opcode", "pyexpat", ] -known_first_party = ["utils", "parse_metadata"] +known-first-party = ["parse_metadata", "utils"] [tool.ruff] line-length = 130 +# Oldest supported Python version target-version = "py37" fix = true exclude = [ - # We're only interested in autofixes for our stubs - "*.py", # Ignore generated protobuf stubs "*_pb2.pyi", - # virtual environment, cache directories, etc.: - "env", + # virtual environment ".env", ".venv", + "env", + # cache directories, etc.: ".git", ".mypy_cache", ".pytype", @@ -79,22 +76,23 @@ exclude = [ # Only enable rules that have safe autofixes; # only enable rules that are relevant to stubs select = [ - "F401", # Remove unused imports - "UP004", # Remove explicit `object` inheritance - "UP006", # PEP-585 autofixes - "UP007", # PEP-604 autofixes - "UP013", # Class-based syntax for TypedDicts - "UP014", # Class-based syntax for NamedTuples - "UP019", # Use str over typing.Text - "UP035", # import from typing, not typing_extensions, wherever possible - "UP039", # don't use parens after a class definition with no bases - "PYI009", # use `...`, not `pass`, in empty class bodies - "PYI010", # function bodies must be empty - "PYI012", # class bodies must not contain `pass` - "PYI013", # non-empty class bodies must not contain `...` - "PYI020", # quoted annotations are always unnecessary in stubs - "PYI025", # always alias `collections.abc.Set` as `AbstractSet` when importing it - "PYI032", # use `object`, not `Any`, as the second parameter to `__eq__` + "F401", # Remove unused imports + "I", # isort + "PYI009", # use `...`, not `pass`, in empty class bodies + "PYI010", # function bodies must be empty + "PYI012", # class bodies must not contain `pass` + "PYI013", # non-empty class bodies must not contain `...` + "PYI020", # quoted annotations are always unnecessary in stubs + "PYI025", # always alias `collections.abc.Set` as `AbstractSet` when importing it + "PYI032", # use `object`, not `Any`, as the second parameter to `__eq__` + "UP004", # Remove explicit `object` inheritance + "UP006", # PEP-585 autofixes + "UP007", # PEP-604 autofixes + "UP013", # Class-based syntax for TypedDicts + "UP014", # Class-based syntax for NamedTuples + "UP019", # Use str over typing.Text + "UP035", # import from typing, not typing_extensions, wherever possible + "UP039", # don't use parens after a class definition with no bases ] [tool.typeshed] diff --git a/requirements-tests.txt b/requirements-tests.txt index 11fbaca82bb3..9b9831e46fc7 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -6,11 +6,10 @@ flake8==6.1.0 # must match .pre-commit-config.yaml flake8-bugbear==23.9.16 # must match .pre-commit-config.yaml flake8-noqa==1.3.2 # must match .pre-commit-config.yaml flake8-pyi==23.10.0 # must match .pre-commit-config.yaml -isort==5.12.0 # must match .pre-commit-config.yaml mypy==1.5.1 pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml pytype==2023.10.5; platform_system != "Windows" and python_version < "3.11" -ruff==0.0.292 # must match .pre-commit-config.yaml +ruff==0.0.292 # must match .pre-commit-config.yaml and tests.yml # Libraries used by our various scripts. aiohttp==3.8.5; python_version < "3.12" # aiohttp can't be installed on 3.12 yet diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 47cbafa354d9..18cef000a01a 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -65,11 +65,6 @@ def run_black(stub_dir: str) -> None: subprocess.run(["black", stub_dir]) -def run_isort(stub_dir: str) -> None: - print(f"Running isort: isort {stub_dir}") - subprocess.run([sys.executable, "-m", "isort", stub_dir]) - - def run_ruff(stub_dir: str) -> None: print(f"Running ruff: ruff {stub_dir}") subprocess.run([sys.executable, "-m", "ruff", stub_dir]) @@ -189,7 +184,7 @@ def add_pyright_exclusion(stub_dir: str) -> None: def main() -> None: parser = argparse.ArgumentParser( description="""Generate baseline stubs automatically for an installed pip package - using stubgen. Also run black, isort and ruff. If the name of + using stubgen. Also run black and ruff. If the name of the project is different from the runtime Python package name, you may need to use --package (example: --package yaml PyYAML).""" ) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index f1315b8a466a..e337516766f8 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -45,7 +45,7 @@ PYTHON_PROTOBUF_DIR="protobuf-$PYTHON_PROTOBUF_VERSION" VENV=venv python3 -m venv "$VENV" source "$VENV/bin/activate" -pip install -r "$REPO_ROOT/requirements-tests.txt" # for black and isort +pip install -r "$REPO_ROOT/requirements-tests.txt" # for black and ruff # Install mypy-protobuf pip install "git+https://github.com/dropbox/mypy-protobuf@$MYPY_PROTOBUF_VERSION" @@ -73,7 +73,7 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \ # shellcheck disable=SC2086 protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES -isort "$REPO_ROOT/stubs/protobuf" +ruff "$REPO_ROOT/stubs/protobuf" --exit-non-zero-on-fix --fix-only black "$REPO_ROOT/stubs/protobuf" sed -i "" "s/mypy-protobuf [^\"]*/mypy-protobuf ${MYPY_PROTOBUF_VERSION}/" "$REPO_ROOT/stubs/protobuf/METADATA.toml" diff --git a/scripts/runtests.py b/scripts/runtests.py index f53c23bd0d9f..ee4ddea31930 100644 --- a/scripts/runtests.py +++ b/scripts/runtests.py @@ -84,8 +84,6 @@ def main() -> None: # Run formatters first. Order matters. print("\nRunning ruff...") subprocess.run([sys.executable, "-m", "ruff", path]) - print("\nRunning isort...") - subprocess.run([sys.executable, "-m", "isort", path]) print("\nRunning Black...") black_result = subprocess.run([sys.executable, "-m", "black", path]) if black_result.returncode == 123: diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 53425fbcccb1..f48d9d2ff263 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -23,7 +23,7 @@ from _csv import ( ) if sys.version_info >= (3, 12): - from _csv import QUOTE_STRINGS as QUOTE_STRINGS, QUOTE_NOTNULL as QUOTE_NOTNULL + from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS from _typeshed import SupportsWrite from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence from typing import Any, Generic, TypeVar, overload diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 57249f16b104..2f11ed6bff20 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -23,7 +23,7 @@ # These type checkers and linters must have exact versions in the requirements file to ensure # consistent CI runs. -linters = {"black", "flake8", "flake8-bugbear", "flake8-noqa", "flake8-pyi", "isort", "ruff", "mypy", "pytype"} +linters = {"black", "flake8", "flake8-bugbear", "flake8-noqa", "flake8-pyi", "ruff", "mypy", "pytype"} def assert_consistent_filetypes( From 9dca69619de31ab2695f430daf07230321000ce5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 18 Oct 2023 16:53:51 -0400 Subject: [PATCH 2/7] Bump ruff version --- .github/workflows/tests.yml | 2 +- .pre-commit-config.yaml | 2 +- requirements-tests.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8bb998647cec..08c4abafaa8f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,7 +52,7 @@ jobs: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 with: - version: "0.0.292" # must match .pre-commit-config.yaml and requirements-test.txt + version: "0.1.0" # must match .pre-commit-config.yaml and requirements-test.txt flake8: name: Lint with Flake8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7bb26cc717b0..22cb07869546 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: black language_version: python3.10 - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 # must match requirements-tests.txt and tests.yml + rev: v0.1.0 # must match requirements-tests.txt and tests.yml hooks: - id: ruff args: [--exit-non-zero-on-fix, --fix-only] diff --git a/requirements-tests.txt b/requirements-tests.txt index 9b9831e46fc7..70ff90b9ee2a 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -9,7 +9,7 @@ flake8-pyi==23.10.0 # must match .pre-commit-config.yaml mypy==1.5.1 pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml pytype==2023.10.5; platform_system != "Windows" and python_version < "3.11" -ruff==0.0.292 # must match .pre-commit-config.yaml and tests.yml +ruff==0.1.0 # must match .pre-commit-config.yaml and tests.yml # Libraries used by our various scripts. aiohttp==3.8.5; python_version < "3.12" # aiohttp can't be installed on 3.12 yet From 7e57883a2ce1518afe38e673910906b81b0c30dd Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 18 Oct 2023 17:34:19 -0400 Subject: [PATCH 3/7] --fix-only in create_baseline_stubs --- scripts/create_baseline_stubs.py | 6 +++--- scripts/generate_proto_stubs.sh | 2 +- scripts/runtests.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 18cef000a01a..9c1be511c4b9 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -66,8 +66,8 @@ def run_black(stub_dir: str) -> None: def run_ruff(stub_dir: str) -> None: - print(f"Running ruff: ruff {stub_dir}") - subprocess.run([sys.executable, "-m", "ruff", stub_dir]) + print(f"Running Ruff: ruff {stub_dir}") + subprocess.run([sys.executable, "-m", "ruff", stub_dir, "--fix-only"]) async def get_project_urls_from_pypi(project: str, session: aiohttp.ClientSession) -> dict[str, str]: @@ -184,7 +184,7 @@ def add_pyright_exclusion(stub_dir: str) -> None: def main() -> None: parser = argparse.ArgumentParser( description="""Generate baseline stubs automatically for an installed pip package - using stubgen. Also run black and ruff. If the name of + using stubgen. Also run black and Ruff. If the name of the project is different from the runtime Python package name, you may need to use --package (example: --package yaml PyYAML).""" ) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index e337516766f8..02b08ce413a3 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -45,7 +45,7 @@ PYTHON_PROTOBUF_DIR="protobuf-$PYTHON_PROTOBUF_VERSION" VENV=venv python3 -m venv "$VENV" source "$VENV/bin/activate" -pip install -r "$REPO_ROOT/requirements-tests.txt" # for black and ruff +pip install -r "$REPO_ROOT/requirements-tests.txt" # for black and Ruff # Install mypy-protobuf pip install "git+https://github.com/dropbox/mypy-protobuf@$MYPY_PROTOBUF_VERSION" diff --git a/scripts/runtests.py b/scripts/runtests.py index ee4ddea31930..0519d7da4083 100644 --- a/scripts/runtests.py +++ b/scripts/runtests.py @@ -82,7 +82,7 @@ def main() -> None: pytype_result: subprocess.CompletedProcess[bytes] | None = None # Run formatters first. Order matters. - print("\nRunning ruff...") + print("\nRunning Ruff...") subprocess.run([sys.executable, "-m", "ruff", path]) print("\nRunning Black...") black_result = subprocess.run([sys.executable, "-m", "black", path]) From 735478a05fc2a68c0dc2a6b648209a8cee0619bf Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 18 Oct 2023 18:19:37 -0400 Subject: [PATCH 4/7] oops leftover method call --- scripts/create_baseline_stubs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 9c1be511c4b9..262bfb22e049 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -234,7 +234,6 @@ def main() -> None: run_stubdefaulter(stub_dir) run_ruff(stub_dir) - run_isort(stub_dir) run_black(stub_dir) create_metadata(project, stub_dir, version) From 32da2aab4a59767db7835c6f1a4a4c5a79476289 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 19 Oct 2023 11:22:53 -0400 Subject: [PATCH 5/7] Post-merge typo --- .vscode/extensions.json | 2 +- scripts/create_baseline_stubs.py | 2 +- scripts/generate_proto_stubs.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 0b218071ba3b..01b9ad4369db 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -28,7 +28,7 @@ "matangover.mypy", // Use Ruff instead "ms-python.isort", - // We use black + // We use Black "ms-python.autopep8", // Not using pylint "ms-python.pylint", diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index ba31a286c1de..294b49d41e5a 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -184,7 +184,7 @@ def add_pyright_exclusion(stub_dir: str) -> None: def main() -> None: parser = argparse.ArgumentParser( description="""Generate baseline stubs automatically for an installed pip package - using stubgen. Also run black and Ruff. If the name of + using stubgen. Also run Black and Ruff. If the name of the project is different from the runtime Python package name, you may need to use --package (example: --package yaml PyYAML).""" ) diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 02b08ce413a3..2d35bc259df1 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -45,7 +45,7 @@ PYTHON_PROTOBUF_DIR="protobuf-$PYTHON_PROTOBUF_VERSION" VENV=venv python3 -m venv "$VENV" source "$VENV/bin/activate" -pip install -r "$REPO_ROOT/requirements-tests.txt" # for black and Ruff +pip install -r "$REPO_ROOT/requirements-tests.txt" # for Black and Ruff # Install mypy-protobuf pip install "git+https://github.com/dropbox/mypy-protobuf@$MYPY_PROTOBUF_VERSION" From 09b63962591d13fe360bb46de0a560ade976bf95 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 22 Oct 2023 19:12:17 -0400 Subject: [PATCH 6/7] PR comments --- CONTRIBUTING.md | 2 +- scripts/create_baseline_stubs.py | 4 ++-- scripts/generate_proto_stubs.sh | 2 +- scripts/runtests.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b9a8be9b824..9390c9d9dc60 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,7 +99,7 @@ That being said, if you *want* to run the checks locally when you commit, you're free to do so. Either run the following manually... ```bash -(.venv)$ ruff . +(.venv)$ ruff check . (.venv)$ black . ``` diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 294b49d41e5a..7fb8db00e6b3 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -66,8 +66,8 @@ def run_black(stub_dir: str) -> None: def run_ruff(stub_dir: str) -> None: - print(f"Running Ruff: ruff {stub_dir}") - subprocess.run([sys.executable, "-m", "ruff", stub_dir, "--fix-only"]) + print(f"Running Ruff: ruff check {stub_dir} --fix-only") + subprocess.run([sys.executable, "-m", "ruff", "check", stub_dir, "--fix-only"]) async def get_project_urls_from_pypi(project: str, session: aiohttp.ClientSession) -> dict[str, str]: diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 2d35bc259df1..eab14901297d 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -73,7 +73,7 @@ PROTO_FILES=$(grep "GenProto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \ # shellcheck disable=SC2086 protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="relax_strict_optional_primitives:$REPO_ROOT/stubs/protobuf" $PROTO_FILES -ruff "$REPO_ROOT/stubs/protobuf" --exit-non-zero-on-fix --fix-only +ruff check "$REPO_ROOT/stubs/protobuf" --fix-only black "$REPO_ROOT/stubs/protobuf" sed -i "" "s/mypy-protobuf [^\"]*/mypy-protobuf ${MYPY_PROTOBUF_VERSION}/" "$REPO_ROOT/stubs/protobuf/METADATA.toml" diff --git a/scripts/runtests.py b/scripts/runtests.py index 0519d7da4083..bec0e47ccaa0 100644 --- a/scripts/runtests.py +++ b/scripts/runtests.py @@ -83,7 +83,7 @@ def main() -> None: # Run formatters first. Order matters. print("\nRunning Ruff...") - subprocess.run([sys.executable, "-m", "ruff", path]) + subprocess.run([sys.executable, "-m", "ruff", "check", path]) print("\nRunning Black...") black_result = subprocess.run([sys.executable, "-m", "black", path]) if black_result.returncode == 123: From 78e728f4c4903e1dcd9d1f9399834ca21e166698 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 22 Oct 2023 19:56:53 -0400 Subject: [PATCH 7/7] Update isort call in sync_tensorflow_protobuf_stubs.sh --- scripts/sync_tensorflow_protobuf_stubs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sync_tensorflow_protobuf_stubs.sh b/scripts/sync_tensorflow_protobuf_stubs.sh index 1626338febe0..11471a86c2aa 100755 --- a/scripts/sync_tensorflow_protobuf_stubs.sh +++ b/scripts/sync_tensorflow_protobuf_stubs.sh @@ -61,7 +61,7 @@ rm tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \ tensorflow/core/protobuf/worker_service_pb2.pyi \ tensorflow/core/util/example_proto_fast_parsing_test_pb2.pyi -isort "$REPO_ROOT/stubs/tensorflow/tensorflow" +ruff check "$REPO_ROOT/stubs/tensorflow/tensorflow" --fix-only black "$REPO_ROOT/stubs/tensorflow/tensorflow" sed --in-place="" \