From c36d3f45dc77fb3302bd95d33aa4add3d85d2de4 Mon Sep 17 00:00:00 2001 From: Matthijs Brobbel Date: Wed, 8 Jan 2025 10:47:09 +0100 Subject: [PATCH] chore(deps): bump flake8 (#358) * chore(deps): bump flake8 * fix: flake8 warnings --- .github/workflows/python.yml | 2 +- .pre-commit-config.yaml | 66 ++++++++++++++++++------------------ CONTRIBUTING.md | 40 +++++++++++----------- ci/version.py | 6 ++-- py/tests/test_api.py | 12 +++---- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f119c30f..fffa35f6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -140,7 +140,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install dependencies - run: python3 -m pip install --upgrade pip black==22.3.0 flake8==4.0.1 + run: python3 -m pip install --upgrade pip black==22.3.0 flake8==7.1.1 - name: Black run: python3 -m black --diff --check . - name: Flake8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb5ecfb4..f4f78c6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,34 +1,34 @@ repos: -- repo: https://github.com/doublify/pre-commit-rust - rev: v1.0 - hooks: - - id: fmt - - id: clippy - - id: cargo-check -- repo: https://github.com/pre-commit/mirrors-clang-format - rev: v13.0.1 - hooks: - - id: clang-format - types_or: [c, c++] -- repo: https://github.com/nametake/pre-commit-buf - rev: v2.0.0 - hooks: - - id: buf-lint -- repo: https://github.com/adrienverge/yamllint.git - rev: v1.35.1 - hooks: - - id: yamllint - args: [-c=.yamllint.yaml] -- repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black -- repo: https://github.com/pycqa/flake8 - rev: 4.0.1 - hooks: - - id: flake8 -- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v8.0.0 - hooks: - - id: commitlint - stages: [commit-msg] + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + - id: clippy + - id: cargo-check + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v13.0.1 + hooks: + - id: clang-format + types_or: [c, c++] + - repo: https://github.com/nametake/pre-commit-buf + rev: v2.0.0 + hooks: + - id: buf-lint + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 + hooks: + - id: yamllint + args: [-c=.yamllint.yaml] + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + - repo: https://github.com/pycqa/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v8.0.0 + hooks: + - id: commitlint + stages: [commit-msg] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 368b2a11..7102e986 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,12 +2,12 @@ Contributions are welcome! Here are some ways you can help: - - Try to break it. Get it to emit an error or warning for something you believe to be completely valid, or get it to emit nothing or only a warning for something you believe to be invalid. The validator is currently still considered to be experimental. - - Help with reviewing PRs and keeping up with Substrait. - - Improve the built-in plan documentation. The validator tries to emit plain English descriptions of various nodes in the tree to explain what they do, but this is far from complete. - - Submit additional integration tests, for more and better queries. Currently about half of TPC-H exists, but the quality of the plans is very poor (no optimization, partially handwritten, may be wholly incorrect, mostly restricted to the set of things Isthmus generates). - - Look through the issues to see if anything needs solving. - - Or maybe we're missing something we haven't even thought of yet! +- Try to break it. Get it to emit an error or warning for something you believe to be completely valid, or get it to emit nothing or only a warning for something you believe to be invalid. The validator is currently still considered to be experimental. +- Help with reviewing PRs and keeping up with Substrait. +- Improve the built-in plan documentation. The validator tries to emit plain English descriptions of various nodes in the tree to explain what they do, but this is far from complete. +- Submit additional integration tests, for more and better queries. Currently about half of TPC-H exists, but the quality of the plans is very poor (no optimization, partially handwritten, may be wholly incorrect, mostly restricted to the set of things Isthmus generates). +- Look through the issues to see if anything needs solving. +- Or maybe we're missing something we haven't even thought of yet! ## Licensing @@ -17,14 +17,14 @@ All contributions should be licensed under Apache 2.0. We use SPDX license heade Here's a (probably non-exhaustive) list of things you may want to have installed to develop for the validator. - - [Rust stable](https://rustup.rs/) - - VSCode with [rust-analyzer](https://rust-analyzer.github.io/) (or some other IDE with Rust support) - - Python 3.x (all non-EOL versions should be supported) - - The toolchain should be able to compile libprotobuf for you if you don't already have it, but it's probably a good idea to have a reasonably recent version installed system-wide as well - - [pre-commit](https://pre-commit.com/), so you don't have to rely on CI to catch all your errors, and to help format your code - - git (obviously) - - for the C bindings: [CMake](https://cmake.org/) and a C compiler (gcc, clang, and MSVC should all work; the bindings are very lightweight) - - [Protobuf](https://protobuf.dev/overview/), namely the `protoc` executable, for working with Substrait +- [Rust stable](https://rustup.rs/) +- VSCode with [rust-analyzer](https://rust-analyzer.github.io/) (or some other IDE with Rust support) +- Python 3.x (all non-EOL versions should be supported) +- The toolchain should be able to compile libprotobuf for you if you don't already have it, but it's probably a good idea to have a reasonably recent version installed system-wide as well +- [pre-commit](https://pre-commit.com/), so you don't have to rely on CI to catch all your errors, and to help format your code +- git (obviously) +- for the C bindings: [CMake](https://cmake.org/) and a C compiler (gcc, clang, and MSVC should all work; the bindings are very lightweight) +- [Protobuf](https://protobuf.dev/overview/), namely the `protoc` executable, for working with Substrait Note: this list is probably non-exhaustive; if you find something missing from this list, please add it! @@ -32,12 +32,12 @@ Note: this list is probably non-exhaustive; if you find something missing from t Code style is strictly enforced for all languages using CI and (to some extent) [pre-commit](https://pre-commit.com/) via: - - Rust: [rustfmt](https://github.com/rust-lang/rustfmt) and [clippy](https://github.com/rust-lang/rust-clippy). - - At the time of writing, stable clippy (1.60 and 1.61) panics on the codebase; hopefully this will be fixed soon. In CI the toolchain for linting is pinned to 1.59 for this reason. You can use Rust 1.59 to run clippy locally as well (`rustup install 1.59.0`, `cargo +1.59.0 clippy`) or you can leave it to CI, but either way you'll have to silence pre-commit (run it, see if there are no violations other than the clippy panic, then commit using `--no-verify`). - - Python: [black](https://github.com/psf/black) and [flake8](https://flake8.pycqa.org/en/4.0.1/). - - C: [clang-format](https://clang.llvm.org/docs/ClangFormat.html). - - protobuf: [buf format](https://buf.build/blog/introducing-buf-format). - - YAML: [yamllint](https://github.com/adrienverge/yamllint). +- Rust: [rustfmt](https://github.com/rust-lang/rustfmt) and [clippy](https://github.com/rust-lang/rust-clippy). + - At the time of writing, stable clippy (1.60 and 1.61) panics on the codebase; hopefully this will be fixed soon. In CI the toolchain for linting is pinned to 1.59 for this reason. You can use Rust 1.59 to run clippy locally as well (`rustup install 1.59.0`, `cargo +1.59.0 clippy`) or you can leave it to CI, but either way you'll have to silence pre-commit (run it, see if there are no violations other than the clippy panic, then commit using `--no-verify`). +- Python: [black](https://github.com/psf/black) and [flake8](https://flake8.pycqa.org/en/7.1.1/). +- C: [clang-format](https://clang.llvm.org/docs/ClangFormat.html). +- protobuf: [buf format](https://buf.build/blog/introducing-buf-format). +- YAML: [yamllint](https://github.com/adrienverge/yamllint). ## Commit conventions diff --git a/ci/version.py b/ci/version.py index 59018bc4..41267fd7 100755 --- a/ci/version.py +++ b/ci/version.py @@ -114,8 +114,8 @@ def escape(s): frm = line[1:] if not lines[index + 1].startswith("+"): print( - f"Error: expecting -+ line pairs on lines {index+1} " - f"and {index+2} of `git diff`" + f"Error: expecting -+ line pairs on lines {index + 1} " + f"and {index + 2} of `git diff`" ) sys.exit(1) to = lines[index + 1][1:] @@ -124,7 +124,7 @@ def escape(s): or to.replace(dummy_version, current_version) != frm ): print( - f"Error: diff at lines {index+1} and {index+2} of git " + f"Error: diff at lines {index + 1} and {index + 2} of git " f"diff is not just a change from {current_version} to " f"{dummy_version}" ) diff --git a/py/tests/test_api.py b/py/tests/test_api.py index 8c3dd730..f889976d 100644 --- a/py/tests/test_api.py +++ b/py/tests/test_api.py @@ -51,19 +51,19 @@ def test_proto_roundtrip(): def test_parsing(): """Test the parsing function.""" result = sv.plan_to_parse_result(BASIC_PLAN) - assert type(result) == sv.ParseResult + assert isinstance(result, sv.ParseResult) root = sv.parse_plan(BASIC_PLAN) - assert type(root) == sv.ParseResult + assert isinstance(root, sv.ParseResult) root = sv.plan_to_parse_result(BASIC_PLAN) - assert type(root) == sv.ParseResult + assert isinstance(root, sv.ParseResult) def test_export_html(): """Test the HTML export function.""" html = sv.plan_to_html(BASIC_PLAN) - assert type(html) == str + assert isinstance(html, str) lines = list(filter(bool, html.split("\n"))) assert lines[0] == "" assert lines[-1] == "" @@ -72,11 +72,11 @@ def test_export_html(): def test_export_diags(): """Test the diagnostics export functions.""" diags = sv.plan_to_diagnostics_str(BASIC_PLAN) - assert type(diags) == str + assert isinstance(diags, str) diags = list(sv.plan_to_diagnostics(BASIC_PLAN)) for diag in diags: - assert type(diag) == sv.Diagnostic + assert isinstance(diag, sv.Diagnostic) def test_valid_invalid():