diff --git a/.editorconfig b/.editorconfig index 11c29680d7..843bd1f3ad 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ indent_style = space insert_final_newline = true indent_size = 2 -[*.{rs,py}] +[*.{rs,py,pyi}] indent_size = 4 [*.snap] diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 67412d272c..eea20ebbe8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,8 +4,10 @@ updates: directory: "/" schedule: interval: "weekly" - day: "monday" - time: "12:00" - timezone: "America/New_York" - commit-message: - prefix: "ci(deps)" + labels: ["internal"] + + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "daily" + labels: ["internal"] diff --git a/.github/release.yml b/.github/release.yml index ea43f8b3f7..7b7737791d 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -20,6 +20,9 @@ changelog: - title: Bug Fixes labels: - bug + - title: Preview + labels: + - preview - title: Other Changes labels: - "*" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7575fc3875..ef17f2df33 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,11 +26,11 @@ jobs: linter: ${{ steps.changed.outputs.linter_any_changed }} formatter: ${{ steps.changed.outputs.formatter_any_changed }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: tj-actions/changed-files@v38 + - uses: tj-actions/changed-files@v39 id: changed with: files_yaml: | @@ -62,7 +62,7 @@ jobs: name: "cargo fmt" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup component add rustfmt - run: cargo fmt --all --check @@ -71,7 +71,7 @@ jobs: name: "cargo clippy" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: | rustup component add clippy @@ -89,7 +89,7 @@ jobs: runs-on: ${{ matrix.os }} name: "cargo test | ${{ matrix.os }}" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup show - name: "Install cargo insta" @@ -125,7 +125,7 @@ jobs: runs-on: ubuntu-latest name: "cargo fuzz" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup show - uses: Swatinem/rust-cache@v2 @@ -141,7 +141,7 @@ jobs: runs-on: ubuntu-latest name: "cargo test (wasm)" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup target add wasm32-unknown-unknown - uses: actions/setup-node@v3 @@ -160,7 +160,7 @@ jobs: name: "test scripts" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup component add rustfmt - uses: Swatinem/rust-cache@v2 @@ -182,7 +182,7 @@ jobs: # Only runs on pull requests, since that is the only we way we can find the base version for comparison. if: github.event_name == 'pull_request' && needs.determine_changes.outputs.linter == 'true' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -227,7 +227,7 @@ jobs: name: "cargo udeps" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install nightly Rust toolchain" # Only pinned to make caching work, update freely run: rustup toolchain install nightly-2023-06-08 @@ -241,7 +241,7 @@ jobs: name: "python package" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -265,7 +265,7 @@ jobs: name: "pre-commit" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -295,7 +295,7 @@ jobs: env: MKDOCS_INSIDERS_SSH_KEY_EXISTS: ${{ secrets.MKDOCS_INSIDERS_SSH_KEY != '' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 - name: "Add SSH key" if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }} @@ -330,7 +330,7 @@ jobs: needs: determine_changes if: needs.determine_changes.outputs.formatter == 'true' || github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup show - name: "Cache rust" @@ -346,7 +346,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Checkout Branch" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup show diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index e340f0aa5a..22443cac89 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -2,6 +2,11 @@ name: mkdocs on: workflow_dispatch: + inputs: + ref: + description: "The commit SHA, tag, or branch to publish. Uses the default branch if not specified." + default: "" + type: string release: types: [published] @@ -12,7 +17,9 @@ jobs: CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }} MKDOCS_INSIDERS_SSH_KEY_EXISTS: ${{ secrets.MKDOCS_INSIDERS_SSH_KEY != '' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} - uses: actions/setup-python@v4 - name: "Add SSH key" if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }} @@ -40,8 +47,9 @@ jobs: run: mkdocs build --strict -f mkdocs.generated.yml - name: "Deploy to Cloudflare Pages" if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }} - uses: cloudflare/wrangler-action@v3.1.0 + uses: cloudflare/wrangler-action@v3.1.1 with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{ secrets.CF_ACCOUNT_ID }} - command: pages publish site --project-name=ruff-docs --branch ${GITHUB_HEAD_REF} --commit-hash ${GITHUB_SHA} + # `github.head_ref` is only set during pull requests and for manual runs or tags we use `main` to deploy to production + command: pages deploy site --project-name=ruff-docs --branch ${{ github.head_ref || 'main' }} --commit-hash ${GITHUB_SHA} diff --git a/.github/workflows/flake8-to-ruff.yaml b/.github/workflows/flake8-to-ruff.yaml index 8bd34be65c..feb1c2825a 100644 --- a/.github/workflows/flake8-to-ruff.yaml +++ b/.github/workflows/flake8-to-ruff.yaml @@ -19,7 +19,7 @@ jobs: macos-x86_64: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -42,7 +42,7 @@ jobs: macos-universal: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -68,7 +68,7 @@ jobs: matrix: target: [x64, x86] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -96,7 +96,7 @@ jobs: matrix: target: [x86_64, i686] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -123,7 +123,7 @@ jobs: matrix: target: [aarch64, armv7, s390x, ppc64le, ppc64] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -160,7 +160,7 @@ jobs: - x86_64-unknown-linux-musl - i686-unknown-linux-musl steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -196,7 +196,7 @@ jobs: - target: armv7-unknown-linux-musleabihf arch: armv7 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} diff --git a/.github/workflows/playground.yaml b/.github/workflows/playground.yaml index 1c1e2ec857..f1222c6c5c 100644 --- a/.github/workflows/playground.yaml +++ b/.github/workflows/playground.yaml @@ -17,7 +17,7 @@ jobs: env: CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install Rust toolchain" run: rustup target add wasm32-unknown-unknown - uses: actions/setup-node@v3 @@ -40,7 +40,7 @@ jobs: working-directory: playground - name: "Deploy to Cloudflare Pages" if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }} - uses: cloudflare/wrangler-action@v3.1.0 + uses: cloudflare/wrangler-action@v3.1.1 with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{ secrets.CF_ACCOUNT_ID }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 83c1679cb2..b8976da26e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,12 +7,15 @@ on: description: "The version to tag, without the leading 'v'. If omitted, will initiate a dry run (no uploads)." type: string sha: - description: "Optionally, the full sha of the commit to be released" + description: "The full sha of the commit to be released. If omitted, the latest commit on the default branch will be used." + default: "" type: string pull_request: paths: # When we change pyproject.toml, we want to ensure that the maturin builds still work - pyproject.toml + # And when we change this workflow itself... + - .github/workflows/release.yaml concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -30,7 +33,9 @@ jobs: sdist: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -56,7 +61,9 @@ jobs: macos-x86_64: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -94,7 +101,9 @@ jobs: macos-universal: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -140,7 +149,9 @@ jobs: - target: aarch64-pc-windows-msvc arch: x64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -186,7 +197,9 @@ jobs: - x86_64-unknown-linux-gnu - i686-unknown-linux-gnu steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -243,7 +256,9 @@ jobs: arch: ppc64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -296,7 +311,9 @@ jobs: - x86_64-unknown-linux-musl - i686-unknown-linux-musl steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -350,7 +367,9 @@ jobs: arch: armv7 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} @@ -398,7 +417,9 @@ jobs: # If you don't set an input tag, it's a dry run (no uploads). if: ${{ inputs.tag }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - name: Check tag consistency run: | version=$(grep "version = " pyproject.toml | sed -e 's/version = "\(.*\)"/\1/g') @@ -410,6 +431,15 @@ jobs: else echo "Releasing ${version}" fi + - name: Check main branch + if: ${{ inputs.sha }} + run: | + # Fetch the main branch since a shallow checkout is used by default + git fetch origin main --unshallow + if ! git branch --contains ${{ inputs.sha }} | grep -E '(^|\s)main$'; then + echo "The specified sha is not on the main branch" >&2 + exit 1 + fi - name: Check SHA consistency if: ${{ inputs.sha }} run: | @@ -464,7 +494,9 @@ jobs: # For git tag contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.sha }} - name: git tag run: | git config user.email "hey@astral.sh" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5d0b2d9a8..d2ec61a421 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,8 +23,6 @@ repos: - id: mdformat additional_dependencies: - mdformat-mkdocs - - mdformat-black - - black==23.1.0 # Must be the latest version of Black - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.33.0 diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index c10e07250f..bdda6f93f9 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -1,5 +1,20 @@ # Breaking Changes +## 0.0.288 + +### Remove support for emoji identifiers ([#7212](https://github.com/astral-sh/ruff/pull/7212)) + +Previously, Ruff supported the non-standard compliant emoji identifiers e.g. `📦 = 1`. +We decided to remove this non-standard language extension, and Ruff now reports syntax errors for emoji identifiers in your code, the same as CPython. + +### Improved GitLab fingerprints ([#7203](https://github.com/astral-sh/ruff/pull/7203)) + +GitLab uses fingerprints to identify new, existing, or fixed violations. Previously, Ruff included the violation's position in the fingerprint. Using the location has the downside that changing any code before the violation causes the fingerprint to change, resulting in GitLab reporting one fixed and one new violation even though it is a pre-existing violation. + +Ruff now uses a more stable location-agnostic fingerprint to minimize that existing violations incorrectly get marked as fixed and re-reported as new violations. + +Expect GitLab to report each pre-existing violation in your project as fixed and a new violation in your Ruff upgrade PR. + ## 0.0.283 / 0.284 ### The target Python version now defaults to 3.8 instead of 3.10 ([#6397](https://github.com/astral-sh/ruff/pull/6397)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6250515efd..674e41578c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,6 +129,7 @@ At time of writing, the repository includes the following crates: intermediate representation. The backend for `ruff_python_formatter`. - `crates/ruff_index`: library crate inspired by `rustc_index`. - `crates/ruff_macros`: proc macro crate containing macros used by Ruff. +- `crates/ruff_notebook`: library crate for parsing and manipulating Jupyter notebooks. - `crates/ruff_python_ast`: library crate containing Python-specific AST types and utilities. - `crates/ruff_python_codegen`: library crate containing utilities for generating Python source code. - `crates/ruff_python_formatter`: library crate implementing the Python formatter. Emits an diff --git a/Cargo.lock b/Cargo.lock index 24f7e2ccc2..a8b182b0fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,18 +28,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "aho-corasick" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -83,24 +74,23 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" @@ -122,9 +112,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -132,16 +122,17 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "argfile" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "265f5108974489a217d5098cd81666b60480c8dd67302acbbe7cbdd8aa09d638" +checksum = "1287c4f82a41c5085e65ee337c7934d71ab43d5187740a81fb69129013f6a5f6" dependencies = [ + "fs-err", "os_str_bytes", ] @@ -162,9 +153,9 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" +checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" dependencies = [ "anstyle", "bstr", @@ -183,9 +174,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "bincode" @@ -219,18 +210,18 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bstr" -version = "1.6.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", - "regex-automata 0.3.0", + "regex-automata 0.3.7", "serde", ] @@ -257,9 +248,12 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -278,18 +272,17 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "serde", - "time 0.1.45", + "time", "wasm-bindgen", - "winapi", + "windows-targets 0.48.5", ] [[package]] @@ -321,9 +314,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.11" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" dependencies = [ "clap_builder", "clap_derive", @@ -332,9 +325,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" dependencies = [ "anstream", "anstyle", @@ -344,9 +337,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.3.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" +checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ "clap", ] @@ -365,9 +358,9 @@ dependencies = [ [[package]] name = "clap_complete_fig" -version = "4.3.1" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fee1d30a51305a6c2ed3fc5709be3c8af626c9c958e04dd9ae94e27bcbce9f" +checksum = "9e9bae21b3f6eb417ad3054c8b1094aa0542116eba4979b1b271baefbfa6b965" dependencies = [ "clap", "clap_complete", @@ -385,21 +378,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "clearscreen" @@ -416,9 +409,9 @@ dependencies = [ [[package]] name = "codspeed" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeec2fbed4969dc38b5ca201115dd5c2614b8ef78e0a7221dd5f0977fb1552b" +checksum = "9b3238416c10f19985b52a937c5b3efc3ed7efe8f7ae263d2aab29a09bca9f57" dependencies = [ "colored", "libc", @@ -427,9 +420,9 @@ dependencies = [ [[package]] name = "codspeed-criterion-compat" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b13f0a08d40ce7c95bdf288f725b975e62fcadfa8ba152340943bab6de43af7" +checksum = "fecc18f65b942d2b033545bb3bd8430a23eecbbe53fad3b1342fb0e5514bca7b" dependencies = [ "codspeed", "colored", @@ -529,8 +522,6 @@ dependencies = [ "num-traits", "once_cell", "oorandom", - "plotters", - "rayon", "regex", "serde", "serde_derive", @@ -598,21 +589,11 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "darling" -version = "0.20.1" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ "darling_core", "darling_macro", @@ -620,27 +601,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.1" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] name = "darling_macro" -version = "0.20.1" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] @@ -731,15 +712,15 @@ checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1" [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "ena" @@ -771,15 +752,15 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -798,12 +779,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fern" @@ -816,13 +794,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -834,7 +812,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flake8-to-ruff" -version = "0.0.286" +version = "0.0.289" dependencies = [ "anyhow", "clap", @@ -858,9 +836,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "miniz_oxide", @@ -917,11 +895,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -958,12 +936,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hexf-parse" version = "0.2.1" @@ -1044,25 +1016,14 @@ dependencies = [ [[package]] name = "imperative" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f92123bf2fe0d9f1b5df1964727b970ca3b2d0203d47cf97fb1f36d856b6398" +checksum = "8b70798296d538cdaa6d652941fcc795963f8b9878b9e300c9fab7a522bd2fc0" dependencies = [ "phf", "rust-stemmers", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.0.0" @@ -1071,13 +1032,14 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", "hashbrown 0.14.0", + "serde", ] [[package]] name = "indicatif" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057" +checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" dependencies = [ "console", "instant", @@ -1124,11 +1086,23 @@ dependencies = [ "lazy_static", "linked-hash-map", "regex", + "serde", "similar", "walkdir", "yaml-rust", ] +[[package]] +name = "insta-cmd" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809d3023d1d6e8d5c2206f199251f75cb26180e41f18cb0f22dd119161cb5127" +dependencies = [ + "insta", + "serde", + "serde_json", +] + [[package]] name = "instant" version = "0.1.12" @@ -1138,38 +1112,27 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-macro" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7d079e129b77477a49c5c4f1cfe9ce6c2c909ef52520693e8e811a714c7b20" +checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" dependencies = [ "Inflector", - "pmutil", + "pmutil 0.6.1", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] name = "is-terminal" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.3", + "rustix", "windows-sys 0.48.0", ] @@ -1184,9 +1147,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" @@ -1199,9 +1162,9 @@ dependencies = [ [[package]] name = "kqueue" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c8fc60ba15bf51257aa9807a48a61013db043fcf3a78cb0d916e8e396dcad98" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" dependencies = [ "kqueue-sys", "libc", @@ -1209,9 +1172,9 @@ dependencies = [ [[package]] name = "kqueue-sys" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" dependencies = [ "bitflags 1.3.2", "libc", @@ -1232,7 +1195,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.7.3", + "regex-syntax 0.7.5", "string_cache", "term", "tiny-keccak", @@ -1290,12 +1253,12 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libcst" version = "0.1.0" -source = "git+https://github.com/Instagram/LibCST.git?rev=3cacca1a1029f05707e50703b49fe3dd860aa839#3cacca1a1029f05707e50703b49fe3dd860aa839" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7773d520d4292e200ab1838f2daabe2feed7549f93b0a3c7582160a09e79ffde" dependencies = [ "chic", - "itertools", "libcst_derive", - "once_cell", + "memchr", "paste", "peg", "regex", @@ -1305,7 +1268,8 @@ dependencies = [ [[package]] name = "libcst_derive" version = "0.1.0" -source = "git+https://github.com/Instagram/LibCST.git?rev=3cacca1a1029f05707e50703b49fe3dd860aa839#3cacca1a1029f05707e50703b49fe3dd860aa839" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520197c50ba477f258cd7005ec5ed3a7393693ae6bec664990c7c8d9306a7c0d" dependencies = [ "quote", "syn 1.0.109", @@ -1313,9 +1277,9 @@ dependencies = [ [[package]] name = "libmimalloc-sys" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ac0e912c8ef1b735e92369695618dc5b1819f5a7bf3f167301a3ba1cea515e" +checksum = "25d058a81af0d1c22d7a1c948576bee6d673f7af3c0f35564abd6c81122f513d" dependencies = [ "cc", "libc", @@ -1329,15 +1293,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[package]] name = "lock_api" @@ -1351,9 +1309,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "matchers" @@ -1372,9 +1330,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memoffset" @@ -1387,9 +1345,9 @@ dependencies = [ [[package]] name = "mimalloc" -version = "0.1.37" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2894987a3459f3ffb755608bd82188f8ed00d0ae077f1edea29c068d639d98" +checksum = "972e5f23f6716f62665760b0f4cbf592576a80c7b879ba9beaafc0e558894127" dependencies = [ "libmimalloc-sys", ] @@ -1441,14 +1399,13 @@ checksum = "d906846a98739ed9d73d66e62c2641eef8321f1734b7a1156ab045a0248fb2b3" [[package]] name = "nix" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "static_assertions", ] [[package]] @@ -1491,9 +1448,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -1512,9 +1469,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -1562,15 +1519,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] - [[package]] name = "overload" version = "0.1.1" @@ -1597,29 +1545,29 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] name = "paste" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "path-absolutize" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43eb3595c63a214e1b37b44f44b0a84900ef7ae0b4c5efce59e123d246d7a0de" +checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" dependencies = [ "path-dedot", ] [[package]] name = "path-dedot" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d55e486337acb9973cdea3ec5638c1b3bcb22e573b2b7b41969e0c744d5a15e" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" dependencies = [ "once_cell", ] @@ -1693,12 +1641,12 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap", ] [[package]] @@ -1750,37 +1698,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" - -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pmutil" @@ -1794,10 +1714,21 @@ dependencies = [ ] [[package]] -name = "portable-atomic" -version = "1.3.3" +name = "pmutil" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" +checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "portable-atomic" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" [[package]] name = "ppv-lite86" @@ -1841,13 +1772,11 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ - "ctor", "diff", - "output_vt100", "yansi", ] @@ -1877,20 +1806,20 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "pyproject-toml" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee79feaa9d31e1c417e34219e610b67db4e786ce9b49d77dda549640abb9dc5f" +checksum = "569e259cd132eb8cec5df8b672d187c5260f82ad352156b5da9549d4472e64b0" dependencies = [ - "indexmap 1.9.3", + "indexmap", "pep440_rs", "pep508_rs", "serde", @@ -1899,12 +1828,12 @@ dependencies = [ [[package]] name = "quick-junit" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b909fe9bf2abb1e3d6a97c9189a37c8105c61d03dca9ce6aace023e7d682bd" +checksum = "6bf780b59d590c25f8c59b44c124166a2a93587868b619fb8f5b47fb15e9ed6d" dependencies = [ "chrono", - "indexmap 1.9.3", + "indexmap", "nextest-workspace-hack", "quick-xml", "thiserror", @@ -1913,18 +1842,18 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.26.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.29" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -2012,14 +1941,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89089e897c013b3deb627116ae56a6955a72b8bed395c9526af31c9fe528b484" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", - "regex-automata 0.3.0", - "regex-syntax 0.7.3", + "regex-automata 0.3.7", + "regex-syntax 0.7.5", ] [[package]] @@ -2033,13 +1962,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.0" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa250384981ea14565685dea16a9ccc4d1c541a13f82b9c168572264d1df8c56" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", - "regex-syntax 0.7.3", + "regex-syntax 0.7.5", ] [[package]] @@ -2050,9 +1979,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.3" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "result-like" @@ -2069,7 +1998,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fabf0a2e54f711c68c50d49f648a1a8a37adcb57353f518ac4df374f0788f42" dependencies = [ - "pmutil", + "pmutil 0.5.3", "proc-macro2", "quote", "syn 1.0.109", @@ -2093,11 +2022,11 @@ dependencies = [ [[package]] name = "ruff" -version = "0.0.286" +version = "0.0.289" dependencies = [ "annotate-snippets 0.9.1", "anyhow", - "bitflags 2.3.3", + "bitflags 2.4.0", "chrono", "clap", "colored", @@ -2127,6 +2056,7 @@ dependencies = [ "ruff_diagnostics", "ruff_index", "ruff_macros", + "ruff_notebook", "ruff_python_ast", "ruff_python_codegen", "ruff_python_index", @@ -2142,7 +2072,6 @@ dependencies = [ "semver", "serde", "serde_json", - "serde_with", "similar", "smallvec", "strum", @@ -2154,7 +2083,6 @@ dependencies = [ "typed-arena", "unicode-width", "unicode_names2", - "uuid", "wsl", ] @@ -2192,14 +2120,14 @@ dependencies = [ [[package]] name = "ruff_cli" -version = "0.0.286" +version = "0.0.289" dependencies = [ "annotate-snippets 0.9.1", "anyhow", "argfile", "assert_cmd", "bincode", - "bitflags 2.3.3", + "bitflags 2.4.0", "cachedir", "chrono", "clap", @@ -2210,6 +2138,7 @@ dependencies = [ "glob", "ignore", "insta", + "insta-cmd", "is-macro", "itertools", "itoa", @@ -2224,6 +2153,7 @@ dependencies = [ "ruff_diagnostics", "ruff_formatter", "ruff_macros", + "ruff_notebook", "ruff_python_ast", "ruff_python_formatter", "ruff_python_stdlib", @@ -2238,6 +2168,7 @@ dependencies = [ "similar", "strum", "tempfile", + "test-case", "thiserror", "tikv-jemallocator", "tracing", @@ -2266,6 +2197,7 @@ dependencies = [ "ruff_cli", "ruff_diagnostics", "ruff_formatter", + "ruff_notebook", "ruff_python_ast", "ruff_python_codegen", "ruff_python_formatter", @@ -2328,16 +2260,36 @@ dependencies = [ "proc-macro2", "quote", "ruff_python_trivia", - "syn 2.0.23", + "syn 2.0.29", +] + +[[package]] +name = "ruff_notebook" +version = "0.0.0" +dependencies = [ + "anyhow", + "insta", + "itertools", + "once_cell", + "ruff_diagnostics", + "ruff_source_file", + "ruff_text_size", + "serde", + "serde_json", + "serde_with", + "test-case", + "thiserror", + "uuid", ] [[package]] name = "ruff_python_ast" version = "0.0.0" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "insta", "is-macro", + "itertools", "memchr", "num-bigint", "num-traits", @@ -2368,11 +2320,10 @@ name = "ruff_python_formatter" version = "0.0.0" dependencies = [ "anyhow", - "bitflags 2.3.3", + "bitflags 2.4.0", "clap", "countme", "insta", - "is-macro", "itertools", "memchr", "once_cell", @@ -2388,7 +2339,9 @@ dependencies = [ "serde_json", "similar", "smallvec", + "static_assertions", "thiserror", + "tracing", "unicode-width", ] @@ -2408,7 +2361,7 @@ dependencies = [ name = "ruff_python_literal" version = "0.0.0" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "hexf-parse", "is-macro", "itertools", @@ -2434,10 +2387,8 @@ dependencies = [ "ruff_text_size", "rustc-hash", "static_assertions", - "test-case", "tiny-keccak", - "unic-emoji-char", - "unic-ucd-ident", + "unicode-ident", "unicode_names2", ] @@ -2455,7 +2406,7 @@ dependencies = [ name = "ruff_python_semantic" version = "0.0.0" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "is-macro", "num-traits", "ruff_index", @@ -2471,6 +2422,9 @@ dependencies = [ [[package]] name = "ruff_python_stdlib" version = "0.0.0" +dependencies = [ + "unicode-ident", +] [[package]] name = "ruff_python_trivia" @@ -2483,7 +2437,7 @@ dependencies = [ "ruff_source_file", "ruff_text_size", "smallvec", - "unic-ucd-ident", + "unicode-ident", ] [[package]] @@ -2593,48 +2547,44 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.37.23" +version = "0.38.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" -dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.3", + "linux-raw-sys", "windows-sys 0.48.0", ] [[package]] name = "rustls" -version = "0.21.2" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e32ca28af694bc1bbf399c33a516dbdf1c90090b8ab23c2bc24f834aa2247f5f" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.4", "sct", ] [[package]] name = "rustls-webpki" -version = "0.100.1" +version = "0.100.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ "ring", "untrusted", @@ -2642,15 +2592,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -2663,9 +2613,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "dyn-clone", "schemars_derive", @@ -2675,9 +2625,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", "quote", @@ -2693,9 +2643,9 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" @@ -2709,15 +2659,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.166" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -2735,13 +2685,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.166" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] @@ -2757,9 +2707,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" dependencies = [ "itoa", "ryu", @@ -2786,30 +2736,24 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.0.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02d8aa6e3c385bf084924f660ce2a3a6bd333ba55b35e8590b321f35d88513" +checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64", - "chrono", - "hex", - "indexmap 1.9.3", "serde", - "serde_json", "serde_with_macros", - "time 0.3.22", ] [[package]] name = "serde_with_macros" -version = "3.0.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc7d5d3932fb12ce722ee5e64dd38c504efba37567f0c402f6ca728c3b8b070" +checksum = "2e6be15c453eb305019bfa438b1593c731f36a289a7853f7707ee29e870b3b3c" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] @@ -2844,15 +2788,15 @@ checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "spin" @@ -2887,24 +2831,24 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 1.0.109", + "syn 2.0.29", ] [[package]] @@ -2920,9 +2864,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.23" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -2940,15 +2884,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.6.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.23", + "rustix", "windows-sys 0.48.0", ] @@ -3028,22 +2971,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] @@ -3058,9 +3001,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", @@ -3068,9 +3011,9 @@ dependencies = [ [[package]] name = "tikv-jemallocator" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" dependencies = [ "libc", "tikv-jemalloc-sys", @@ -3087,33 +3030,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" -dependencies = [ - "time-core", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -3150,9 +3066,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebafdf5ad1220cb59e7d17cf4d2c72015297b75b19a10472f99b89225089240" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -3171,11 +3087,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.11" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap 2.0.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -3203,7 +3119,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] @@ -3218,9 +3134,9 @@ dependencies = [ [[package]] name = "tracing-indicatif" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38ed3722d27705c3bd7ca0ccf29acc3d8e1c717b4cd87f97891a2c1834ea1af" +checksum = "57e05fe4a1c906d94b275d8aeb8ff8b9deaca502aeb59ae8ab500a92b8032ac8" dependencies = [ "indicatif", "tracing", @@ -3284,17 +3200,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" -[[package]] -name = "unic-emoji-char" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b07221e68897210270a38bde4babb655869637af0f69407f96053a34f76494d" -dependencies = [ - "unic-char-property", - "unic-char-range", - "unic-ucd-version", -] - [[package]] name = "unic-ucd-category" version = "0.9.0" @@ -3307,17 +3212,6 @@ dependencies = [ "unic-ucd-version", ] -[[package]] -name = "unic-ucd-ident" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" -dependencies = [ - "unic-char-property", - "unic-char-range", - "unic-ucd-version", -] - [[package]] name = "unic-ucd-version" version = "0.9.0" @@ -3335,9 +3229,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -3385,16 +3279,16 @@ dependencies = [ "log", "once_cell", "rustls", - "rustls-webpki", + "rustls-webpki 0.100.2", "url", "webpki-roots", ] [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -3428,7 +3322,7 @@ checksum = "f7e1ba1f333bd65ce3c9f27de592fcbc256dafe3af2717f56d7c87761fbaccf4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", ] [[package]] @@ -3487,9 +3381,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -3528,7 +3422,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -3562,7 +3456,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.23", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3613,7 +3507,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki", + "rustls-webpki 0.100.2", ] [[package]] @@ -3673,7 +3567,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -3691,7 +3585,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -3711,17 +3605,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -3732,9 +3626,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -3744,9 +3638,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -3756,9 +3650,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -3768,9 +3662,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -3780,9 +3674,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -3792,9 +3686,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -3804,15 +3698,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.7" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index ae97f5676f..f50c041a1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,26 +22,27 @@ glob = { version = "0.3.1" } globset = { version = "0.4.10" } ignore = { version = "0.4.20" } insta = { version = "1.31.0", feature = ["filters", "glob"] } -is-macro = { version = "0.2.2" } +is-macro = { version = "0.3.0" } itertools = { version = "0.10.5" } log = { version = "0.4.17" } -memchr = "2.5.0" +memchr = "2.6.3" num-bigint = { version = "0.4.3" } num-traits = { version = "0.2.15" } once_cell = { version = "1.17.1" } -path-absolutize = { version = "3.0.14" } +path-absolutize = { version = "3.1.1" } proc-macro2 = { version = "1.0.51" } quote = { version = "1.0.23" } regex = { version = "1.7.1" } rustc-hash = { version = "1.1.0" } schemars = { version = "0.8.12" } serde = { version = "1.0.152", features = ["derive"] } -serde_json = { version = "1.0.93" } +serde_json = { version = "1.0.106" } shellexpand = { version = "3.0.0" } similar = { version = "2.2.1", features = ["inline"] } smallvec = { version = "1.10.0" } -strum = { version = "0.24.1", features = ["strum_macros"] } -strum_macros = { version = "0.24.3" } +static_assertions = "1.1.0" +strum = { version = "0.25.0", features = ["strum_macros"] } +strum_macros = { version = "0.25.2" } syn = { version = "2.0.15" } test-case = { version = "3.0.0" } thiserror = { version = "1.0.43" } @@ -49,12 +50,13 @@ toml = { version = "0.7.2" } tracing = "0.1.37" tracing-indicatif = "0.3.4" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } +unicode-ident = "1.0.11" unicode-width = "0.1.10" uuid = { version = "1.4.1", features = ["v4", "fast-rng", "macro-diagnostics", "js"] } wsl = { version = "0.1.0" } # v1.0.1 -libcst = { git = "https://github.com/Instagram/LibCST.git", rev = "3cacca1a1029f05707e50703b49fe3dd860aa839", default-features = false } +libcst = { version = "0.1.0", default-features = false } [profile.release] lto = "fat" diff --git a/README.md b/README.md index 9e3fe2029e..98a5d8a3c7 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com) hook: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.286 + rev: v0.0.289 hooks: - id: ruff ``` @@ -398,6 +398,7 @@ Ruff is used by a number of major open-source projects and companies, including: - [Pydantic](https://github.com/pydantic/pydantic) - [Pylint](https://github.com/PyCQA/pylint) - [Reflex](https://github.com/reflex-dev/reflex) +- [Rippling](https://rippling.com) - [Robyn](https://github.com/sansyrox/robyn) - Scale AI ([Launch SDK](https://github.com/scaleapi/launch-python-client)) - Snowflake ([SnowCLI](https://github.com/Snowflake-Labs/snowcli)) diff --git a/crates/flake8_to_ruff/Cargo.toml b/crates/flake8_to_ruff/Cargo.toml index 91c8695e6b..c8d47dbf65 100644 --- a/crates/flake8_to_ruff/Cargo.toml +++ b/crates/flake8_to_ruff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flake8-to-ruff" -version = "0.0.286" +version = "0.0.289" description = """ Convert Flake8 configuration files to Ruff configuration files. """ diff --git a/crates/flake8_to_ruff/src/plugin.rs b/crates/flake8_to_ruff/src/plugin.rs index 2c0109e987..4c43dbabfe 100644 --- a/crates/flake8_to_ruff/src/plugin.rs +++ b/crates/flake8_to_ruff/src/plugin.rs @@ -4,6 +4,7 @@ use std::str::FromStr; use anyhow::anyhow; use ruff::registry::Linter; +use ruff::settings::types::PreviewMode; use ruff::RuleSelector; #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] @@ -331,7 +332,7 @@ pub(crate) fn infer_plugins_from_codes(selectors: &HashSet) -> Vec .filter(|plugin| { for selector in selectors { if selector - .into_iter() + .rules(PreviewMode::Disabled) .any(|rule| Linter::from(plugin).rules().any(|r| r == rule)) { return true; diff --git a/crates/ruff/Cargo.toml b/crates/ruff/Cargo.toml index 7b9d30ebfd..ab41dd7b27 100644 --- a/crates/ruff/Cargo.toml +++ b/crates/ruff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruff" -version = "0.0.286" +version = "0.0.289" publish = false authors = { workspace = true } edition = { workspace = true } @@ -18,6 +18,7 @@ name = "ruff" ruff_cache = { path = "../ruff_cache" } ruff_diagnostics = { path = "../ruff_diagnostics", features = ["serde"] } ruff_index = { path = "../ruff_index" } +ruff_notebook = { path = "../ruff_notebook" } ruff_macros = { path = "../ruff_macros" } ruff_python_ast = { path = "../ruff_python_ast", features = ["serde"] } ruff_python_codegen = { path = "../ruff_python_codegen" } @@ -55,7 +56,7 @@ path-absolutize = { workspace = true, features = [ ] } pathdiff = { version = "0.2.1" } pep440_rs = { version = "0.3.1", features = ["serde"] } -pyproject-toml = { version = "0.6.0" } +pyproject-toml = { version = "0.7.0" } quick-junit = { version = "0.3.2" } regex = { workspace = true } result-like = { version = "0.4.6" } @@ -64,17 +65,15 @@ schemars = { workspace = true, optional = true } semver = { version = "1.0.16" } serde = { workspace = true } serde_json = { workspace = true } -serde_with = { version = "3.0.0" } similar = { workspace = true } smallvec = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } -thiserror = { version = "1.0.43" } +thiserror = { workspace = true } toml = { workspace = true } typed-arena = { version = "2.0.2" } unicode-width = { workspace = true } unicode_names2 = { version = "0.6.0", git = "https://github.com/youknowone/unicode_names2.git", rev = "4ce16aa85cbcdd9cc830410f1a72ef9a235f2fde" } -uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics", "js"] } wsl = { version = "0.1.0" } [dev-dependencies] diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_1.py b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_1.py new file mode 100644 index 0000000000..68487f8c8f --- /dev/null +++ b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_1.py @@ -0,0 +1,5 @@ +# Docstring followed by a newline + +def foobar(foor, bar={}): + """ + """ diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_2.py b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_2.py new file mode 100644 index 0000000000..e723231f4c --- /dev/null +++ b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_2.py @@ -0,0 +1,6 @@ +# Docstring followed by whitespace with no newline +# Regression test for https://github.com/astral-sh/ruff/issues/7155 + +def foobar(foor, bar={}): + """ + """ \ No newline at end of file diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_3.py b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_3.py new file mode 100644 index 0000000000..1106f17036 --- /dev/null +++ b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_3.py @@ -0,0 +1,6 @@ +# Docstring with no newline + + +def foobar(foor, bar={}): + """ + """ \ No newline at end of file diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_B008.py b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_B008.py index 4b8f8b925b..77ab80b7ee 100644 --- a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_B008.py +++ b/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_B008.py @@ -308,3 +308,7 @@ def single_line_func_wrong(value: dict[str, str] = { def single_line_func_wrong(value: dict[str, str] = {}) \ : \ """Docstring""" + + +def single_line_func_wrong(value: dict[str, str] = {}): + """Docstring without newline""" \ No newline at end of file diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B009_B010.py b/crates/ruff/resources/test/fixtures/flake8_bugbear/B009_B010.py index 623ddc6c96..05efa43712 100644 --- a/crates/ruff/resources/test/fixtures/flake8_bugbear/B009_B010.py +++ b/crates/ruff/resources/test/fixtures/flake8_bugbear/B009_B010.py @@ -1,7 +1,7 @@ """ Should emit: -B009 - Line 19, 20, 21, 22, 23, 24 -B010 - Line 40, 41, 42, 43, 44, 45 +B009 - Lines 19-31 +B010 - Lines 40-45 """ # Valid getattr usage @@ -24,6 +24,16 @@ getattr(foo, r"abc123") _ = lambda x: getattr(x, "bar") if getattr(x, "bar"): pass +getattr(1, "real") +getattr(1., "real") +getattr(1.0, "real") +getattr(1j, "real") +getattr(True, "real") +getattr(x := 1, "real") +getattr(x + y, "real") +getattr("foo" + "bar", "real") + # Valid setattr usage setattr(foo, bar, None) diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B013.py b/crates/ruff/resources/test/fixtures/flake8_bugbear/B013.py index 27b21bb638..8c0bc1ce78 100644 --- a/crates/ruff/resources/test/fixtures/flake8_bugbear/B013.py +++ b/crates/ruff/resources/test/fixtures/flake8_bugbear/B013.py @@ -1,3 +1,5 @@ +retriable_exceptions = (FileExistsError, FileNotFoundError) + try: pass except (ValueError,): @@ -6,3 +8,7 @@ except AttributeError: pass except (ImportError, TypeError): pass +except (*retriable_exceptions,): + pass +except(ValueError,): + pass diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C402.py b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C402.py index 736bdaff0c..56a1f6cfc8 100644 --- a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C402.py +++ b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C402.py @@ -16,3 +16,6 @@ def f(x): return x print(f'Hello {dict((x,f(x)) for x in "abc")} World') + +# Regression test for: https://github.com/astral-sh/ruff/issues/7086 +dict((k,v)for k,v in d.iteritems() if k in only_args) diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C404.py b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C404.py index a4a6d67bc9..3ad9545844 100644 --- a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C404.py +++ b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C404.py @@ -11,3 +11,6 @@ f"{dict([(s,f(s)) for s in 'ab'])}" f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' + +# Regression test for: https://github.com/astral-sh/ruff/issues/7087 +saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C413.py b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C413.py index b11fbb8ba0..3947868387 100644 --- a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C413.py +++ b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C413.py @@ -8,6 +8,11 @@ reversed(sorted(x, key=lambda e: e, reverse=True)) reversed(sorted(x, reverse=True, key=lambda e: e)) reversed(sorted(x, reverse=False)) +# Regression test for: https://github.com/astral-sh/ruff/issues/7289 +reversed(sorted(i for i in range(42))) +reversed(sorted((i for i in range(42)), reverse=True)) + + def reversed(*args, **kwargs): return None diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.py b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.py index df76e93eb8..6ca19ee574 100644 --- a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.py +++ b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.py @@ -17,3 +17,6 @@ d = {"a": 1, "b": 2, "c": 3} {k.foo: k for k in y} {k["foo"]: k for k in y} {k: v if v else None for k, v in y} + +# Regression test for: https://github.com/astral-sh/ruff/issues/7196 +any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C417.py b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C417.py index daffead2f8..18b6525be6 100644 --- a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C417.py +++ b/crates/ruff/resources/test/fixtures/flake8_comprehensions/C417.py @@ -5,11 +5,13 @@ map(lambda x: str(x), nums) list(map(lambda x: x * 2, nums)) set(map(lambda x: x % 2 == 0, nums)) dict(map(lambda v: (v, v**2), nums)) +dict(map(lambda v: [v, v**2], nums)) map(lambda: "const", nums) map(lambda _: 3.0, nums) _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) all(map(lambda v: isinstance(v, dict), nums)) filter(func, map(lambda v: v, nums)) +list(map(lambda x, y: x * y, nums)) # When inside f-string, then the fix should be surrounded by whitespace _ = f"{set(map(lambda x: x % 2 == 0, nums))}" @@ -40,3 +42,8 @@ map(lambda **kwargs: len(kwargs), range(4)) # Ok because multiple arguments are allowed. dict(map(lambda k, v: (k, v), keys, values)) + +# Regression test for: https://github.com/astral-sh/ruff/issues/7121 +map(lambda x: x, y if y else z) +map(lambda x: x, (y if y else z)) +map(lambda x: x, (x, y, z)) diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.py b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.py index 1c6afa31ad..b8235724c2 100644 --- a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.py +++ b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.py @@ -3,16 +3,20 @@ def bar(): def foo(): - """foo""" # OK + """foo""" # OK, docstrings are handled by another rule def buzz(): - print("buzz") # OK, not in stub file + print("buzz") # ERROR PYI010 def foo2(): - 123 # OK, not in a stub file + 123 # ERROR PYI010 def bizz(): - x = 123 # OK, not in a stub file + x = 123 # ERROR PYI010 + + +def foo3(): + pass # OK, pass is handled by another rule diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.pyi b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.pyi index b49859d824..11346a5196 100644 --- a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.pyi +++ b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.pyi @@ -1,6 +1,6 @@ def bar(): ... # OK def foo(): - """foo""" # OK, strings are handled by another rule + """foo""" # OK, docstrings are handled by another rule def buzz(): print("buzz") # ERROR PYI010 @@ -10,3 +10,6 @@ def foo2(): def bizz(): x = 123 # ERROR PYI010 + +def foo3(): + pass # OK, pass is handled by another rule diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.py b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.py index 8ec21f2d31..350a18120f 100644 --- a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.py +++ b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.py @@ -1,19 +1,27 @@ -def bar(): # OK - ... +def bar(): + ... # OK -def oof(): # OK, docstrings are handled by another rule +def bar(): + pass # OK + + +def bar(): + """oof""" # OK + + +def oof(): # ERROR PYI048 """oof""" print("foo") -def foo(): # Ok not in Stub file +def foo(): # ERROR PYI048 """foo""" print("foo") print("foo") -def buzz(): # Ok not in Stub file +def buzz(): # ERROR PYI048 print("fizz") print("buzz") print("test") diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.pyi b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.pyi index 29a2120f94..fe4246396a 100644 --- a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.pyi +++ b/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.pyi @@ -1,20 +1,20 @@ +def bar(): ... # OK def bar(): - ... # OK + pass # OK +def bar(): + """oof""" # OK -def oof(): # OK, docstrings are handled by another rule - """oof""" - print("foo") +def oof(): # ERROR PYI048 + """oof""" + print("foo") - - -def foo(): # ERROR PYI048 +def foo(): # ERROR PYI048 """foo""" print("foo") print("foo") - -def buzz(): # ERROR PYI048 +def buzz(): # ERROR PYI048 print("fizz") print("buzz") print("test") diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT018.py b/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT018.py index 4b70bae72e..0eafac016e 100644 --- a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT018.py +++ b/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT018.py @@ -52,3 +52,21 @@ def test_multiline(): x = 1; \ assert something and something_else + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7143 +def test_parenthesized_not(): + assert not ( + self.find_graph_output(node.output[0]) + or self.find_graph_input(node.input[0]) + or self.find_graph_output(node.input[0]) + ) + + assert (not ( + self.find_graph_output(node.output[0]) + or self.find_graph_input(node.input[0]) + or self.find_graph_output(node.input[0]) + )) + + assert (not self.find_graph_output(node.output[0]) or + self.find_graph_input(node.input[0])) diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET504.py b/crates/ruff/resources/test/fixtures/flake8_return/RET504.py index 7bd789386a..ef71d178ad 100644 --- a/crates/ruff/resources/test/fixtures/flake8_return/RET504.py +++ b/crates/ruff/resources/test/fixtures/flake8_return/RET504.py @@ -357,3 +357,9 @@ def foo(): def foo(): a = 1 # Comment return a + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7098 +def mavko_debari(P_kbar): + D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 + return D diff --git a/crates/ruff/resources/test/fixtures/flake8_self/SLF001_extended.py b/crates/ruff/resources/test/fixtures/flake8_self/SLF001_extended.py new file mode 100644 index 0000000000..f628137f77 --- /dev/null +++ b/crates/ruff/resources/test/fixtures/flake8_self/SLF001_extended.py @@ -0,0 +1,10 @@ +def foo(obj): + obj._meta # OK + + +def foo(obj): + obj._asdict # SLF001 + + +def foo(obj): + obj._bar # SLF001 diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_0.py b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_0.py index 03f379a01d..7d63806c61 100644 --- a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_0.py +++ b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_0.py @@ -8,6 +8,7 @@ try: except ValueError: pass + # SIM105 try: foo() @@ -110,3 +111,20 @@ try: print() except "not an exception": pass + +# Regression test for: https://github.com/astral-sh/ruff/issues/7123 +def write_models(directory, Models): + try: + os.makedirs(model_dir); + except OSError: + pass; + + try: os.makedirs(model_dir); + except OSError: + pass; + + try: os.makedirs(model_dir); + except OSError: + pass; \ + \ + # diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py index 182412e545..27331ee559 100644 --- a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py +++ b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py @@ -42,3 +42,17 @@ class Foo: def __contains__(self, key: object) -> bool: return key in self.keys() # OK + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7124 +key in obj.keys()and foo +(key in obj.keys())and foo +key in (obj.keys())and foo + +# Regression test for: https://github.com/astral-sh/ruff/issues/7200 +for key in ( + self.experiment.surveys[0] + .stations[0] + .keys() +): + continue diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM210.py b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM210.py index 9def63a549..201f6e2458 100644 --- a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM210.py +++ b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM210.py @@ -13,3 +13,8 @@ def f(): return False a = True if b else False + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7076 +samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == + psl.privatesuffix(src.netloc)) else False diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM222.py b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM222.py index 91829bd018..dcf730f4a7 100644 --- a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM222.py +++ b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM222.py @@ -152,3 +152,11 @@ if (a or [1] or True or [2]) == (a or [1]): # SIM222 if f(a or [1] or True or [2]): # SIM222 pass + +# Regression test for: https://github.com/astral-sh/ruff/issues/7099 +def secondToTime(s0: int) -> (int, int, int) or str: + m, s = divmod(s0, 60) + + +def secondToTime(s0: int) -> ((int, int, int) or str): + m, s = divmod(s0, 60) diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM300.py b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM300.py index 25735ca70c..a9cd7df872 100644 --- a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM300.py +++ b/crates/ruff/resources/test/fixtures/flake8_simplify/SIM300.py @@ -14,6 +14,8 @@ YODA >= age # SIM300 JediOrder.YODA == age # SIM300 0 < (number - 100) # SIM300 SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +B None: diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/sections.py b/crates/ruff/resources/test/fixtures/pydocstyle/sections.py index fef7f2fba1..223c55dff5 100644 --- a/crates/ruff/resources/test/fixtures/pydocstyle/sections.py +++ b/crates/ruff/resources/test/fixtures/pydocstyle/sections.py @@ -529,3 +529,16 @@ def replace_equals_with_dash2(): Parameters =========== """ + + +@expect(_D213) +def non_empty_blank_line_before_section(): # noqa: D416 + """Toggle the gizmo. + + The function's description. + + Returns + ------- + A value of some sort. + + """ diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_0.py b/crates/ruff/resources/test/fixtures/pyflakes/F401_0.py index c3a2db56f7..ecc6ecc43f 100644 --- a/crates/ruff/resources/test/fixtures/pyflakes/F401_0.py +++ b/crates/ruff/resources/test/fixtures/pyflakes/F401_0.py @@ -112,3 +112,11 @@ match *0, 1, *2: import b1 import b2 + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7244 +from datameta_client_lib.model_utils import ( # noqa: F401 +noqa ) + +from datameta_client_lib.model_helpers import ( +noqa ) diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F504.py b/crates/ruff/resources/test/fixtures/pyflakes/F504.py index 8a4ab822e4..bb5549adae 100644 --- a/crates/ruff/resources/test/fixtures/pyflakes/F504.py +++ b/crates/ruff/resources/test/fixtures/pyflakes/F504.py @@ -9,3 +9,8 @@ hidden = {"a": "!"} "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) '' % {'a''b' : ''} # F504 ("ab" not used) + +# https://github.com/astral-sh/ruff/issues/4899 +"" % { + 'test1': '', 'test2': '', +} diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F841_3.py b/crates/ruff/resources/test/fixtures/pyflakes/F841_3.py index ce7b19a1b3..00c2962223 100644 --- a/crates/ruff/resources/test/fixtures/pyflakes/F841_3.py +++ b/crates/ruff/resources/test/fixtures/pyflakes/F841_3.py @@ -165,3 +165,9 @@ def f(): x = 1 y = 2 + + +def f(): + (x) = foo() + ((x)) = foo() + (x) = (y.z) = foo() diff --git a/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py b/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py index 46d8be249b..ee4a12b435 100644 --- a/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py +++ b/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py @@ -1,3 +1,6 @@ +from typing import override + + class Apples: def _init_(self): # [bad-dunder-name] pass @@ -21,6 +24,11 @@ class Apples: # author likely meant to call the invert dunder method pass + @override + def _ignore__(self): # [bad-dunder-name] + # overridden dunder methods should be ignored + pass + def hello(self): print("hello") diff --git a/crates/ruff/resources/test/fixtures/pylint/nested_min_max.py b/crates/ruff/resources/test/fixtures/pylint/nested_min_max.py index 2c66580305..4857a873ba 100644 --- a/crates/ruff/resources/test/fixtures/pylint/nested_min_max.py +++ b/crates/ruff/resources/test/fixtures/pylint/nested_min_max.py @@ -36,3 +36,6 @@ tuples_list = [ min(min(tuples_list)) max(max(tuples_list)) + +# Starred argument should be copied as it is. +max(1, max(*a)) diff --git a/crates/ruff/resources/test/fixtures/pylint/repeated_equality_comparison_target.py b/crates/ruff/resources/test/fixtures/pylint/repeated_equality_comparison.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/repeated_equality_comparison_target.py rename to crates/ruff/resources/test/fixtures/pylint/repeated_equality_comparison.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP007.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP007.py index 47c9fdbc0a..3f8218f36c 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP007.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP007.py @@ -91,3 +91,20 @@ def f(x: Optional[int : float]) -> None: def f(x: Optional[str, int : float]) -> None: ... + + +def f(x: Optional[int, float]) -> None: + ... + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7131 +class ServiceRefOrValue: + service_specification: Optional[ + list[ServiceSpecificationRef] + | list[ServiceSpecification] + ] = None + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7201 +class ServiceRefOrValue: + service_specification: Optional[str]is not True = None diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP021.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP021.py index c6e0b5e591..04b837951c 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP021.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP021.py @@ -1,12 +1,10 @@ import subprocess -import subprocess as somename from subprocess import run -from subprocess import run as anothername +# Errors subprocess.run(["foo"], universal_newlines=True, check=True) -somename.run(["foo"], universal_newlines=True) - +subprocess.run(["foo"], universal_newlines=True, text=True) run(["foo"], universal_newlines=True, check=False) -anothername(["foo"], universal_newlines=True) +# OK subprocess.run(["foo"], check=True) diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP022.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP022.py index c5ccb93107..01cf7e107d 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP022.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP022.py @@ -35,8 +35,19 @@ if output: encoding="utf-8", ) +output = subprocess.run( + ["foo"], stdout=subprocess.PIPE, capture_output=True, stderr=subprocess.PIPE +) -# Examples that should NOT trigger the rule +output = subprocess.run( + ["foo"], stdout=subprocess.PIPE, capture_output=False, stderr=subprocess.PIPE +) + +output = subprocess.run( + ["foo"], capture_output=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE +) + +# OK from foo import PIPE subprocess.run(["foo"], stdout=PIPE, stderr=PIPE) run(["foo"], stdout=None, stderr=PIPE) diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_0.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP024_0.py index 5d8c07b8bd..523ee451f9 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_0.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP024_0.py @@ -96,3 +96,11 @@ try: pass except (OSError, KeyError): pass + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7101 +def get_owner_id_from_mac_address(): + try: + mac_address = get_primary_mac_address() + except(IOError, OSError) as ex: + msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP028_0.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP028_0.py index fcb0f6af99..08f382c956 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP028_0.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP028_0.py @@ -72,3 +72,12 @@ def f(): for x, y in z(): yield x, y x = 1 + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7103 +def _serve_method(fn): + for h in ( + TaggedText.from_file(args.input) + .markup(highlight=args.region) + ): + yield h diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP028_1.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP028_1.py index db49d68668..66675da186 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP028_1.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP028_1.py @@ -1,4 +1,4 @@ -# These should NOT change +# OK def f(): for x in z: yield diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP035.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP035.py index 80c0eb966f..d0da69d47f 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP035.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP035.py @@ -74,6 +74,8 @@ from typing import Collection from typing import AsyncGenerator from typing import Reversible from typing import Generator +from typing import Callable +from typing import cast # OK from a import b diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_0.py b/crates/ruff/resources/test/fixtures/pyupgrade/UP036_0.py index d223d58c68..fc4ad3ccd7 100644 --- a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_0.py +++ b/crates/ruff/resources/test/fixtures/pyupgrade/UP036_0.py @@ -178,3 +178,9 @@ if True: if True: if sys.version_info > (3, 0): \ expected_error = [] + +if sys.version_info < (3,12): + print("py3") + +if sys.version_info <= (3,12): + print("py3") diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB145.py b/crates/ruff/resources/test/fixtures/refurb/FURB145.py new file mode 100644 index 0000000000..885674c8d9 --- /dev/null +++ b/crates/ruff/resources/test/fixtures/refurb/FURB145.py @@ -0,0 +1,21 @@ +l = [1, 2, 3, 4, 5] + +# Errors. +a = l[:] +b, c = 1, l[:] +d, e = l[:], 1 +m = l[::] +l[:] +print(l[:]) + +# False negatives. +aa = a[:] # Type inference. + +# OK. +t = (1, 2, 3, 4, 5) +f = t[:] # t.copy() is not supported. +g = l[1:3] +h = l[1:] +i = l[:3] +j = l[1:3:2] +k = l[::2] diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF017.py b/crates/ruff/resources/test/fixtures/ruff/RUF017.py index f7c062d894..546d08be57 100644 --- a/crates/ruff/resources/test/fixtures/ruff/RUF017.py +++ b/crates/ruff/resources/test/fixtures/ruff/RUF017.py @@ -12,3 +12,10 @@ sum([[1, 2, 3], [4, 5, 6]], # OK sum([x, y]) sum([[1, 2, 3], [4, 5, 6]]) + + +# Regression test for: https://github.com/astral-sh/ruff/issues/7059 +def func(): + import functools, operator + + sum([x, y], []) diff --git a/crates/ruff/src/autofix/edits.rs b/crates/ruff/src/autofix/edits.rs index 02b18bdf0a..e11d8a53e6 100644 --- a/crates/ruff/src/autofix/edits.rs +++ b/crates/ruff/src/autofix/edits.rs @@ -3,14 +3,14 @@ use anyhow::{Context, Result}; use ruff_diagnostics::Edit; -use ruff_python_ast::{self as ast, Arguments, ExceptHandler, Expr, Keyword, Stmt}; +use ruff_python_ast::{self as ast, Arguments, ExceptHandler, Stmt}; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; use ruff_python_trivia::{ has_leading_content, is_python_whitespace, PythonWhitespace, SimpleTokenKind, SimpleTokenizer, }; use ruff_source_file::{Locator, NewlineWithTrailingNewline}; -use ruff_text_size::{Ranged, TextLen, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use crate::autofix::codemods; @@ -92,10 +92,8 @@ pub(crate) fn remove_argument( ) -> Result { // Partition into arguments before and after the argument to remove. let (before, after): (Vec<_>, Vec<_>) = arguments - .args - .iter() - .map(Expr::range) - .chain(arguments.keywords.iter().map(Keyword::range)) + .arguments_source_order() + .map(|arg| arg.range()) .filter(|range| argument.range() != *range) .partition(|range| range.start() < argument.start()); @@ -249,6 +247,44 @@ fn next_stmt_break(semicolon: TextSize, locator: &Locator) -> TextSize { locator.line_end(start_location) } +/// Add leading whitespace to a snippet, if it's immediately preceded an identifier or keyword. +pub(crate) fn pad_start(mut content: String, start: TextSize, locator: &Locator) -> String { + // Ex) When converting `except(ValueError,)` from a tuple to a single argument, we need to + // insert a space before the fix, to achieve `except ValueError`. + if locator + .up_to(start) + .chars() + .last() + .is_some_and(|char| char.is_ascii_alphabetic()) + { + content.insert(0, ' '); + } + content +} + +/// Add trailing whitespace to a snippet, if it's immediately followed by an identifier or keyword. +pub(crate) fn pad_end(mut content: String, end: TextSize, locator: &Locator) -> String { + if locator + .after(end) + .chars() + .next() + .is_some_and(|char| char.is_ascii_alphabetic()) + { + content.push(' '); + } + content +} + +/// Add leading or trailing whitespace to a snippet, if it's immediately preceded or followed by +/// an identifier or keyword. +pub(crate) fn pad(content: String, range: TextRange, locator: &Locator) -> String { + pad_start( + pad_end(content, range.end(), locator), + range.start(), + locator, + ) +} + #[cfg(test)] mod tests { use anyhow::Result; diff --git a/crates/ruff/src/autofix/mod.rs b/crates/ruff/src/autofix/mod.rs index b85f1b54d2..6e33cb99a1 100644 --- a/crates/ruff/src/autofix/mod.rs +++ b/crates/ruff/src/autofix/mod.rs @@ -4,17 +4,15 @@ use std::collections::BTreeSet; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use rustc_hash::{FxHashMap, FxHashSet}; -use ruff_diagnostics::{Diagnostic, Edit, Fix, IsolationLevel}; +use ruff_diagnostics::{Diagnostic, Edit, Fix, IsolationLevel, SourceMap}; use ruff_source_file::Locator; -use crate::autofix::source_map::SourceMap; use crate::linter::FixTable; use crate::registry::{AsRule, Rule}; pub(crate) mod codemods; pub(crate) mod edits; pub(crate) mod snippet; -pub(crate) mod source_map; pub(crate) struct FixResult { /// The resulting source code, after applying all fixes. @@ -140,10 +138,9 @@ fn cmp_fix(rule1: Rule, rule2: Rule, fix1: &Fix, fix2: &Fix) -> std::cmp::Orderi mod tests { use ruff_text_size::{Ranged, TextSize}; - use ruff_diagnostics::{Diagnostic, Edit, Fix}; + use ruff_diagnostics::{Diagnostic, Edit, Fix, SourceMarker}; use ruff_source_file::Locator; - use crate::autofix::source_map::SourceMarker; use crate::autofix::{apply_fixes, FixResult}; use crate::rules::pycodestyle::rules::MissingNewlineAtEndOfFile; @@ -207,14 +204,8 @@ print("hello world") assert_eq!( source_map.markers(), &[ - SourceMarker { - source: 10.into(), - dest: 10.into(), - }, - SourceMarker { - source: 10.into(), - dest: 21.into(), - }, + SourceMarker::new(10.into(), 10.into(),), + SourceMarker::new(10.into(), 21.into(),), ] ); } @@ -250,14 +241,8 @@ class A(Bar): assert_eq!( source_map.markers(), &[ - SourceMarker { - source: 8.into(), - dest: 8.into(), - }, - SourceMarker { - source: 14.into(), - dest: 11.into(), - }, + SourceMarker::new(8.into(), 8.into(),), + SourceMarker::new(14.into(), 11.into(),), ] ); } @@ -289,14 +274,8 @@ class A: assert_eq!( source_map.markers(), &[ - SourceMarker { - source: 7.into(), - dest: 7.into() - }, - SourceMarker { - source: 15.into(), - dest: 7.into() - } + SourceMarker::new(7.into(), 7.into()), + SourceMarker::new(15.into(), 7.into()), ] ); } @@ -332,22 +311,10 @@ class A(object): assert_eq!( source_map.markers(), &[ - SourceMarker { - source: 8.into(), - dest: 8.into() - }, - SourceMarker { - source: 16.into(), - dest: 8.into() - }, - SourceMarker { - source: 22.into(), - dest: 14.into(), - }, - SourceMarker { - source: 30.into(), - dest: 14.into(), - } + SourceMarker::new(8.into(), 8.into()), + SourceMarker::new(16.into(), 8.into()), + SourceMarker::new(22.into(), 14.into(),), + SourceMarker::new(30.into(), 14.into(),), ] ); } @@ -382,14 +349,8 @@ class A: assert_eq!( source_map.markers(), &[ - SourceMarker { - source: 7.into(), - dest: 7.into(), - }, - SourceMarker { - source: 15.into(), - dest: 7.into(), - } + SourceMarker::new(7.into(), 7.into(),), + SourceMarker::new(15.into(), 7.into(),), ] ); } diff --git a/crates/ruff/src/checkers/ast/analyze/expression.rs b/crates/ruff/src/checkers/ast/analyze/expression.rs index 553eb461ac..cc29448125 100644 --- a/crates/ruff/src/checkers/ast/analyze/expression.rs +++ b/crates/ruff/src/checkers/ast/analyze/expression.rs @@ -16,7 +16,7 @@ use crate::rules::{ flake8_future_annotations, flake8_gettext, flake8_implicit_str_concat, flake8_logging_format, flake8_pie, flake8_print, flake8_pyi, flake8_pytest_style, flake8_self, flake8_simplify, flake8_tidy_imports, flake8_use_pathlib, flynt, numpy, pandas_vet, pep8_naming, pycodestyle, - pyflakes, pygrep_hooks, pylint, pyupgrade, ruff, + pyflakes, pygrep_hooks, pylint, pyupgrade, refurb, ruff, }; use crate::settings::types::PythonVersion; @@ -113,10 +113,12 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { if checker.enabled(Rule::UnnecessaryIterableAllocationForFirstElement) { ruff::rules::unnecessary_iterable_allocation_for_first_element(checker, subscript); } - if checker.enabled(Rule::InvalidIndexType) { ruff::rules::invalid_index_type(checker, subscript); } + if checker.settings.rules.enabled(Rule::SliceCopy) { + refurb::rules::slice_copy(checker, subscript); + } pandas_vet::rules::subscript(checker, value, expr); } @@ -1195,7 +1197,6 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { } Expr::Constant(ast::ExprConstant { value: Constant::Int(_) | Constant::Float(_) | Constant::Complex { .. }, - kind: _, range: _, }) => { if checker.source_type.is_stub() && checker.enabled(Rule::NumericLiteralTooLong) { @@ -1204,7 +1205,6 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { } Expr::Constant(ast::ExprConstant { value: Constant::Bytes(_), - kind: _, range: _, }) => { if checker.source_type.is_stub() && checker.enabled(Rule::StringOrBytesTooLong) { @@ -1213,7 +1213,6 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { } Expr::Constant(ast::ExprConstant { value: Constant::Str(value), - kind, range: _, }) => { if checker.enabled(Rule::HardcodedBindAllInterfaces) { @@ -1227,7 +1226,7 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { flake8_bandit::rules::hardcoded_tmp_directory(checker, expr, value); } if checker.enabled(Rule::UnicodeKindPrefix) { - pyupgrade::rules::unicode_kind_prefix(checker, expr, kind.as_deref()); + pyupgrade::rules::unicode_kind_prefix(checker, expr, value.unicode); } if checker.source_type.is_stub() { if checker.enabled(Rule::StringOrBytesTooLong) { @@ -1253,14 +1252,10 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { range: _, }) => { if checker.enabled(Rule::IfExprWithTrueFalse) { - flake8_simplify::rules::explicit_true_false_in_ifexpr( - checker, expr, test, body, orelse, - ); + flake8_simplify::rules::if_expr_with_true_false(checker, expr, test, body, orelse); } if checker.enabled(Rule::IfExprWithFalseTrue) { - flake8_simplify::rules::explicit_false_true_in_ifexpr( - checker, expr, test, body, orelse, - ); + flake8_simplify::rules::if_expr_with_false_true(checker, expr, test, body, orelse); } if checker.enabled(Rule::IfExprWithTwistedArms) { flake8_simplify::rules::twisted_arms_in_ifexpr(checker, expr, test, body, orelse); @@ -1358,8 +1353,8 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) { if checker.enabled(Rule::ExprAndFalse) { flake8_simplify::rules::expr_and_false(checker, expr); } - if checker.enabled(Rule::RepeatedEqualityComparisonTarget) { - pylint::rules::repeated_equality_comparison_target(checker, bool_op); + if checker.enabled(Rule::RepeatedEqualityComparison) { + pylint::rules::repeated_equality_comparison(checker, bool_op); } } _ => {} diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index c4ea4e8b28..27a8a2a7d3 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -528,11 +528,7 @@ where &self.semantic.definitions, ); self.semantic.push_definition(definition); - - self.semantic.push_scope(match &stmt { - Stmt::FunctionDef(stmt) => ScopeKind::Function(stmt), - _ => unreachable!("Expected Stmt::FunctionDef"), - }); + self.semantic.push_scope(ScopeKind::Function(function_def)); self.deferred.functions.push(self.semantic.snapshot()); @@ -1192,7 +1188,6 @@ where } Expr::Constant(ast::ExprConstant { value: Constant::Str(value), - kind: _, range: _, }) => { if self.semantic.in_type_definition() diff --git a/crates/ruff/src/checkers/imports.rs b/crates/ruff/src/checkers/imports.rs index 58ff35fa64..0c96fafffd 100644 --- a/crates/ruff/src/checkers/imports.rs +++ b/crates/ruff/src/checkers/imports.rs @@ -85,7 +85,7 @@ pub(crate) fn check_imports( stylist: &Stylist, path: &Path, package: Option<&Path>, - source_kind: Option<&SourceKind>, + source_kind: &SourceKind, source_type: PySourceType, ) -> (Vec, Option) { // Extract all import blocks from the AST. diff --git a/crates/ruff/src/codes.rs b/crates/ruff/src/codes.rs index 2c5b3c7bad..a8383a0ea1 100644 --- a/crates/ruff/src/codes.rs +++ b/crates/ruff/src/codes.rs @@ -9,6 +9,7 @@ use strum_macros::{AsRefStr, EnumIter}; use ruff_diagnostics::Violation; use crate::registry::{AsRule, Linter}; +use crate::rule_selector::is_single_rule_selector; use crate::rules; #[derive(PartialEq, Eq, PartialOrd, Ord)] @@ -51,7 +52,10 @@ impl PartialEq<&str> for NoqaCode { pub enum RuleGroup { /// The rule has not been assigned to any specific group. Unspecified, - /// The rule is still under development, and must be enabled explicitly. + /// The rule is unstable, and preview mode must be enabled for usage. + Preview, + /// Legacy category for unstable rules, supports backwards compatible selection. + #[deprecated(note = "Use `RuleGroup::Preview` for new rules instead")] Nursery, } @@ -64,38 +68,71 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { Some(match (linter, code) { // pycodestyle errors (Pycodestyle, "E101") => (RuleGroup::Unspecified, rules::pycodestyle::rules::MixedSpacesAndTabs), + #[allow(deprecated)] (Pycodestyle, "E111") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::IndentationWithInvalidMultiple), + #[allow(deprecated)] (Pycodestyle, "E112") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::NoIndentedBlock), + #[allow(deprecated)] (Pycodestyle, "E113") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::UnexpectedIndentation), + #[allow(deprecated)] (Pycodestyle, "E114") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::IndentationWithInvalidMultipleComment), + #[allow(deprecated)] (Pycodestyle, "E115") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::NoIndentedBlockComment), + #[allow(deprecated)] (Pycodestyle, "E116") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::UnexpectedIndentationComment), + #[allow(deprecated)] (Pycodestyle, "E117") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::OverIndented), + #[allow(deprecated)] (Pycodestyle, "E201") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::WhitespaceAfterOpenBracket), + #[allow(deprecated)] (Pycodestyle, "E202") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::WhitespaceBeforeCloseBracket), + #[allow(deprecated)] (Pycodestyle, "E203") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::WhitespaceBeforePunctuation), + #[allow(deprecated)] (Pycodestyle, "E211") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::WhitespaceBeforeParameters), + #[allow(deprecated)] (Pycodestyle, "E221") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MultipleSpacesBeforeOperator), + #[allow(deprecated)] (Pycodestyle, "E222") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MultipleSpacesAfterOperator), + #[allow(deprecated)] (Pycodestyle, "E223") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::TabBeforeOperator), + #[allow(deprecated)] (Pycodestyle, "E224") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::TabAfterOperator), + #[allow(deprecated)] (Pycodestyle, "E225") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespaceAroundOperator), + #[allow(deprecated)] (Pycodestyle, "E226") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespaceAroundArithmeticOperator), + #[allow(deprecated)] (Pycodestyle, "E227") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespaceAroundBitwiseOrShiftOperator), + #[allow(deprecated)] (Pycodestyle, "E228") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespaceAroundModuloOperator), + #[allow(deprecated)] (Pycodestyle, "E231") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespace), + #[allow(deprecated)] (Pycodestyle, "E241") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MultipleSpacesAfterComma), + #[allow(deprecated)] (Pycodestyle, "E242") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::TabAfterComma), + #[allow(deprecated)] (Pycodestyle, "E251") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::UnexpectedSpacesAroundKeywordParameterEquals), + #[allow(deprecated)] (Pycodestyle, "E252") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespaceAroundParameterEquals), + #[allow(deprecated)] (Pycodestyle, "E261") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::TooFewSpacesBeforeInlineComment), + #[allow(deprecated)] (Pycodestyle, "E262") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::NoSpaceAfterInlineComment), + #[allow(deprecated)] (Pycodestyle, "E265") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::NoSpaceAfterBlockComment), + #[allow(deprecated)] (Pycodestyle, "E266") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MultipleLeadingHashesForBlockComment), + #[allow(deprecated)] (Pycodestyle, "E271") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MultipleSpacesAfterKeyword), + #[allow(deprecated)] (Pycodestyle, "E272") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MultipleSpacesBeforeKeyword), + #[allow(deprecated)] (Pycodestyle, "E273") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::TabAfterKeyword), + #[allow(deprecated)] (Pycodestyle, "E274") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::TabBeforeKeyword), + #[allow(deprecated)] (Pycodestyle, "E275") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::MissingWhitespaceAfterKeyword), (Pycodestyle, "E401") => (RuleGroup::Unspecified, rules::pycodestyle::rules::MultipleImportsOnOneLine), (Pycodestyle, "E402") => (RuleGroup::Unspecified, rules::pycodestyle::rules::ModuleImportNotAtTopOfFile), @@ -176,6 +213,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Pylint, "C0205") => (RuleGroup::Unspecified, rules::pylint::rules::SingleStringSlots), (Pylint, "C0208") => (RuleGroup::Unspecified, rules::pylint::rules::IterationOverSet), (Pylint, "C0414") => (RuleGroup::Unspecified, rules::pylint::rules::UselessImportAlias), + #[allow(deprecated)] (Pylint, "C1901") => (RuleGroup::Nursery, rules::pylint::rules::CompareToEmptyString), (Pylint, "C3002") => (RuleGroup::Unspecified, rules::pylint::rules::UnnecessaryDirectLambdaCall), (Pylint, "E0100") => (RuleGroup::Unspecified, rules::pylint::rules::YieldInInit), @@ -212,10 +250,11 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Pylint, "R0915") => (RuleGroup::Unspecified, rules::pylint::rules::TooManyStatements), (Pylint, "R1701") => (RuleGroup::Unspecified, rules::pylint::rules::RepeatedIsinstanceCalls), (Pylint, "R1711") => (RuleGroup::Unspecified, rules::pylint::rules::UselessReturn), - (Pylint, "R1714") => (RuleGroup::Unspecified, rules::pylint::rules::RepeatedEqualityComparisonTarget), + (Pylint, "R1714") => (RuleGroup::Unspecified, rules::pylint::rules::RepeatedEqualityComparison), (Pylint, "R1722") => (RuleGroup::Unspecified, rules::pylint::rules::SysExitAlias), (Pylint, "R2004") => (RuleGroup::Unspecified, rules::pylint::rules::MagicValueComparison), (Pylint, "R5501") => (RuleGroup::Unspecified, rules::pylint::rules::CollapsibleElseIf), + #[allow(deprecated)] (Pylint, "R6301") => (RuleGroup::Nursery, rules::pylint::rules::NoSelfUse), (Pylint, "W0120") => (RuleGroup::Unspecified, rules::pylint::rules::UselessElseOnLoop), (Pylint, "W0127") => (RuleGroup::Unspecified, rules::pylint::rules::SelfAssigningVariable), @@ -228,9 +267,11 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Pylint, "W1508") => (RuleGroup::Unspecified, rules::pylint::rules::InvalidEnvvarDefault), (Pylint, "W1509") => (RuleGroup::Unspecified, rules::pylint::rules::SubprocessPopenPreexecFn), (Pylint, "W1510") => (RuleGroup::Unspecified, rules::pylint::rules::SubprocessRunWithoutCheck), + #[allow(deprecated)] (Pylint, "W1641") => (RuleGroup::Nursery, rules::pylint::rules::EqWithoutHash), (Pylint, "R0904") => (RuleGroup::Unspecified, rules::pylint::rules::TooManyPublicMethods), (Pylint, "W2901") => (RuleGroup::Unspecified, rules::pylint::rules::RedefinedLoopName), + #[allow(deprecated)] (Pylint, "W3201") => (RuleGroup::Nursery, rules::pylint::rules::BadDunderMethodName), (Pylint, "W3301") => (RuleGroup::Unspecified, rules::pylint::rules::NestedMinMax), @@ -404,6 +445,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Simplify, "910") => (RuleGroup::Unspecified, rules::flake8_simplify::rules::DictGetWithNoneDefault), // flake8-copyright + #[allow(deprecated)] (Flake8Copyright, "001") => (RuleGroup::Nursery, rules::flake8_copyright::rules::MissingCopyrightNotice), // pyupgrade @@ -816,9 +858,11 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Ruff, "012") => (RuleGroup::Unspecified, rules::ruff::rules::MutableClassDefault), (Ruff, "013") => (RuleGroup::Unspecified, rules::ruff::rules::ImplicitOptional), #[cfg(feature = "unreachable-code")] // When removing this feature gate, also update rules_selector.rs + #[allow(deprecated)] (Ruff, "014") => (RuleGroup::Nursery, rules::ruff::rules::UnreachableCode), (Ruff, "015") => (RuleGroup::Unspecified, rules::ruff::rules::UnnecessaryIterableAllocationForFirstElement), (Ruff, "016") => (RuleGroup::Unspecified, rules::ruff::rules::InvalidIndexType), + #[allow(deprecated)] (Ruff, "017") => (RuleGroup::Nursery, rules::ruff::rules::QuadraticListSummation), (Ruff, "100") => (RuleGroup::Unspecified, rules::ruff::rules::UnusedNOQA), (Ruff, "200") => (RuleGroup::Unspecified, rules::ruff::rules::InvalidPyprojectToml), @@ -867,9 +911,13 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Slots, "002") => (RuleGroup::Unspecified, rules::flake8_slots::rules::NoSlotsInNamedtupleSubclass), // refurb + #[allow(deprecated)] (Refurb, "113") => (RuleGroup::Nursery, rules::refurb::rules::RepeatedAppend), + #[allow(deprecated)] (Refurb, "131") => (RuleGroup::Nursery, rules::refurb::rules::DeleteFullSlice), + #[allow(deprecated)] (Refurb, "132") => (RuleGroup::Nursery, rules::refurb::rules::CheckAndRemoveFromSet), + (Refurb, "145") => (RuleGroup::Preview, rules::refurb::rules::SliceCopy), _ => return None, }) diff --git a/crates/ruff/src/cst/helpers.rs b/crates/ruff/src/cst/helpers.rs index c2cc95f79c..a9a5e171eb 100644 --- a/crates/ruff/src/cst/helpers.rs +++ b/crates/ruff/src/cst/helpers.rs @@ -1,4 +1,4 @@ -use libcst_native::{Expression, NameOrAttribute}; +use libcst_native::{Expression, NameOrAttribute, ParenthesizableWhitespace, SimpleWhitespace}; fn compose_call_path_inner<'a>(expr: &'a Expression, parts: &mut Vec<&'a str>) { match expr { @@ -36,3 +36,17 @@ pub(crate) fn compose_module_path(module: &NameOrAttribute) -> String { } } } + +/// Return a [`ParenthesizableWhitespace`] containing a single space. +pub(crate) fn space() -> ParenthesizableWhitespace<'static> { + ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")) +} + +/// Ensure that a [`ParenthesizableWhitespace`] contains at least one space. +pub(crate) fn or_space(whitespace: ParenthesizableWhitespace) -> ParenthesizableWhitespace { + if whitespace == ParenthesizableWhitespace::default() { + space() + } else { + whitespace + } +} diff --git a/crates/ruff/src/importer/mod.rs b/crates/ruff/src/importer/mod.rs index 6ab2ebba4f..7989fbc787 100644 --- a/crates/ruff/src/importer/mod.rs +++ b/crates/ruff/src/importer/mod.rs @@ -171,10 +171,8 @@ impl<'a> Importer<'a> { at: TextSize, semantic: &SemanticModel, ) -> Result<(Edit, String), ResolutionError> { - match self.get_symbol(symbol, at, semantic) { - Some(result) => result, - None => self.import_symbol(symbol, at, semantic), - } + self.get_symbol(symbol, at, semantic)? + .map_or_else(|| self.import_symbol(symbol, at, semantic), Ok) } /// Return an [`Edit`] to reference an existing symbol, if it's present in the given [`SemanticModel`]. @@ -183,9 +181,13 @@ impl<'a> Importer<'a> { symbol: &ImportRequest, at: TextSize, semantic: &SemanticModel, - ) -> Option> { + ) -> Result, ResolutionError> { // If the symbol is already available in the current scope, use it. - let imported_name = semantic.resolve_qualified_import_name(symbol.module, symbol.member)?; + let Some(imported_name) = + semantic.resolve_qualified_import_name(symbol.module, symbol.member) + else { + return Ok(None); + }; // If the symbol source (i.e., the import statement) comes after the current location, // abort. For example, we could be generating an edit within a function, and the import @@ -195,13 +197,13 @@ impl<'a> Importer<'a> { // unclear whether should add an import statement at the start of the file, since it could // be shadowed between the import and the current location. if imported_name.start() > at { - return Some(Err(ResolutionError::ImportAfterUsage)); + return Err(ResolutionError::ImportAfterUsage); } // If the symbol source (i.e., the import statement) is in a typing-only context, but we're // in a runtime context, abort. if imported_name.context().is_typing() && semantic.execution_context().is_runtime() { - return Some(Err(ResolutionError::IncompatibleContext)); + return Err(ResolutionError::IncompatibleContext); } // We also add a no-op edit to force conflicts with any other fixes that might try to @@ -224,7 +226,7 @@ impl<'a> Importer<'a> { self.locator.slice(imported_name.range()).to_string(), imported_name.range(), ); - Some(Ok((import_edit, imported_name.into_name()))) + Ok(Some((import_edit, imported_name.into_name()))) } /// Generate an [`Edit`] to reference the given symbol. Returns the [`Edit`] necessary to make diff --git a/crates/ruff/src/lib.rs b/crates/ruff/src/lib.rs index 3bfa003291..676e521dfe 100644 --- a/crates/ruff/src/lib.rs +++ b/crates/ruff/src/lib.rs @@ -6,7 +6,7 @@ //! [Ruff]: https://github.com/astral-sh/ruff pub use rule_selector::RuleSelector; -pub use rules::pycodestyle::rules::IOError; +pub use rules::pycodestyle::rules::{IOError, SyntaxError}; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -20,7 +20,6 @@ mod doc_lines; mod docstrings; pub mod fs; mod importer; -pub mod jupyter; mod lex; pub mod line_width; pub mod linter; diff --git a/crates/ruff/src/linter.rs b/crates/ruff/src/linter.rs index e247377b00..19612ab968 100644 --- a/crates/ruff/src/linter.rs +++ b/crates/ruff/src/linter.rs @@ -6,8 +6,6 @@ use anyhow::{anyhow, Result}; use colored::Colorize; use itertools::Itertools; use log::error; -use ruff_python_parser::lexer::LexResult; -use ruff_python_parser::{AsMode, ParseError}; use rustc_hash::FxHashMap; use ruff_diagnostics::Diagnostic; @@ -15,7 +13,8 @@ use ruff_python_ast::imports::ImportMap; use ruff_python_ast::PySourceType; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; - +use ruff_python_parser::lexer::LexResult; +use ruff_python_parser::{AsMode, ParseError}; use ruff_source_file::{Locator, SourceFileBuilder}; use ruff_text_size::Ranged; @@ -82,7 +81,7 @@ pub fn check_path( directives: &Directives, settings: &Settings, noqa: flags::Noqa, - source_kind: Option<&SourceKind>, + source_kind: &SourceKind, source_type: PySourceType, ) -> LinterResult<(Vec, Option)> { // Aggregate all diagnostics. @@ -271,17 +270,17 @@ const MAX_ITERATIONS: usize = 100; pub fn add_noqa_to_path( path: &Path, package: Option<&Path>, + source_kind: &SourceKind, source_type: PySourceType, settings: &Settings, ) -> Result { - // Read the file from disk. - let contents = std::fs::read_to_string(path)?; + let contents = source_kind.source_code(); // Tokenize once. - let tokens: Vec = ruff_python_parser::tokenize(&contents, source_type.as_mode()); + let tokens: Vec = ruff_python_parser::tokenize(contents, source_type.as_mode()); // Map row and column locations to byte slices (lazily). - let locator = Locator::new(&contents); + let locator = Locator::new(contents); // Detect the current code style (lazily). let stylist = Stylist::from_tokens(&tokens, &locator); @@ -311,21 +310,20 @@ pub fn add_noqa_to_path( &directives, settings, flags::Noqa::Disabled, - None, + source_kind, source_type, ); // Log any parse errors. if let Some(err) = error { - // TODO(dhruvmanila): This should use `SourceKind`, update when - // `--add-noqa` is supported for Jupyter notebooks. error!( "{}", - DisplayParseError::new(err, locator.to_source_code(), None) + DisplayParseError::new(err, locator.to_source_code(), source_kind) ); } // Add any missing `# noqa` pragmas. + // TODO(dhruvmanila): Add support for Jupyter Notebooks add_noqa( path, &diagnostics.0, @@ -378,7 +376,7 @@ pub fn lint_only( &directives, settings, noqa, - Some(source_kind), + source_kind, source_type, ); @@ -472,7 +470,7 @@ pub fn lint_fix<'a>( &directives, settings, noqa, - Some(source_kind), + source_kind, source_type, ); @@ -609,3 +607,133 @@ This indicates a bug in `{}`. If you could open an issue at: ); } } + +#[cfg(test)] +mod tests { + use std::path::Path; + + use anyhow::Result; + use test_case::test_case; + + use ruff_notebook::{Notebook, NotebookError}; + + use crate::registry::Rule; + use crate::source_kind::SourceKind; + use crate::test::{test_contents, test_notebook_path, TestedNotebook}; + use crate::{assert_messages, settings}; + + /// Construct a path to a Jupyter notebook in the `resources/test/fixtures/jupyter` directory. + fn notebook_path(path: impl AsRef) -> std::path::PathBuf { + Path::new("../ruff_notebook/resources/test/fixtures/jupyter").join(path) + } + + #[test] + fn test_import_sorting() -> Result<(), NotebookError> { + let actual = notebook_path("isort.ipynb"); + let expected = notebook_path("isort_expected.ipynb"); + let TestedNotebook { + messages, + source_notebook, + .. + } = test_notebook_path( + &actual, + expected, + &settings::Settings::for_rule(Rule::UnsortedImports), + )?; + assert_messages!(messages, actual, source_notebook); + Ok(()) + } + + #[test] + fn test_ipy_escape_command() -> Result<(), NotebookError> { + let actual = notebook_path("ipy_escape_command.ipynb"); + let expected = notebook_path("ipy_escape_command_expected.ipynb"); + let TestedNotebook { + messages, + source_notebook, + .. + } = test_notebook_path( + &actual, + expected, + &settings::Settings::for_rule(Rule::UnusedImport), + )?; + assert_messages!(messages, actual, source_notebook); + Ok(()) + } + + #[test] + fn test_unused_variable() -> Result<(), NotebookError> { + let actual = notebook_path("unused_variable.ipynb"); + let expected = notebook_path("unused_variable_expected.ipynb"); + let TestedNotebook { + messages, + source_notebook, + .. + } = test_notebook_path( + &actual, + expected, + &settings::Settings::for_rule(Rule::UnusedVariable), + )?; + assert_messages!(messages, actual, source_notebook); + Ok(()) + } + + #[test] + fn test_json_consistency() -> Result<()> { + let actual_path = notebook_path("before_fix.ipynb"); + let expected_path = notebook_path("after_fix.ipynb"); + + let TestedNotebook { + linted_notebook: fixed_notebook, + .. + } = test_notebook_path( + actual_path, + &expected_path, + &settings::Settings::for_rule(Rule::UnusedImport), + )?; + let mut writer = Vec::new(); + fixed_notebook.write(&mut writer)?; + let actual = String::from_utf8(writer)?; + let expected = std::fs::read_to_string(expected_path)?; + assert_eq!(actual, expected); + Ok(()) + } + + #[test_case(Path::new("before_fix.ipynb"), true; "trailing_newline")] + #[test_case(Path::new("no_trailing_newline.ipynb"), false; "no_trailing_newline")] + fn test_trailing_newline(path: &Path, trailing_newline: bool) -> Result<()> { + let notebook = Notebook::from_path(¬ebook_path(path))?; + assert_eq!(notebook.trailing_newline(), trailing_newline); + + let mut writer = Vec::new(); + notebook.write(&mut writer)?; + let string = String::from_utf8(writer)?; + assert_eq!(string.ends_with('\n'), trailing_newline); + + Ok(()) + } + + // Version <4.5, don't emit cell ids + #[test_case(Path::new("no_cell_id.ipynb"), false; "no_cell_id")] + // Version 4.5, cell ids are missing and need to be added + #[test_case(Path::new("add_missing_cell_id.ipynb"), true; "add_missing_cell_id")] + fn test_cell_id(path: &Path, has_id: bool) -> Result<()> { + let source_notebook = Notebook::from_path(¬ebook_path(path))?; + let source_kind = SourceKind::IpyNotebook(source_notebook); + let (_, transformed) = test_contents( + &source_kind, + path, + &settings::Settings::for_rule(Rule::UnusedImport), + ); + let linted_notebook = transformed.into_owned().expect_ipy_notebook(); + let mut writer = Vec::new(); + linted_notebook.write(&mut writer)?; + let actual = String::from_utf8(writer)?; + if has_id { + assert!(actual.contains(r#""id": ""#)); + } else { + assert!(!actual.contains(r#""id":"#)); + } + Ok(()) + } +} diff --git a/crates/ruff/src/logging.rs b/crates/ruff/src/logging.rs index 6645e38eae..6851680cfb 100644 --- a/crates/ruff/src/logging.rs +++ b/crates/ruff/src/logging.rs @@ -12,8 +12,8 @@ use ruff_python_parser::{ParseError, ParseErrorType}; use ruff_source_file::{OneIndexed, SourceCode, SourceLocation}; use crate::fs; -use crate::jupyter::Notebook; use crate::source_kind::SourceKind; +use ruff_notebook::Notebook; pub static WARNINGS: Lazy>> = Lazy::new(Mutex::default); @@ -139,14 +139,14 @@ pub fn set_up_logging(level: &LogLevel) -> Result<()> { pub struct DisplayParseError<'a> { error: ParseError, source_code: SourceCode<'a, 'a>, - source_kind: Option<&'a SourceKind>, + source_kind: &'a SourceKind, } impl<'a> DisplayParseError<'a> { pub fn new( error: ParseError, source_code: SourceCode<'a, 'a>, - source_kind: Option<&'a SourceKind>, + source_kind: &'a SourceKind, ) -> Self { Self { error, @@ -171,32 +171,29 @@ impl Display for DisplayParseError<'_> { // If we're working on a Jupyter notebook, translate the positions // with respect to the cell and row in the cell. This is the same // format as the `TextEmitter`. - let error_location = if let Some(jupyter_index) = self - .source_kind - .and_then(SourceKind::notebook) - .map(Notebook::index) - { - write!( - f, - "cell {cell}{colon}", - cell = jupyter_index - .cell(source_location.row.get()) - .unwrap_or_default(), - colon = ":".cyan(), - )?; + let error_location = + if let Some(jupyter_index) = self.source_kind.as_ipy_notebook().map(Notebook::index) { + write!( + f, + "cell {cell}{colon}", + cell = jupyter_index + .cell(source_location.row.get()) + .unwrap_or_default(), + colon = ":".cyan(), + )?; - SourceLocation { - row: OneIndexed::new( - jupyter_index - .cell_row(source_location.row.get()) - .unwrap_or(1) as usize, - ) - .unwrap(), - column: source_location.column, - } - } else { - source_location - }; + SourceLocation { + row: OneIndexed::new( + jupyter_index + .cell_row(source_location.row.get()) + .unwrap_or(1) as usize, + ) + .unwrap(), + column: source_location.column, + } + } else { + source_location + }; write!( f, diff --git a/crates/ruff/src/message/gitlab.rs b/crates/ruff/src/message/gitlab.rs index e799823fda..355472212d 100644 --- a/crates/ruff/src/message/gitlab.rs +++ b/crates/ruff/src/message/gitlab.rs @@ -1,4 +1,5 @@ use std::collections::hash_map::DefaultHasher; +use std::collections::HashSet; use std::hash::{Hash, Hasher}; use std::io::Write; @@ -6,8 +7,6 @@ use serde::ser::SerializeSeq; use serde::{Serialize, Serializer}; use serde_json::json; -use ruff_source_file::SourceLocation; - use crate::fs::{relativize_path, relativize_path_to}; use crate::message::{Emitter, EmitterContext, Message}; use crate::registry::AsRule; @@ -58,6 +57,7 @@ impl Serialize for SerializedMessages<'_> { S: Serializer, { let mut s = serializer.serialize_seq(Some(self.messages.len()))?; + let mut fingerprints = HashSet::::with_capacity(self.messages.len()); for message in self.messages { let start_location = message.compute_start_location(); @@ -82,10 +82,19 @@ impl Serialize for SerializedMessages<'_> { |project_dir| relativize_path_to(message.filename(), project_dir), ); + let mut message_fingerprint = fingerprint(message, 0); + + // Make sure that we do not get a fingerprint that is already in use + // by adding in the previously generated one. + while fingerprints.contains(&message_fingerprint) { + message_fingerprint = fingerprint(message, message_fingerprint); + } + fingerprints.insert(message_fingerprint); + let value = json!({ "description": format!("({}) {}", message.kind.rule().noqa_code(), message.kind.body), "severity": "major", - "fingerprint": fingerprint(message, &start_location, &end_location), + "fingerprint": format!("{:x}", message_fingerprint), "location": { "path": path, "lines": lines @@ -100,11 +109,7 @@ impl Serialize for SerializedMessages<'_> { } /// Generate a unique fingerprint to identify a violation. -fn fingerprint( - message: &Message, - start_location: &SourceLocation, - end_location: &SourceLocation, -) -> String { +fn fingerprint(message: &Message, salt: u64) -> u64 { let Message { kind, range: _, @@ -115,12 +120,11 @@ fn fingerprint( let mut hasher = DefaultHasher::new(); - kind.rule().hash(&mut hasher); - start_location.hash(&mut hasher); - end_location.hash(&mut hasher); + salt.hash(&mut hasher); + kind.name.hash(&mut hasher); file.name().hash(&mut hasher); - format!("{:x}", hasher.finish()) + hasher.finish() } #[cfg(test)] diff --git a/crates/ruff/src/message/grouped.rs b/crates/ruff/src/message/grouped.rs index 467a5b5466..41e3f52cd1 100644 --- a/crates/ruff/src/message/grouped.rs +++ b/crates/ruff/src/message/grouped.rs @@ -4,10 +4,10 @@ use std::num::NonZeroUsize; use colored::Colorize; +use ruff_notebook::NotebookIndex; use ruff_source_file::OneIndexed; use crate::fs::relativize_path; -use crate::jupyter::{Notebook, NotebookIndex}; use crate::message::diff::calculate_print_width; use crate::message::text::{MessageCodeFrame, RuleCodeAndBody}; use crate::message::{ @@ -65,7 +65,7 @@ impl Emitter for GroupedEmitter { writer, "{}", DisplayGroupedMessage { - jupyter_index: context.notebook(message.filename()).map(Notebook::index), + notebook_index: context.notebook_index(message.filename()), message, show_fix_status: self.show_fix_status, show_source: self.show_source, @@ -92,7 +92,7 @@ struct DisplayGroupedMessage<'a> { show_source: bool, row_length: NonZeroUsize, column_length: NonZeroUsize, - jupyter_index: Option<&'a NotebookIndex>, + notebook_index: Option<&'a NotebookIndex>, } impl Display for DisplayGroupedMessage<'_> { @@ -110,7 +110,7 @@ impl Display for DisplayGroupedMessage<'_> { )?; // Check if we're working on a jupyter notebook and translate positions with cell accordingly - let (row, col) = if let Some(jupyter_index) = self.jupyter_index { + let (row, col) = if let Some(jupyter_index) = self.notebook_index { write!( f, "cell {cell}{sep}", @@ -150,7 +150,7 @@ impl Display for DisplayGroupedMessage<'_> { "{}", MessageCodeFrame { message, - jupyter_index: self.jupyter_index + notebook_index: self.notebook_index } )?; } diff --git a/crates/ruff/src/message/mod.rs b/crates/ruff/src/message/mod.rs index ea89872600..67ba50df4e 100644 --- a/crates/ruff/src/message/mod.rs +++ b/crates/ruff/src/message/mod.rs @@ -14,12 +14,11 @@ pub use json_lines::JsonLinesEmitter; pub use junit::JunitEmitter; pub use pylint::PylintEmitter; use ruff_diagnostics::{Diagnostic, DiagnosticKind, Fix}; +use ruff_notebook::NotebookIndex; use ruff_source_file::{SourceFile, SourceLocation}; use ruff_text_size::{Ranged, TextRange, TextSize}; pub use text::TextEmitter; -use crate::jupyter::Notebook; - mod azure; mod diff; mod github; @@ -128,21 +127,21 @@ pub trait Emitter { /// Context passed to [`Emitter`]. pub struct EmitterContext<'a> { - notebooks: &'a FxHashMap, + notebook_indexes: &'a FxHashMap, } impl<'a> EmitterContext<'a> { - pub fn new(notebooks: &'a FxHashMap) -> Self { - Self { notebooks } + pub fn new(notebook_indexes: &'a FxHashMap) -> Self { + Self { notebook_indexes } } /// Tests if the file with `name` is a jupyter notebook. pub fn is_notebook(&self, name: &str) -> bool { - self.notebooks.contains_key(name) + self.notebook_indexes.contains_key(name) } - pub fn notebook(&self, name: &str) -> Option<&Notebook> { - self.notebooks.get(name) + pub fn notebook_index(&self, name: &str) -> Option<&NotebookIndex> { + self.notebook_indexes.get(name) } } @@ -226,8 +225,8 @@ def fibonacci(n): emitter: &mut dyn Emitter, messages: &[Message], ) -> String { - let source_kinds = FxHashMap::default(); - let context = EmitterContext::new(&source_kinds); + let notebook_indexes = FxHashMap::default(); + let context = EmitterContext::new(¬ebook_indexes); let mut output: Vec = Vec::new(); emitter.emit(&mut output, messages, &context).unwrap(); diff --git a/crates/ruff/src/message/text.rs b/crates/ruff/src/message/text.rs index 1daec724d3..5abc7fd268 100644 --- a/crates/ruff/src/message/text.rs +++ b/crates/ruff/src/message/text.rs @@ -7,11 +7,11 @@ use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, Sou use bitflags::bitflags; use colored::Colorize; +use ruff_notebook::NotebookIndex; use ruff_source_file::{OneIndexed, SourceLocation}; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::fs::relativize_path; -use crate::jupyter::{Notebook, NotebookIndex}; use crate::line_width::{LineWidthBuilder, TabSize}; use crate::message::diff::Diff; use crate::message::{Emitter, EmitterContext, Message}; @@ -71,14 +71,14 @@ impl Emitter for TextEmitter { )?; let start_location = message.compute_start_location(); - let jupyter_index = context.notebook(message.filename()).map(Notebook::index); + let notebook_index = context.notebook_index(message.filename()); // Check if we're working on a jupyter notebook and translate positions with cell accordingly - let diagnostic_location = if let Some(jupyter_index) = jupyter_index { + let diagnostic_location = if let Some(notebook_index) = notebook_index { write!( writer, "cell {cell}{sep}", - cell = jupyter_index + cell = notebook_index .cell(start_location.row.get()) .unwrap_or_default(), sep = ":".cyan(), @@ -86,7 +86,7 @@ impl Emitter for TextEmitter { SourceLocation { row: OneIndexed::new( - jupyter_index + notebook_index .cell_row(start_location.row.get()) .unwrap_or(1) as usize, ) @@ -115,7 +115,7 @@ impl Emitter for TextEmitter { "{}", MessageCodeFrame { message, - jupyter_index + notebook_index } )?; } @@ -161,7 +161,7 @@ impl Display for RuleCodeAndBody<'_> { pub(super) struct MessageCodeFrame<'a> { pub(crate) message: &'a Message, - pub(crate) jupyter_index: Option<&'a NotebookIndex>, + pub(crate) notebook_index: Option<&'a NotebookIndex>, } impl Display for MessageCodeFrame<'_> { @@ -186,14 +186,12 @@ impl Display for MessageCodeFrame<'_> { let content_start_index = source_code.line_index(range.start()); let mut start_index = content_start_index.saturating_sub(2); - // If we're working on a jupyter notebook, skip the lines which are + // If we're working with a Jupyter Notebook, skip the lines which are // outside of the cell containing the diagnostic. - if let Some(jupyter_index) = self.jupyter_index { - let content_start_cell = jupyter_index - .cell(content_start_index.get()) - .unwrap_or_default(); + if let Some(index) = self.notebook_index { + let content_start_cell = index.cell(content_start_index.get()).unwrap_or_default(); while start_index < content_start_index { - if jupyter_index.cell(start_index.get()).unwrap_or_default() == content_start_cell { + if index.cell(start_index.get()).unwrap_or_default() == content_start_cell { break; } start_index = start_index.saturating_add(1); @@ -213,14 +211,12 @@ impl Display for MessageCodeFrame<'_> { .saturating_add(2) .min(OneIndexed::from_zero_indexed(source_code.line_count())); - // If we're working on a jupyter notebook, skip the lines which are + // If we're working with a Jupyter Notebook, skip the lines which are // outside of the cell containing the diagnostic. - if let Some(jupyter_index) = self.jupyter_index { - let content_end_cell = jupyter_index - .cell(content_end_index.get()) - .unwrap_or_default(); + if let Some(index) = self.notebook_index { + let content_end_cell = index.cell(content_end_index.get()).unwrap_or_default(); while end_index > content_end_index { - if jupyter_index.cell(end_index.get()).unwrap_or_default() == content_end_cell { + if index.cell(end_index.get()).unwrap_or_default() == content_end_cell { break; } end_index = end_index.saturating_sub(1); @@ -256,10 +252,10 @@ impl Display for MessageCodeFrame<'_> { title: None, slices: vec![Slice { source: &source.text, - line_start: self.jupyter_index.map_or_else( + line_start: self.notebook_index.map_or_else( || start_index.get(), - |jupyter_index| { - jupyter_index + |notebook_index| { + notebook_index .cell_row(start_index.get()) .unwrap_or_default() as usize }, diff --git a/crates/ruff/src/noqa.rs b/crates/ruff/src/noqa.rs index 36cf5105a9..c905f7bd5a 100644 --- a/crates/ruff/src/noqa.rs +++ b/crates/ruff/src/noqa.rs @@ -59,7 +59,7 @@ impl<'a> Directive<'a> { if text[..comment_start] .chars() .last() - .is_some_and(|c| c != '#') + .map_or(true, |c| c != '#') { continue; } diff --git a/crates/ruff/src/rule_selector.rs b/crates/ruff/src/rule_selector.rs index a20213b10d..362dcb72b2 100644 --- a/crates/ruff/src/rule_selector.rs +++ b/crates/ruff/src/rule_selector.rs @@ -9,12 +9,16 @@ use crate::codes::RuleCodePrefix; use crate::codes::RuleIter; use crate::registry::{Linter, Rule, RuleNamespace}; use crate::rule_redirects::get_redirect; +use crate::settings::types::PreviewMode; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum RuleSelector { - /// Select all stable rules. + /// Select all rules (includes rules in preview if enabled) All, - /// Select all nursery rules. + /// Category to select all rules in preview (includes legacy nursery rules) + Preview, + /// Legacy category to select all rules in the "nursery" which predated preview mode + #[deprecated(note = "Use `RuleSelector::Preview` for new rules instead")] Nursery, /// Legacy category to select both the `mccabe` and `flake8-comprehensions` linters /// via a single selector. @@ -29,6 +33,11 @@ pub enum RuleSelector { prefix: RuleCodePrefix, redirected_from: Option<&'static str>, }, + /// Select an individual rule with a given prefix. + Rule { + prefix: RuleCodePrefix, + redirected_from: Option<&'static str>, + }, } impl From for RuleSelector { @@ -43,7 +52,9 @@ impl FromStr for RuleSelector { fn from_str(s: &str) -> Result { match s { "ALL" => Ok(Self::All), + #[allow(deprecated)] "NURSERY" => Ok(Self::Nursery), + "PREVIEW" => Ok(Self::Preview), "C" => Ok(Self::C), "T" => Ok(Self::T), _ => { @@ -59,16 +70,43 @@ impl FromStr for RuleSelector { return Ok(Self::Linter(linter)); } - Ok(Self::Prefix { - prefix: RuleCodePrefix::parse(&linter, code) - .map_err(|_| ParseError::Unknown(s.to_string()))?, - redirected_from, - }) + // Does the selector select a single rule? + let prefix = RuleCodePrefix::parse(&linter, code) + .map_err(|_| ParseError::Unknown(s.to_string()))?; + + if is_single_rule_selector(&prefix) { + Ok(Self::Rule { + prefix, + redirected_from, + }) + } else { + Ok(Self::Prefix { + prefix, + redirected_from, + }) + } } } } } +/// Returns `true` if the [`RuleCodePrefix`] matches a single rule exactly +/// (e.g., `E225`, as opposed to `E2`). +pub(crate) fn is_single_rule_selector(prefix: &RuleCodePrefix) -> bool { + let mut rules = prefix.rules(); + + // The selector must match a single rule. + let Some(rule) = rules.next() else { + return false; + }; + if rules.next().is_some() { + return false; + } + + // The rule must match the selector exactly. + rule.noqa_code().suffix() == prefix.short_code() +} + #[derive(Debug, thiserror::Error)] pub enum ParseError { #[error("Unknown rule selector: `{0}`")] @@ -81,10 +119,12 @@ impl RuleSelector { pub fn prefix_and_code(&self) -> (&'static str, &'static str) { match self { RuleSelector::All => ("", "ALL"), + #[allow(deprecated)] RuleSelector::Nursery => ("", "NURSERY"), + RuleSelector::Preview => ("", "PREVIEW"), RuleSelector::C => ("", "C"), RuleSelector::T => ("", "T"), - RuleSelector::Prefix { prefix, .. } => { + RuleSelector::Prefix { prefix, .. } | RuleSelector::Rule { prefix, .. } => { (prefix.linter().common_prefix(), prefix.short_code()) } RuleSelector::Linter(l) => (l.common_prefix(), ""), @@ -135,27 +175,19 @@ impl Visitor<'_> for SelectorVisitor { } } -impl From for RuleSelector { - fn from(prefix: RuleCodePrefix) -> Self { - Self::Prefix { - prefix, - redirected_from: None, - } - } -} - -impl IntoIterator for &RuleSelector { - type IntoIter = RuleSelectorIter; - type Item = Rule; - - fn into_iter(self) -> Self::IntoIter { +impl RuleSelector { + /// Return all matching rules, regardless of whether they're in preview. + pub fn all_rules(&self) -> impl Iterator + '_ { match self { - RuleSelector::All => { - RuleSelectorIter::All(Rule::iter().filter(|rule| !rule.is_nursery())) - } + RuleSelector::All => RuleSelectorIter::All(Rule::iter()), + + #[allow(deprecated)] RuleSelector::Nursery => { RuleSelectorIter::Nursery(Rule::iter().filter(Rule::is_nursery)) } + RuleSelector::Preview => RuleSelectorIter::Nursery( + Rule::iter().filter(|rule| rule.is_preview() || rule.is_nursery()), + ), RuleSelector::C => RuleSelectorIter::Chain( Linter::Flake8Comprehensions .rules() @@ -167,13 +199,28 @@ impl IntoIterator for &RuleSelector { .chain(Linter::Flake8Print.rules()), ), RuleSelector::Linter(linter) => RuleSelectorIter::Vec(linter.rules()), - RuleSelector::Prefix { prefix, .. } => RuleSelectorIter::Vec(prefix.clone().rules()), + RuleSelector::Prefix { prefix, .. } | RuleSelector::Rule { prefix, .. } => { + RuleSelectorIter::Vec(prefix.clone().rules()) + } } } + + /// Returns rules matching the selector, taking into account whether preview mode is enabled. + pub fn rules(&self, preview: PreviewMode) -> impl Iterator + '_ { + #[allow(deprecated)] + self.all_rules().filter(move |rule| { + // Always include rules that are not in preview or the nursery + !(rule.is_preview() || rule.is_nursery()) + // Backwards compatibility allows selection of nursery rules by exact code or dedicated group + || ((matches!(self, RuleSelector::Rule { .. }) || matches!(self, RuleSelector::Nursery { .. })) && rule.is_nursery()) + // Enabling preview includes all preview or nursery rules + || preview.is_enabled() + }) + } } pub enum RuleSelectorIter { - All(std::iter::Filter bool>), + All(RuleIter), Nursery(std::iter::Filter bool>), Chain(std::iter::Chain, std::vec::IntoIter>), Vec(std::vec::IntoIter), @@ -192,18 +239,6 @@ impl Iterator for RuleSelectorIter { } } -/// A const alternative to the `impl From for RuleSelector` -/// to let us keep the fields of [`RuleSelector`] private. -// Note that Rust doesn't yet support `impl const From for -// RuleSelector` (see https://github.com/rust-lang/rust/issues/67792). -// TODO(martin): Remove once RuleSelector is an enum with Linter & Rule variants -pub(crate) const fn prefix_to_selector(prefix: RuleCodePrefix) -> RuleSelector { - RuleSelector::Prefix { - prefix, - redirected_from: None, - } -} - #[cfg(feature = "schemars")] mod schema { use itertools::Itertools; @@ -266,18 +301,20 @@ impl RuleSelector { pub fn specificity(&self) -> Specificity { match self { RuleSelector::All => Specificity::All, + RuleSelector::Preview => Specificity::All, + #[allow(deprecated)] RuleSelector::Nursery => Specificity::All, RuleSelector::T => Specificity::LinterGroup, RuleSelector::C => Specificity::LinterGroup, RuleSelector::Linter(..) => Specificity::Linter, + RuleSelector::Rule { .. } => Specificity::Rule, RuleSelector::Prefix { prefix, .. } => { let prefix: &'static str = prefix.short_code(); match prefix.len() { - 1 => Specificity::Code1Char, - 2 => Specificity::Code2Chars, - 3 => Specificity::Code3Chars, - 4 => Specificity::Code4Chars, - 5 => Specificity::Code5Chars, + 1 => Specificity::Prefix1Char, + 2 => Specificity::Prefix2Chars, + 3 => Specificity::Prefix3Chars, + 4 => Specificity::Prefix4Chars, _ => panic!("RuleSelector::specificity doesn't yet support codes with so many characters"), } } @@ -285,16 +322,24 @@ impl RuleSelector { } } -#[derive(EnumIter, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] +#[derive(EnumIter, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)] pub enum Specificity { + /// The specificity when selecting all rules (e.g., `--select ALL`). All, + /// The specificity when selecting a legacy linter group (e.g., `--select C` or `--select T`). LinterGroup, + /// The specificity when selecting a linter (e.g., `--select PLE` or `--select UP`). Linter, - Code1Char, - Code2Chars, - Code3Chars, - Code4Chars, - Code5Chars, + /// The specificity when selecting via a rule prefix with a one-character code (e.g., `--select PLE1`). + Prefix1Char, + /// The specificity when selecting via a rule prefix with a two-character code (e.g., `--select PLE12`). + Prefix2Chars, + /// The specificity when selecting via a rule prefix with a three-character code (e.g., `--select PLE123`). + Prefix3Chars, + /// The specificity when selecting via a rule prefix with a four-character code (e.g., `--select PLE1234`). + Prefix4Chars, + /// The specificity when selecting an individual rule (e.g., `--select PLE1205`). + Rule, } #[cfg(feature = "clap")] diff --git a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff/src/rules/flake8_annotations/rules/definition.rs index 0748e663a6..f86e84830c 100644 --- a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff/src/rules/flake8_annotations/rules/definition.rs @@ -454,7 +454,6 @@ fn check_dynamically_typed( if let Expr::Constant(ast::ExprConstant { range, value: Constant::Str(string), - .. }) = annotation { // Quoted annotations diff --git a/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs b/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs index 4112c6ae7a..6c91cb0c17 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs @@ -23,6 +23,10 @@ use ruff_text_size::Ranged; /// /// Use instead: /// ```python +/// if not x > 0: +/// raise ValueError("Expected positive value.") +/// +/// # or even better: /// if x <= 0: /// raise ValueError("Expected positive value.") /// ``` diff --git a/crates/ruff/src/rules/flake8_bugbear/mod.rs b/crates/ruff/src/rules/flake8_bugbear/mod.rs index 717bb1ee3a..71ec3b130a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/mod.rs +++ b/crates/ruff/src/rules/flake8_bugbear/mod.rs @@ -33,6 +33,9 @@ mod tests { #[test_case(Rule::JumpStatementInFinally, Path::new("B012.py"))] #[test_case(Rule::LoopVariableOverridesIterator, Path::new("B020.py"))] #[test_case(Rule::MutableArgumentDefault, Path::new("B006_B008.py"))] + #[test_case(Rule::MutableArgumentDefault, Path::new("B006_1.py"))] + #[test_case(Rule::MutableArgumentDefault, Path::new("B006_2.py"))] + #[test_case(Rule::MutableArgumentDefault, Path::new("B006_3.py"))] #[test_case(Rule::NoExplicitStacklevel, Path::new("B028.py"))] #[test_case(Rule::RaiseLiteral, Path::new("B016.py"))] #[test_case(Rule::RaiseWithoutFromInsideExcept, Path::new("B904.py"))] diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs b/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs index 572bc139e8..c66e1d452a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs @@ -1,7 +1,6 @@ -use ruff_python_ast::{self as ast, Constant, Expr}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private}; use ruff_text_size::Ranged; @@ -81,7 +80,17 @@ pub(crate) fn getattr_with_constant( let mut diagnostic = Diagnostic::new(GetAttrWithConstant, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - format!("{}.{}", checker.locator().slice(obj), value), + if matches!( + obj, + Expr::Name(_) | Expr::Attribute(_) | Expr::Subscript(_) | Expr::Call(_) + ) { + format!("{}.{}", checker.locator().slice(obj), value) + } else { + // Defensively parenthesize any other expressions. For example, attribute accesses + // on `int` literals must be parenthesized, e.g., `getattr(1, "real")` becomes + // `(1).real`. The same is true for named expressions and others. + format!("({}).{}", checker.locator().slice(obj), value) + }, expr.range(), ))); } diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs b/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs index bf3c0fc531..c1a34be60c 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs @@ -175,8 +175,15 @@ fn move_initialization( return None; } Edit::insertion(content, locator.line_start(statement.start())) + } else if locator.full_line_end(statement.end()) == locator.text_len() { + // If the statement is at the end of the file, without a trailing newline, insert + // _after_ it with an extra newline. + Edit::insertion( + format!("{}{}", stylist.line_ending().as_str(), content), + locator.full_line_end(statement.end()), + ) } else { - // If the docstring is the only statement, insert _before_ it. + // If the docstring is the only statement, insert _after_ it. Edit::insertion(content, locator.full_line_end(statement.end())) } } else { diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs b/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs index 68accc1b65..cabcd9b558 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::helpers::map_starred; +use ruff_python_ast::{self as ast, ExceptHandler, Expr}; use ruff_text_size::Ranged; +use crate::autofix::edits::pad; use crate::checkers::ast::Checker; use crate::registry::AsRule; @@ -41,11 +42,7 @@ pub struct RedundantTupleInExceptionHandler { impl AlwaysAutofixableViolation for RedundantTupleInExceptionHandler { #[derive_message_formats] fn message(&self) -> String { - let RedundantTupleInExceptionHandler { name } = self; - format!( - "A length-one tuple literal is redundant. Write `except {name}` instead of `except \ - ({name},)`." - ) + format!("A length-one tuple literal is redundant in exception handlers") } fn autofix_title(&self) -> String { @@ -70,9 +67,10 @@ pub(crate) fn redundant_tuple_in_exception_handler( let Expr::Tuple(ast::ExprTuple { elts, .. }) = type_.as_ref() else { continue; }; - let [elt] = &elts[..] else { + let [elt] = elts.as_slice() else { continue; }; + let elt = map_starred(elt); let mut diagnostic = Diagnostic::new( RedundantTupleInExceptionHandler { name: checker.generator().expr(elt), @@ -80,8 +78,19 @@ pub(crate) fn redundant_tuple_in_exception_handler( type_.range(), ); if checker.patch(diagnostic.kind.rule()) { + // If there's no space between the `except` and the tuple, we need to insert a space, + // as in: + // ```python + // except(ValueError,): + // ``` + // Otherwise, the output will be invalid syntax, since we're removing a set of + // parentheses. diagnostic.set_fix(Fix::automatic(Edit::range_replacement( - checker.generator().expr(elt), + pad( + checker.generator().expr(elt), + type_.range(), + checker.locator(), + ), type_.range(), ))); } diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_1.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_1.py.snap new file mode 100644 index 0000000000..092572890d --- /dev/null +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_1.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff/src/rules/flake8_bugbear/mod.rs +--- +B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument defaults + | +1 | # Docstring followed by a newline +2 | +3 | def foobar(foor, bar={}): + | ^^ B006 +4 | """ +5 | """ + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +1 1 | # Docstring followed by a newline +2 2 | +3 |-def foobar(foor, bar={}): + 3 |+def foobar(foor, bar=None): +4 4 | """ +5 5 | """ + 6 |+ + 7 |+ if bar is None: + 8 |+ bar = {} + + diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_2.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_2.py.snap new file mode 100644 index 0000000000..1e34f109fb --- /dev/null +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_2.py.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff/src/rules/flake8_bugbear/mod.rs +--- +B006_2.py:4:22: B006 [*] Do not use mutable data structures for argument defaults + | +2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 +3 | +4 | def foobar(foor, bar={}): + | ^^ B006 +5 | """ +6 | """ + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +1 1 | # Docstring followed by whitespace with no newline +2 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 +3 3 | +4 |-def foobar(foor, bar={}): + 4 |+def foobar(foor, bar=None): +5 5 | """ +6 |- """ + 6 |+ """ + 7 |+ if bar is None: + 8 |+ bar = {} + + diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_3.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_3.py.snap new file mode 100644 index 0000000000..037d2d67cf --- /dev/null +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_3.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff/src/rules/flake8_bugbear/mod.rs +--- +B006_3.py:4:22: B006 [*] Do not use mutable data structures for argument defaults + | +4 | def foobar(foor, bar={}): + | ^^ B006 +5 | """ +6 | """ + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +1 1 | # Docstring with no newline +2 2 | +3 3 | +4 |-def foobar(foor, bar={}): + 4 |+def foobar(foor, bar=None): + 5 |+ """ +5 6 | """ +6 |- """ + 7 |+ if bar is None: + 8 |+ bar = {} + + diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap index b98badffde..05c860d523 100644 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap @@ -476,4 +476,23 @@ B006_B008.py:308:52: B006 Do not use mutable data structures for argument defaul | = help: Replace with `None`; initialize within function +B006_B008.py:313:52: B006 [*] Do not use mutable data structures for argument defaults + | +313 | def single_line_func_wrong(value: dict[str, str] = {}): + | ^^ B006 +314 | """Docstring without newline""" + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +310 310 | """Docstring""" +311 311 | +312 312 | +313 |-def single_line_func_wrong(value: dict[str, str] = {}): +314 |- """Docstring without newline""" + 313 |+def single_line_func_wrong(value: dict[str, str] = None): + 314 |+ """Docstring without newline""" + 315 |+ if value is None: + 316 |+ value = {} + diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap index 94bc6e4483..89e970b2d8 100644 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap @@ -124,7 +124,7 @@ B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute val 24 |+_ = lambda x: x.bar 25 25 | if getattr(x, "bar"): 26 26 | pass -27 27 | +27 27 | getattr(1, "real") B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. | @@ -133,6 +133,7 @@ B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute valu 25 | if getattr(x, "bar"): | ^^^^^^^^^^^^^^^^^ B009 26 | pass +27 | getattr(1, "real") | = help: Replace `getattr` with attribute access @@ -143,7 +144,176 @@ B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute valu 25 |-if getattr(x, "bar"): 25 |+if x.bar: 26 26 | pass -27 27 | -28 28 | # Valid setattr usage +27 27 | getattr(1, "real") +28 28 | getattr(1., "real") + +B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +25 | if getattr(x, "bar"): +26 | pass +27 | getattr(1, "real") + | ^^^^^^^^^^^^^^^^^^ B009 +28 | getattr(1., "real") +29 | getattr(1.0, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +24 24 | _ = lambda x: getattr(x, "bar") +25 25 | if getattr(x, "bar"): +26 26 | pass +27 |-getattr(1, "real") + 27 |+(1).real +28 28 | getattr(1., "real") +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") + +B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +26 | pass +27 | getattr(1, "real") +28 | getattr(1., "real") + | ^^^^^^^^^^^^^^^^^^^ B009 +29 | getattr(1.0, "real") +30 | getattr(1j, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +25 25 | if getattr(x, "bar"): +26 26 | pass +27 27 | getattr(1, "real") +28 |-getattr(1., "real") + 28 |+(1.).real +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") + +B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +27 | getattr(1, "real") +28 | getattr(1., "real") +29 | getattr(1.0, "real") + | ^^^^^^^^^^^^^^^^^^^^ B009 +30 | getattr(1j, "real") +31 | getattr(True, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +26 26 | pass +27 27 | getattr(1, "real") +28 28 | getattr(1., "real") +29 |-getattr(1.0, "real") + 29 |+(1.0).real +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") + +B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +28 | getattr(1., "real") +29 | getattr(1.0, "real") +30 | getattr(1j, "real") + | ^^^^^^^^^^^^^^^^^^^ B009 +31 | getattr(True, "real") +32 | getattr(x := 1, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +27 27 | getattr(1, "real") +28 28 | getattr(1., "real") +29 29 | getattr(1.0, "real") +30 |-getattr(1j, "real") + 30 |+(1j).real +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") +33 33 | getattr(x + y, "real") + +B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +29 | getattr(1.0, "real") +30 | getattr(1j, "real") +31 | getattr(True, "real") + | ^^^^^^^^^^^^^^^^^^^^^ B009 +32 | getattr(x := 1, "real") +33 | getattr(x + y, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +28 28 | getattr(1., "real") +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") +31 |-getattr(True, "real") + 31 |+(True).real +32 32 | getattr(x := 1, "real") +33 33 | getattr(x + y, "real") +34 34 | getattr("foo" + +B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +30 | getattr(1j, "real") +31 | getattr(True, "real") +32 | getattr(x := 1, "real") + | ^^^^^^^^^^^^^^^^^^^^^^^ B009 +33 | getattr(x + y, "real") +34 | getattr("foo" + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") +32 |-getattr(x := 1, "real") + 32 |+(x := 1).real +33 33 | getattr(x + y, "real") +34 34 | getattr("foo" +35 35 | "bar", "real") + +B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +31 | getattr(True, "real") +32 | getattr(x := 1, "real") +33 | getattr(x + y, "real") + | ^^^^^^^^^^^^^^^^^^^^^^ B009 +34 | getattr("foo" +35 | "bar", "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") +33 |-getattr(x + y, "real") + 33 |+(x + y).real +34 34 | getattr("foo" +35 35 | "bar", "real") +36 36 | + +B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +32 | getattr(x := 1, "real") +33 | getattr(x + y, "real") +34 | / getattr("foo" +35 | | "bar", "real") + | |______________________^ B009 + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") +33 33 | getattr(x + y, "real") +34 |-getattr("foo" +35 |- "bar", "real") + 34 |+("foo" + 35 |+ "bar").real +36 36 | +37 37 | +38 38 | # Valid setattr usage diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap index e8b728cd8f..81590e3d1a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap @@ -1,120 +1,120 @@ --- source: crates/ruff/src/rules/flake8_bugbear/mod.rs --- -B009_B010.py:40:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | -39 | # Invalid usage -40 | setattr(foo, "bar", None) +49 | # Invalid usage +50 | setattr(foo, "bar", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -41 | setattr(foo, "_123abc", None) -42 | setattr(foo, "__123abc__", None) +51 | setattr(foo, "_123abc", None) +52 | setattr(foo, "__123abc__", None) | = help: Replace `setattr` with assignment ℹ Suggested fix -37 37 | pass -38 38 | -39 39 | # Invalid usage -40 |-setattr(foo, "bar", None) - 40 |+foo.bar = None -41 41 | setattr(foo, "_123abc", None) -42 42 | setattr(foo, "__123abc__", None) -43 43 | setattr(foo, "abc123", None) +47 47 | pass +48 48 | +49 49 | # Invalid usage +50 |-setattr(foo, "bar", None) + 50 |+foo.bar = None +51 51 | setattr(foo, "_123abc", None) +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) -B009_B010.py:41:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | -39 | # Invalid usage -40 | setattr(foo, "bar", None) -41 | setattr(foo, "_123abc", None) +49 | # Invalid usage +50 | setattr(foo, "bar", None) +51 | setattr(foo, "_123abc", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -42 | setattr(foo, "__123abc__", None) -43 | setattr(foo, "abc123", None) +52 | setattr(foo, "__123abc__", None) +53 | setattr(foo, "abc123", None) | = help: Replace `setattr` with assignment ℹ Suggested fix -38 38 | -39 39 | # Invalid usage -40 40 | setattr(foo, "bar", None) -41 |-setattr(foo, "_123abc", None) - 41 |+foo._123abc = None -42 42 | setattr(foo, "__123abc__", None) -43 43 | setattr(foo, "abc123", None) -44 44 | setattr(foo, r"abc123", None) +48 48 | +49 49 | # Invalid usage +50 50 | setattr(foo, "bar", None) +51 |-setattr(foo, "_123abc", None) + 51 |+foo._123abc = None +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) +54 54 | setattr(foo, r"abc123", None) -B009_B010.py:42:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | -40 | setattr(foo, "bar", None) -41 | setattr(foo, "_123abc", None) -42 | setattr(foo, "__123abc__", None) +50 | setattr(foo, "bar", None) +51 | setattr(foo, "_123abc", None) +52 | setattr(foo, "__123abc__", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -43 | setattr(foo, "abc123", None) -44 | setattr(foo, r"abc123", None) +53 | setattr(foo, "abc123", None) +54 | setattr(foo, r"abc123", None) | = help: Replace `setattr` with assignment ℹ Suggested fix -39 39 | # Invalid usage -40 40 | setattr(foo, "bar", None) -41 41 | setattr(foo, "_123abc", None) -42 |-setattr(foo, "__123abc__", None) - 42 |+foo.__123abc__ = None -43 43 | setattr(foo, "abc123", None) -44 44 | setattr(foo, r"abc123", None) -45 45 | setattr(foo.bar, r"baz", None) +49 49 | # Invalid usage +50 50 | setattr(foo, "bar", None) +51 51 | setattr(foo, "_123abc", None) +52 |-setattr(foo, "__123abc__", None) + 52 |+foo.__123abc__ = None +53 53 | setattr(foo, "abc123", None) +54 54 | setattr(foo, r"abc123", None) +55 55 | setattr(foo.bar, r"baz", None) -B009_B010.py:43:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | -41 | setattr(foo, "_123abc", None) -42 | setattr(foo, "__123abc__", None) -43 | setattr(foo, "abc123", None) +51 | setattr(foo, "_123abc", None) +52 | setattr(foo, "__123abc__", None) +53 | setattr(foo, "abc123", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -44 | setattr(foo, r"abc123", None) -45 | setattr(foo.bar, r"baz", None) +54 | setattr(foo, r"abc123", None) +55 | setattr(foo.bar, r"baz", None) | = help: Replace `setattr` with assignment ℹ Suggested fix -40 40 | setattr(foo, "bar", None) -41 41 | setattr(foo, "_123abc", None) -42 42 | setattr(foo, "__123abc__", None) -43 |-setattr(foo, "abc123", None) - 43 |+foo.abc123 = None -44 44 | setattr(foo, r"abc123", None) -45 45 | setattr(foo.bar, r"baz", None) +50 50 | setattr(foo, "bar", None) +51 51 | setattr(foo, "_123abc", None) +52 52 | setattr(foo, "__123abc__", None) +53 |-setattr(foo, "abc123", None) + 53 |+foo.abc123 = None +54 54 | setattr(foo, r"abc123", None) +55 55 | setattr(foo.bar, r"baz", None) -B009_B010.py:44:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | -42 | setattr(foo, "__123abc__", None) -43 | setattr(foo, "abc123", None) -44 | setattr(foo, r"abc123", None) +52 | setattr(foo, "__123abc__", None) +53 | setattr(foo, "abc123", None) +54 | setattr(foo, r"abc123", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -45 | setattr(foo.bar, r"baz", None) +55 | setattr(foo.bar, r"baz", None) | = help: Replace `setattr` with assignment ℹ Suggested fix -41 41 | setattr(foo, "_123abc", None) -42 42 | setattr(foo, "__123abc__", None) -43 43 | setattr(foo, "abc123", None) -44 |-setattr(foo, r"abc123", None) - 44 |+foo.abc123 = None -45 45 | setattr(foo.bar, r"baz", None) +51 51 | setattr(foo, "_123abc", None) +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) +54 |-setattr(foo, r"abc123", None) + 54 |+foo.abc123 = None +55 55 | setattr(foo.bar, r"baz", None) -B009_B010.py:45:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | -43 | setattr(foo, "abc123", None) -44 | setattr(foo, r"abc123", None) -45 | setattr(foo.bar, r"baz", None) +53 | setattr(foo, "abc123", None) +54 | setattr(foo, r"abc123", None) +55 | setattr(foo.bar, r"baz", None) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 | = help: Replace `setattr` with assignment ℹ Suggested fix -42 42 | setattr(foo, "__123abc__", None) -43 43 | setattr(foo, "abc123", None) -44 44 | setattr(foo, r"abc123", None) -45 |-setattr(foo.bar, r"baz", None) - 45 |+foo.bar.baz = None +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) +54 54 | setattr(foo, r"abc123", None) +55 |-setattr(foo.bar, r"baz", None) + 55 |+foo.bar.baz = None diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap index 3be573fd87..01c7ebda55 100644 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap +++ b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap @@ -1,24 +1,64 @@ --- source: crates/ruff/src/rules/flake8_bugbear/mod.rs --- -B013.py:3:8: B013 [*] A length-one tuple literal is redundant. Write `except ValueError` instead of `except (ValueError,)`. +B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handlers | -1 | try: -2 | pass -3 | except (ValueError,): - | ^^^^^^^^^^^^^ B013 +3 | try: 4 | pass -5 | except AttributeError: +5 | except (ValueError,): + | ^^^^^^^^^^^^^ B013 +6 | pass +7 | except AttributeError: | = help: Replace with `except ValueError` ℹ Fix -1 1 | try: -2 2 | pass -3 |-except (ValueError,): - 3 |+except ValueError: +2 2 | +3 3 | try: 4 4 | pass -5 5 | except AttributeError: +5 |-except (ValueError,): + 5 |+except ValueError: 6 6 | pass +7 7 | except AttributeError: +8 8 | pass + +B013.py:11:8: B013 [*] A length-one tuple literal is redundant in exception handlers + | + 9 | except (ImportError, TypeError): +10 | pass +11 | except (*retriable_exceptions,): + | ^^^^^^^^^^^^^^^^^^^^^^^^ B013 +12 | pass +13 | except(ValueError,): + | + = help: Replace with `except retriable_exceptions` + +ℹ Fix +8 8 | pass +9 9 | except (ImportError, TypeError): +10 10 | pass +11 |-except (*retriable_exceptions,): + 11 |+except retriable_exceptions: +12 12 | pass +13 13 | except(ValueError,): +14 14 | pass + +B013.py:13:7: B013 [*] A length-one tuple literal is redundant in exception handlers + | +11 | except (*retriable_exceptions,): +12 | pass +13 | except(ValueError,): + | ^^^^^^^^^^^^^ B013 +14 | pass + | + = help: Replace with `except ValueError` + +ℹ Fix +10 10 | pass +11 11 | except (*retriable_exceptions,): +12 12 | pass +13 |-except(ValueError,): + 13 |+except ValueError: +14 14 | pass diff --git a/crates/ruff/src/rules/flake8_comprehensions/fixes.rs b/crates/ruff/src/rules/flake8_comprehensions/fixes.rs index 3c5aaa9287..3c4fc055d7 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/fixes.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/fixes.rs @@ -3,8 +3,8 @@ use itertools::Itertools; use libcst_native::{ Arg, AssignEqual, AssignTargetExpression, Call, Comment, CompFor, Dict, DictComp, DictElement, Element, EmptyLine, Expression, GeneratorExp, LeftCurlyBrace, LeftParen, LeftSquareBracket, - List, ListComp, Name, ParenthesizableWhitespace, ParenthesizedWhitespace, RightCurlyBrace, - RightParen, RightSquareBracket, Set, SetComp, SimpleString, SimpleWhitespace, + List, ListComp, Name, ParenthesizableWhitespace, ParenthesizedNode, ParenthesizedWhitespace, + RightCurlyBrace, RightParen, RightSquareBracket, Set, SetComp, SimpleString, SimpleWhitespace, TrailingWhitespace, Tuple, }; use ruff_python_ast::Expr; @@ -12,9 +12,12 @@ use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{Edit, Fix}; use ruff_python_codegen::Stylist; +use ruff_python_semantic::SemanticModel; use ruff_source_file::Locator; use crate::autofix::codemods::CodegenStylist; +use crate::autofix::edits::pad; +use crate::cst::helpers::space; use crate::rules::flake8_comprehensions::rules::ObjectType; use crate::{ checkers::ast::Checker, @@ -26,9 +29,9 @@ use crate::{ /// (C400) Convert `list(x for x in y)` to `[x for x in y]`. pub(crate) fn fix_unnecessary_generator_list( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { // Expr(Call(GeneratorExp)))) -> Expr(ListComp))) let module_text = locator.slice(expr); @@ -58,7 +61,7 @@ pub(crate) fn fix_unnecessary_generator_list( } /// (C401) Convert `set(x for x in y)` to `{x for x in y}`. -pub(crate) fn fix_unnecessary_generator_set(checker: &Checker, expr: &Expr) -> Result { +pub(crate) fn fix_unnecessary_generator_set(expr: &Expr, checker: &Checker) -> Result { let locator = checker.locator(); let stylist = checker.stylist(); @@ -86,14 +89,14 @@ pub(crate) fn fix_unnecessary_generator_set(checker: &Checker, expr: &Expr) -> R let content = tree.codegen_stylist(stylist); Ok(Edit::range_replacement( - pad_expression(content, expr.range(), checker), + pad_expression(content, expr.range(), checker.locator(), checker.semantic()), expr.range(), )) } /// (C402) Convert `dict((x, x) for x in range(3))` to `{x: x for x in /// range(3)}`. -pub(crate) fn fix_unnecessary_generator_dict(checker: &Checker, expr: &Expr) -> Result { +pub(crate) fn fix_unnecessary_generator_dict(expr: &Expr, checker: &Checker) -> Result { let locator = checker.locator(); let stylist = checker.stylist(); @@ -110,10 +113,20 @@ pub(crate) fn fix_unnecessary_generator_dict(checker: &Checker, expr: &Expr) -> bail!("Expected tuple to contain two elements"); }; + // Insert whitespace before the `for`, since we're removing parentheses, as in: + // ```python + // dict((x, x)for x in range(3)) + // ``` + let mut for_in = generator_exp.for_in.clone(); + if for_in.whitespace_before == ParenthesizableWhitespace::default() { + for_in.whitespace_before = + ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")); + } + tree = Expression::DictComp(Box::new(DictComp { key: Box::new(key.clone()), value: Box::new(value.clone()), - for_in: generator_exp.for_in.clone(), + for_in, lbrace: LeftCurlyBrace { whitespace_after: call.whitespace_before_args.clone(), }, @@ -123,19 +136,24 @@ pub(crate) fn fix_unnecessary_generator_dict(checker: &Checker, expr: &Expr) -> lpar: vec![], rpar: vec![], whitespace_before_colon: ParenthesizableWhitespace::default(), - whitespace_after_colon: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), + whitespace_after_colon: space(), })); Ok(Edit::range_replacement( - pad_expression(tree.codegen_stylist(stylist), expr.range(), checker), + pad_expression( + tree.codegen_stylist(stylist), + expr.range(), + checker.locator(), + checker.semantic(), + ), expr.range(), )) } /// (C403) Convert `set([x for x in y])` to `{x for x in y}`. pub(crate) fn fix_unnecessary_list_comprehension_set( - checker: &Checker, expr: &Expr, + checker: &Checker, ) -> Result { let locator = checker.locator(); let stylist = checker.stylist(); @@ -162,7 +180,12 @@ pub(crate) fn fix_unnecessary_list_comprehension_set( })); Ok(Edit::range_replacement( - pad_expression(tree.codegen_stylist(stylist), expr.range(), checker), + pad_expression( + tree.codegen_stylist(stylist), + expr.range(), + checker.locator(), + checker.semantic(), + ), expr.range(), )) } @@ -170,8 +193,8 @@ pub(crate) fn fix_unnecessary_list_comprehension_set( /// (C404) Convert `dict([(i, i) for i in range(3)])` to `{i: i for i in /// range(3)}`. pub(crate) fn fix_unnecessary_list_comprehension_dict( - checker: &Checker, expr: &Expr, + checker: &Checker, ) -> Result { let locator = checker.locator(); let stylist = checker.stylist(); @@ -190,12 +213,22 @@ pub(crate) fn fix_unnecessary_list_comprehension_dict( bail!("Expected tuple with two elements"); }; + // Insert whitespace before the `for`, since we're removing parentheses, as in: + // ```python + // dict((x, x)for x in range(3)) + // ``` + let mut for_in = list_comp.for_in.clone(); + if for_in.whitespace_before == ParenthesizableWhitespace::default() { + for_in.whitespace_before = + ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")); + } + tree = Expression::DictComp(Box::new(DictComp { key: Box::new(key.clone()), value: Box::new(value.clone()), - for_in: list_comp.for_in.clone(), + for_in, whitespace_before_colon: ParenthesizableWhitespace::default(), - whitespace_after_colon: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), + whitespace_after_colon: space(), lbrace: LeftCurlyBrace { whitespace_after: call.whitespace_before_args.clone(), }, @@ -207,7 +240,12 @@ pub(crate) fn fix_unnecessary_list_comprehension_dict( })); Ok(Edit::range_replacement( - pad_expression(tree.codegen_stylist(stylist), expr.range(), checker), + pad_expression( + tree.codegen_stylist(stylist), + expr.range(), + checker.locator(), + checker.semantic(), + ), expr.range(), )) } @@ -256,7 +294,7 @@ fn drop_trailing_comma<'a>( } /// (C405) Convert `set((1, 2))` to `{1, 2}`. -pub(crate) fn fix_unnecessary_literal_set(checker: &Checker, expr: &Expr) -> Result { +pub(crate) fn fix_unnecessary_literal_set(expr: &Expr, checker: &Checker) -> Result { let locator = checker.locator(); let stylist = checker.stylist(); @@ -291,13 +329,18 @@ pub(crate) fn fix_unnecessary_literal_set(checker: &Checker, expr: &Expr) -> Res } Ok(Edit::range_replacement( - pad_expression(tree.codegen_stylist(stylist), expr.range(), checker), + pad_expression( + tree.codegen_stylist(stylist), + expr.range(), + checker.locator(), + checker.semantic(), + ), expr.range(), )) } /// (C406) Convert `dict([(1, 2)])` to `{1: 2}`. -pub(crate) fn fix_unnecessary_literal_dict(checker: &Checker, expr: &Expr) -> Result { +pub(crate) fn fix_unnecessary_literal_dict(expr: &Expr, checker: &Checker) -> Result { let locator = checker.locator(); let stylist = checker.stylist(); @@ -354,13 +397,18 @@ pub(crate) fn fix_unnecessary_literal_dict(checker: &Checker, expr: &Expr) -> Re })); Ok(Edit::range_replacement( - pad_expression(tree.codegen_stylist(stylist), expr.range(), checker), + pad_expression( + tree.codegen_stylist(stylist), + expr.range(), + checker.locator(), + checker.semantic(), + ), expr.range(), )) } /// (C408) -pub(crate) fn fix_unnecessary_collection_call(checker: &Checker, expr: &Expr) -> Result { +pub(crate) fn fix_unnecessary_collection_call(expr: &Expr, checker: &Checker) -> Result { enum Collection { Tuple, List, @@ -470,7 +518,12 @@ pub(crate) fn fix_unnecessary_collection_call(checker: &Checker, expr: &Expr) -> Ok(Edit::range_replacement( if matches!(collection, Collection::Dict) { - pad_expression(tree.codegen_stylist(stylist), expr.range(), checker) + pad_expression( + tree.codegen_stylist(stylist), + expr.range(), + checker.locator(), + checker.semantic(), + ) } else { tree.codegen_stylist(stylist) }, @@ -490,19 +543,24 @@ pub(crate) fn fix_unnecessary_collection_call(checker: &Checker, expr: &Expr) -> /// However, this is a syntax error under the f-string grammar. As such, /// this method will pad the start and end of an expression as needed to /// avoid producing invalid syntax. -fn pad_expression(content: String, range: TextRange, checker: &Checker) -> String { - if !checker.semantic().in_f_string() { +fn pad_expression( + content: String, + range: TextRange, + locator: &Locator, + semantic: &SemanticModel, +) -> String { + if !semantic.in_f_string() { return content; } // If the expression is immediately preceded by an opening brace, then // we need to add a space before the expression. - let prefix = checker.locator().up_to(range.start()); + let prefix = locator.up_to(range.start()); let left_pad = matches!(prefix.chars().next_back(), Some('{')); // If the expression is immediately preceded by an opening brace, then // we need to add a space before the expression. - let suffix = checker.locator().after(range.end()); + let suffix = locator.after(range.end()); let right_pad = matches!(suffix.chars().next(), Some('}')); if left_pad && right_pad { @@ -518,9 +576,9 @@ fn pad_expression(content: String, range: TextRange, checker: &Checker) -> Strin /// (C409) Convert `tuple([1, 2])` to `tuple(1, 2)` pub(crate) fn fix_unnecessary_literal_within_tuple_call( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; @@ -568,9 +626,9 @@ pub(crate) fn fix_unnecessary_literal_within_tuple_call( /// (C410) Convert `list([1, 2])` to `[1, 2]` pub(crate) fn fix_unnecessary_literal_within_list_call( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; @@ -620,9 +678,9 @@ pub(crate) fn fix_unnecessary_literal_within_list_call( /// (C411) Convert `list([i * i for i in x])` to `[i * i for i in x]`. pub(crate) fn fix_unnecessary_list_call( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { // Expr(Call(List|Tuple)))) -> Expr(List|Tuple))) let module_text = locator.slice(expr); @@ -642,9 +700,9 @@ pub(crate) fn fix_unnecessary_list_call( /// (C413) Convert `reversed(sorted([2, 3, 1]))` to `sorted([2, 3, 1], /// reverse=True)`. pub(crate) fn fix_unnecessary_call_around_sorted( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; @@ -660,7 +718,7 @@ pub(crate) fn fix_unnecessary_call_around_sorted( if outer_name.value == "list" { tree = Expression::Call(Box::new((*inner_call).clone())); } else { - // If the `reverse` argument is used + // If the `reverse` argument is used... let args = if inner_call.args.iter().any(|arg| { matches!( arg.keyword, @@ -712,6 +770,28 @@ pub(crate) fn fix_unnecessary_call_around_sorted( .collect_vec() } else { let mut args = inner_call.args.clone(); + + // If necessary, parenthesize a generator expression, as a generator expression must + // be parenthesized if it's not a solitary argument. For example, given: + // ```python + // reversed(sorted(i for i in range(42))) + // ``` + // Rewrite as: + // ```python + // sorted((i for i in range(42)), reverse=True) + // ``` + if let [arg] = args.as_mut_slice() { + if matches!(arg.value, Expression::GeneratorExp(_)) { + if arg.value.lpar().is_empty() && arg.value.rpar().is_empty() { + arg.value = arg + .value + .clone() + .with_parens(LeftParen::default(), RightParen::default()); + } + } + } + + // Add the `reverse=True` argument. args.push(Arg { value: Expression::Name(Box::new(Name { value: "True", @@ -754,9 +834,9 @@ pub(crate) fn fix_unnecessary_call_around_sorted( /// (C414) Convert `sorted(list(foo))` to `sorted(foo)` pub(crate) fn fix_unnecessary_double_cast_or_process( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; @@ -785,9 +865,9 @@ pub(crate) fn fix_unnecessary_double_cast_or_process( /// (C416) Convert `[i for i in x]` to `list(x)`. pub(crate) fn fix_unnecessary_comprehension( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; @@ -865,161 +945,172 @@ pub(crate) fn fix_unnecessary_comprehension( } Ok(Edit::range_replacement( - tree.codegen_stylist(stylist), + pad(tree.codegen_stylist(stylist), expr.range(), locator), expr.range(), )) } /// (C417) Convert `map(lambda x: x * 2, bar)` to `(x * 2 for x in bar)`. pub(crate) fn fix_unnecessary_map( - locator: &Locator, - stylist: &Stylist, expr: &Expr, parent: Option<&Expr>, object_type: ObjectType, + locator: &Locator, + stylist: &Stylist, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; let call = match_call_mut(&mut tree)?; - let arg = match_arg(call)?; - let (args, lambda_func) = match &arg.value { - Expression::Call(outer_call) => { - let inner_lambda = outer_call.args.first().unwrap().value.clone(); - match &inner_lambda { - Expression::Lambda(..) => (outer_call.args.clone(), inner_lambda), - _ => { - bail!("Expected a lambda function") - } - } + let (lambda, iter) = match call.args.as_slice() { + [call] => { + let call = match_call(&call.value)?; + let [lambda, iter] = call.args.as_slice() else { + bail!("Expected two arguments"); + }; + let lambda = match_lambda(&lambda.value)?; + let iter = &iter.value; + (lambda, iter) } - Expression::Lambda(..) => (call.args.clone(), arg.value.clone()), - _ => { - bail!("Expected a lambda or call") + [lambda, iter] => { + let lambda = match_lambda(&lambda.value)?; + let iter = &iter.value; + (lambda, iter) } + _ => bail!("Expected a call or lambda"), }; - let func_body = match_lambda(&lambda_func)?; + // Format the lambda target. + let target = match lambda.params.params.as_slice() { + // Ex) `lambda: x` + [] => AssignTargetExpression::Name(Box::new(Name { + value: "_", + lpar: vec![], + rpar: vec![], + })), + // Ex) `lambda x: y` + [param] => AssignTargetExpression::Name(Box::new(param.name.clone())), + // Ex) `lambda x, y: z` + params => AssignTargetExpression::Tuple(Box::new(Tuple { + elements: params + .iter() + .map(|param| Element::Simple { + value: Expression::Name(Box::new(param.name.clone())), + comma: None, + }) + .collect(), + lpar: vec![], + rpar: vec![], + })), + }; - if args.len() == 2 { - if func_body.params.params.iter().any(|f| f.default.is_some()) { - bail!("Currently not supporting default values"); + // Parenthesize the iterator, if necessary, as in: + // ```python + // map(lambda x: x, y if y else z) + // ``` + let iter = iter.clone(); + let iter = if iter.lpar().is_empty() + && iter.rpar().is_empty() + && matches!(iter, Expression::IfExp(_) | Expression::Lambda(_)) + { + iter.with_parens(LeftParen::default(), RightParen::default()) + } else { + iter + }; + + let compfor = Box::new(CompFor { + target, + iter, + ifs: vec![], + inner_for_in: None, + asynchronous: None, + whitespace_before: space(), + whitespace_after_for: space(), + whitespace_before_in: space(), + whitespace_after_in: space(), + }); + + match object_type { + ObjectType::Generator => { + tree = Expression::GeneratorExp(Box::new(GeneratorExp { + elt: lambda.body.clone(), + for_in: compfor, + lpar: vec![LeftParen::default()], + rpar: vec![RightParen::default()], + })); } - - let mut args_str = func_body - .params - .params - .iter() - .map(|f| f.name.value) - .join(", "); - if args_str.is_empty() { - args_str = "_".to_string(); - } - - let compfor = Box::new(CompFor { - target: AssignTargetExpression::Name(Box::new(Name { - value: args_str.as_str(), + ObjectType::List => { + tree = Expression::ListComp(Box::new(ListComp { + elt: lambda.body.clone(), + for_in: compfor, + lbracket: LeftSquareBracket::default(), + rbracket: RightSquareBracket::default(), lpar: vec![], rpar: vec![], - })), - iter: args.last().unwrap().value.clone(), - ifs: vec![], - inner_for_in: None, - asynchronous: None, - whitespace_before: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), - whitespace_after_for: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace( - " ", - )), - whitespace_before_in: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace( - " ", - )), - whitespace_after_in: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), - }); - - match object_type { - ObjectType::Generator => { - tree = Expression::GeneratorExp(Box::new(GeneratorExp { - elt: func_body.body.clone(), - for_in: compfor, - lpar: vec![LeftParen::default()], - rpar: vec![RightParen::default()], - })); - } - ObjectType::List => { - tree = Expression::ListComp(Box::new(ListComp { - elt: func_body.body.clone(), - for_in: compfor, - lbracket: LeftSquareBracket::default(), - rbracket: RightSquareBracket::default(), - lpar: vec![], - rpar: vec![], - })); - } - ObjectType::Set => { - tree = Expression::SetComp(Box::new(SetComp { - elt: func_body.body.clone(), - for_in: compfor, - lpar: vec![], - rpar: vec![], - lbrace: LeftCurlyBrace::default(), - rbrace: RightCurlyBrace::default(), - })); - } - ObjectType::Dict => { - let (key, value) = if let Expression::Tuple(tuple) = func_body.body.as_ref() { - if tuple.elements.len() != 2 { - bail!("Expected two elements") - } - - let Some(Element::Simple { value: key, .. }) = &tuple.elements.get(0) else { - bail!("Expected tuple to contain a key as the first element"); - }; - let Some(Element::Simple { value, .. }) = &tuple.elements.get(1) else { - bail!("Expected tuple to contain a key as the second element"); - }; - - (key, value) - } else { - bail!("Expected tuple for dict comprehension") - }; - - tree = Expression::DictComp(Box::new(DictComp { - for_in: compfor, - lpar: vec![], - rpar: vec![], - key: Box::new(key.clone()), - value: Box::new(value.clone()), - lbrace: LeftCurlyBrace::default(), - rbrace: RightCurlyBrace::default(), - whitespace_before_colon: ParenthesizableWhitespace::default(), - whitespace_after_colon: ParenthesizableWhitespace::SimpleWhitespace( - SimpleWhitespace(" "), - ), - })); - } + })); } - - let mut content = tree.codegen_stylist(stylist); - - // If the expression is embedded in an f-string, surround it with spaces to avoid - // syntax errors. - if matches!(object_type, ObjectType::Set | ObjectType::Dict) { - if parent.is_some_and(Expr::is_formatted_value_expr) { - content = format!(" {content} "); - } + ObjectType::Set => { + tree = Expression::SetComp(Box::new(SetComp { + elt: lambda.body.clone(), + for_in: compfor, + lpar: vec![], + rpar: vec![], + lbrace: LeftCurlyBrace::default(), + rbrace: RightCurlyBrace::default(), + })); } + ObjectType::Dict => { + let elements = match lambda.body.as_ref() { + Expression::Tuple(tuple) => &tuple.elements, + Expression::List(list) => &list.elements, + _ => { + bail!("Expected tuple or list for dictionary comprehension") + } + }; + let [key, value] = elements.as_slice() else { + bail!("Expected container to include two elements"); + }; + let Element::Simple { value: key, .. } = key else { + bail!("Expected container to use a key as the first element"); + }; + let Element::Simple { value, .. } = value else { + bail!("Expected container to use a value as the second element"); + }; - Ok(Edit::range_replacement(content, expr.range())) - } else { - bail!("Should have two arguments"); + tree = Expression::DictComp(Box::new(DictComp { + for_in: compfor, + lpar: vec![], + rpar: vec![], + key: Box::new(key.clone()), + value: Box::new(value.clone()), + lbrace: LeftCurlyBrace::default(), + rbrace: RightCurlyBrace::default(), + whitespace_before_colon: ParenthesizableWhitespace::default(), + whitespace_after_colon: ParenthesizableWhitespace::SimpleWhitespace( + SimpleWhitespace(" "), + ), + })); + } } + + let mut content = tree.codegen_stylist(stylist); + + // If the expression is embedded in an f-string, surround it with spaces to avoid + // syntax errors. + if matches!(object_type, ObjectType::Set | ObjectType::Dict) { + if parent.is_some_and(Expr::is_formatted_value_expr) { + content = format!(" {content} "); + } + } + + Ok(Edit::range_replacement(content, expr.range())) } /// (C418) Convert `dict({"a": 1})` to `{"a": 1}` pub(crate) fn fix_unnecessary_literal_within_dict_call( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { let module_text = locator.slice(expr); let mut tree = match_expression(module_text)?; @@ -1036,9 +1127,9 @@ pub(crate) fn fix_unnecessary_literal_within_dict_call( /// (C419) Convert `[i for i in a]` into `i for i in a` pub(crate) fn fix_unnecessary_comprehension_any_all( + expr: &Expr, locator: &Locator, stylist: &Stylist, - expr: &Expr, ) -> Result { // Expr(ListComp) -> Expr(GeneratorExp) let module_text = locator.slice(expr); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs index d85048b553..bc233cc665 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs @@ -85,9 +85,9 @@ pub(crate) fn unnecessary_call_around_sorted( if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { let edit = fixes::fix_unnecessary_call_around_sorted( + expr, checker.locator(), checker.stylist(), - expr, )?; if outer.id == "reversed" { Ok(Fix::suggested(edit)) diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs index 8f8ec3fc26..01e6e0b383 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs @@ -88,7 +88,7 @@ pub(crate) fn unnecessary_collection_call( ); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_collection_call(checker, expr).map(Fix::suggested) + fixes::fix_unnecessary_collection_call(expr, checker).map(Fix::suggested) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs index 307225f7bc..d9095cda49 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs @@ -65,7 +65,7 @@ fn add_diagnostic(checker: &mut Checker, expr: &Expr) { ); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_comprehension(checker.locator(), checker.stylist(), expr) + fixes::fix_unnecessary_comprehension(expr, checker.locator(), checker.stylist()) .map(Fix::suggested) }); } diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs index a1eb9eef17..d50a5de057 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs @@ -91,7 +91,7 @@ pub(crate) fn unnecessary_comprehension_any_all( let mut diagnostic = Diagnostic::new(UnnecessaryComprehensionAnyAll, arg.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_comprehension_any_all(checker.locator(), checker.stylist(), expr) + fixes::fix_unnecessary_comprehension_any_all(expr, checker.locator(), checker.stylist()) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs index 7c682f7126..bb4922afd4 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs @@ -133,9 +133,9 @@ pub(crate) fn unnecessary_double_cast_or_process( if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { fixes::fix_unnecessary_double_cast_or_process( + expr, checker.locator(), checker.stylist(), - expr, ) .map(Fix::suggested) }); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs index 955ddb9e8e..b03d5880e8 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs @@ -60,7 +60,7 @@ pub(crate) fn unnecessary_generator_dict( let mut diagnostic = Diagnostic::new(UnnecessaryGeneratorDict, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_generator_dict(checker, expr).map(Fix::suggested) + fixes::fix_unnecessary_generator_dict(expr, checker).map(Fix::suggested) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs index bdb5e0da2d..8c8b43591e 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs @@ -62,7 +62,7 @@ pub(crate) fn unnecessary_generator_list( let mut diagnostic = Diagnostic::new(UnnecessaryGeneratorList, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_generator_list(checker.locator(), checker.stylist(), expr) + fixes::fix_unnecessary_generator_list(expr, checker.locator(), checker.stylist()) .map(Fix::suggested) }); } diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs index 352f39d81a..d4fd13c33e 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs @@ -62,7 +62,7 @@ pub(crate) fn unnecessary_generator_set( let mut diagnostic = Diagnostic::new(UnnecessaryGeneratorSet, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_generator_set(checker, expr).map(Fix::suggested) + fixes::fix_unnecessary_generator_set(expr, checker).map(Fix::suggested) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs index a8690718ed..1f4cf31a83 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs @@ -58,7 +58,7 @@ pub(crate) fn unnecessary_list_call( let mut diagnostic = Diagnostic::new(UnnecessaryListCall, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_list_call(checker.locator(), checker.stylist(), expr) + fixes::fix_unnecessary_list_call(expr, checker.locator(), checker.stylist()) .map(Fix::suggested) }); } diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs index 13b78e3af1..e92d5b6663 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs @@ -67,7 +67,7 @@ pub(crate) fn unnecessary_list_comprehension_dict( let mut diagnostic = Diagnostic::new(UnnecessaryListComprehensionDict, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_list_comprehension_dict(checker, expr).map(Fix::suggested) + fixes::fix_unnecessary_list_comprehension_dict(expr, checker).map(Fix::suggested) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs index f363014739..34e775fc39 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs @@ -60,7 +60,7 @@ pub(crate) fn unnecessary_list_comprehension_set( let mut diagnostic = Diagnostic::new(UnnecessaryListComprehensionSet, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { - fixes::fix_unnecessary_list_comprehension_set(checker, expr).map(Fix::suggested) + fixes::fix_unnecessary_list_comprehension_set(expr, checker).map(Fix::suggested) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs index c498d1c082..36403f70c6 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs @@ -82,7 +82,7 @@ pub(crate) fn unnecessary_literal_dict( ); if checker.patch(diagnostic.kind.rule()) { diagnostic - .try_set_fix(|| fixes::fix_unnecessary_literal_dict(checker, expr).map(Fix::suggested)); + .try_set_fix(|| fixes::fix_unnecessary_literal_dict(expr, checker).map(Fix::suggested)); } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs index 35524e7db7..2d22f0b804 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs @@ -77,7 +77,7 @@ pub(crate) fn unnecessary_literal_set( ); if checker.patch(diagnostic.kind.rule()) { diagnostic - .try_set_fix(|| fixes::fix_unnecessary_literal_set(checker, expr).map(Fix::suggested)); + .try_set_fix(|| fixes::fix_unnecessary_literal_set(expr, checker).map(Fix::suggested)); } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs index 52c7db6a2d..5ee01a7527 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs @@ -94,9 +94,9 @@ pub(crate) fn unnecessary_literal_within_dict_call( if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { fixes::fix_unnecessary_literal_within_dict_call( + expr, checker.locator(), checker.stylist(), - expr, ) .map(Fix::suggested) }); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs index f76023080d..f6810ad446 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs @@ -96,9 +96,9 @@ pub(crate) fn unnecessary_literal_within_list_call( if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { fixes::fix_unnecessary_literal_within_list_call( + expr, checker.locator(), checker.stylist(), - expr, ) .map(Fix::suggested) }); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs index a15d44559f..83ae8d1410 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs @@ -98,9 +98,9 @@ pub(crate) fn unnecessary_literal_within_tuple_call( if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { fixes::fix_unnecessary_literal_within_tuple_call( + expr, checker.locator(), checker.stylist(), - expr, ) .map(Fix::suggested) }); diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs index ae00f12d8b..2dd0fa0025 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs @@ -224,11 +224,11 @@ pub(crate) fn unnecessary_map( if checker.patch(diagnostic.kind.rule()) { diagnostic.try_set_fix(|| { fixes::fix_unnecessary_map( - checker.locator(), - checker.stylist(), expr, parent, object_type, + checker.locator(), + checker.stylist(), ) .map(Fix::suggested) }); diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap index a0733820e6..8fe86d0663 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap +++ b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap @@ -231,6 +231,8 @@ C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension 17 | 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 +19 | +20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 | = help: Rewrite as a `dict` comprehension @@ -240,5 +242,23 @@ C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension 17 17 | 18 |-print(f'Hello {dict((x,f(x)) for x in "abc")} World') 18 |+print(f'Hello { {x: f(x) for x in "abc"} } World') +19 19 | +20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 +21 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) + +C402.py:21:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | +20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 +21 | dict((k,v)for k,v in d.iteritems() if k in only_args) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +18 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') +19 19 | +20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 +21 |-dict((k,v)for k,v in d.iteritems() if k in only_args) + 21 |+{k: v for k,v in d.iteritems() if k in only_args} diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap index 07c6d005b4..8e4eb5a2ed 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap +++ b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap @@ -115,6 +115,8 @@ C404.py:12:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com 12 |-f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 12 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"])}' 13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | @@ -133,12 +135,16 @@ C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co 12 |-f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 12 |+f'{dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' 13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 +14 | +15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 | = help: Rewrite as a `dict` comprehension @@ -148,12 +154,17 @@ C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` com 12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 |-f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' 13 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 +14 | +15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 | = help: Rewrite as a `dict` comprehension @@ -163,5 +174,23 @@ C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` co 12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 |-f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' 13 |+f'{ dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + +C404.py:16:14: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 |-saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + 16 |+saved.append({k: v for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]}) diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap index 734d403452..043c3f1432 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap +++ b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap @@ -123,7 +123,7 @@ C413.py:8:1: C413 [*] Unnecessary `reversed` call around `sorted()` 8 |+sorted(x, reverse=False, key=lambda e: e) 9 9 | reversed(sorted(x, reverse=False)) 10 10 | -11 11 | def reversed(*args, **kwargs): +11 11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` | @@ -132,7 +132,7 @@ C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` 9 | reversed(sorted(x, reverse=False)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 10 | -11 | def reversed(*args, **kwargs): +11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 | = help: Remove unnecessary `reversed` call @@ -143,7 +143,45 @@ C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` 9 |-reversed(sorted(x, reverse=False)) 9 |+sorted(x, reverse=True) 10 10 | -11 11 | def reversed(*args, **kwargs): -12 12 | return None +11 11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +12 12 | reversed(sorted(i for i in range(42))) + +C413.py:12:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +12 | reversed(sorted(i for i in range(42))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +13 | reversed(sorted((i for i in range(42)), reverse=True)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +9 9 | reversed(sorted(x, reverse=False)) +10 10 | +11 11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +12 |-reversed(sorted(i for i in range(42))) + 12 |+sorted((i for i in range(42)), reverse=True) +13 13 | reversed(sorted((i for i in range(42)), reverse=True)) +14 14 | +15 15 | + +C413.py:13:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +12 | reversed(sorted(i for i in range(42))) +13 | reversed(sorted((i for i in range(42)), reverse=True)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +10 10 | +11 11 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +12 12 | reversed(sorted(i for i in range(42))) +13 |-reversed(sorted((i for i in range(42)), reverse=True)) + 13 |+sorted((i for i in range(42)), reverse=False) +14 14 | +15 15 | +16 16 | def reversed(*args, **kwargs): diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap index 253dc8744a..7268cef9f7 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap +++ b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap @@ -83,4 +83,19 @@ C416.py:9:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) 11 11 | [i for i, in z] 12 12 | [i for i, j in y] +C416.py:22:70: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) + | +21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 +22 | any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) + | ^^^^^^^^^^^^^^^^^^^^^^^ C416 + | + = help: Rewrite using `list()` + +ℹ Suggested fix +19 19 | {k: v if v else None for k, v in y} +20 20 | +21 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 +22 |-any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) + 22 |+any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in list(SymbolType)) + diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap index c04bcb03b9..ef82a61589 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap +++ b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap @@ -61,7 +61,7 @@ C417.py:5:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehens 5 |+[x * 2 for x in nums] 6 6 | set(map(lambda x: x % 2 == 0, nums)) 7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | map(lambda: "const", nums) +8 8 | dict(map(lambda v: [v, v**2], nums)) C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) | @@ -70,7 +70,7 @@ C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehensi 6 | set(map(lambda x: x % 2 == 0, nums)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 7 | dict(map(lambda v: (v, v**2), nums)) -8 | map(lambda: "const", nums) +8 | dict(map(lambda v: [v, v**2], nums)) | = help: Replace `map` with a `set` comprehension @@ -81,8 +81,8 @@ C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehensi 6 |-set(map(lambda x: x % 2 == 0, nums)) 6 |+{x % 2 == 0 for x in nums} 7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | map(lambda: "const", nums) -9 9 | map(lambda _: 3.0, nums) +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) | @@ -90,8 +90,8 @@ C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehens 6 | set(map(lambda x: x % 2 == 0, nums)) 7 | dict(map(lambda v: (v, v**2), nums)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -8 | map(lambda: "const", nums) -9 | map(lambda _: 3.0, nums) +8 | dict(map(lambda v: [v, v**2], nums)) +9 | map(lambda: "const", nums) | = help: Replace `map` with a `dict` comprehension @@ -101,172 +101,267 @@ C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehens 6 6 | set(map(lambda x: x % 2 == 0, nums)) 7 |-dict(map(lambda v: (v, v**2), nums)) 7 |+{v: v**2 for v in nums} -8 8 | map(lambda: "const", nums) -9 9 | map(lambda _: 3.0, nums) -10 10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) -C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) +C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) | 6 | set(map(lambda x: x % 2 == 0, nums)) 7 | dict(map(lambda v: (v, v**2), nums)) - 8 | map(lambda: "const", nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 - 9 | map(lambda _: 3.0, nums) -10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + 8 | dict(map(lambda v: [v, v**2], nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + 9 | map(lambda: "const", nums) +10 | map(lambda _: 3.0, nums) | - = help: Replace `map` with a generator expression + = help: Replace `map` with a `dict` comprehension ℹ Suggested fix 5 5 | list(map(lambda x: x * 2, nums)) 6 6 | set(map(lambda x: x % 2 == 0, nums)) 7 7 | dict(map(lambda v: (v, v**2), nums)) -8 |-map(lambda: "const", nums) - 8 |+("const" for _ in nums) -9 9 | map(lambda _: 3.0, nums) -10 10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 11 | all(map(lambda v: isinstance(v, dict), nums)) +8 |-dict(map(lambda v: [v, v**2], nums)) + 8 |+{v: v**2 for v in nums} +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) C417.py:9:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | 7 | dict(map(lambda v: (v, v**2), nums)) - 8 | map(lambda: "const", nums) - 9 | map(lambda _: 3.0, nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^ C417 -10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 | all(map(lambda v: isinstance(v, dict), nums)) + 8 | dict(map(lambda v: [v, v**2], nums)) + 9 | map(lambda: "const", nums) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +10 | map(lambda _: 3.0, nums) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) | = help: Replace `map` with a generator expression ℹ Suggested fix 6 6 | set(map(lambda x: x % 2 == 0, nums)) 7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | map(lambda: "const", nums) -9 |-map(lambda _: 3.0, nums) - 9 |+(3.0 for _ in nums) -10 10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 11 | all(map(lambda v: isinstance(v, dict), nums)) -12 12 | filter(func, map(lambda v: v, nums)) +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 |-map(lambda: "const", nums) + 9 |+("const" for _ in nums) +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) -C417.py:10:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) +C417.py:10:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | - 8 | map(lambda: "const", nums) - 9 | map(lambda _: 3.0, nums) -10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -11 | all(map(lambda v: isinstance(v, dict), nums)) -12 | filter(func, map(lambda v: v, nums)) + 8 | dict(map(lambda v: [v, v**2], nums)) + 9 | map(lambda: "const", nums) +10 | map(lambda _: 3.0, nums) + | ^^^^^^^^^^^^^^^^^^^^^^^^ C417 +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 | all(map(lambda v: isinstance(v, dict), nums)) | = help: Replace `map` with a generator expression ℹ Suggested fix 7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | map(lambda: "const", nums) -9 9 | map(lambda _: 3.0, nums) -10 |-_ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - 10 |+_ = "".join((x in nums and "1" or "0" for x in range(123))) -11 11 | all(map(lambda v: isinstance(v, dict), nums)) -12 12 | filter(func, map(lambda v: v, nums)) -13 13 | +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) +10 |-map(lambda _: 3.0, nums) + 10 |+(3.0 for _ in nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 13 | filter(func, map(lambda v: v, nums)) -C417.py:11:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) +C417.py:11:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | - 9 | map(lambda _: 3.0, nums) -10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 | all(map(lambda v: isinstance(v, dict), nums)) + 9 | map(lambda: "const", nums) +10 | map(lambda _: 3.0, nums) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +12 | all(map(lambda v: isinstance(v, dict), nums)) +13 | filter(func, map(lambda v: v, nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) +11 |-_ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + 11 |+_ = "".join((x in nums and "1" or "0" for x in range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 13 | filter(func, map(lambda v: v, nums)) +14 14 | list(map(lambda x, y: x * y, nums)) + +C417.py:12:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +10 | map(lambda _: 3.0, nums) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 | all(map(lambda v: isinstance(v, dict), nums)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -12 | filter(func, map(lambda v: v, nums)) +13 | filter(func, map(lambda v: v, nums)) +14 | list(map(lambda x, y: x * y, nums)) | = help: Replace `map` with a generator expression ℹ Suggested fix -8 8 | map(lambda: "const", nums) -9 9 | map(lambda _: 3.0, nums) -10 10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 |-all(map(lambda v: isinstance(v, dict), nums)) - 11 |+all((isinstance(v, dict) for v in nums)) -12 12 | filter(func, map(lambda v: v, nums)) -13 13 | -14 14 | # When inside f-string, then the fix should be surrounded by whitespace +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 |-all(map(lambda v: isinstance(v, dict), nums)) + 12 |+all((isinstance(v, dict) for v in nums)) +13 13 | filter(func, map(lambda v: v, nums)) +14 14 | list(map(lambda x, y: x * y, nums)) +15 15 | -C417.py:12:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) +C417.py:13:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | -10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 | all(map(lambda v: isinstance(v, dict), nums)) -12 | filter(func, map(lambda v: v, nums)) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 | all(map(lambda v: isinstance(v, dict), nums)) +13 | filter(func, map(lambda v: v, nums)) | ^^^^^^^^^^^^^^^^^^^^^^ C417 -13 | -14 | # When inside f-string, then the fix should be surrounded by whitespace +14 | list(map(lambda x, y: x * y, nums)) | = help: Replace `map` with a generator expression ℹ Suggested fix -9 9 | map(lambda _: 3.0, nums) -10 10 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -11 11 | all(map(lambda v: isinstance(v, dict), nums)) -12 |-filter(func, map(lambda v: v, nums)) - 12 |+filter(func, (v for v in nums)) -13 13 | -14 14 | # When inside f-string, then the fix should be surrounded by whitespace -15 15 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 |-filter(func, map(lambda v: v, nums)) + 13 |+filter(func, (v for v in nums)) +14 14 | list(map(lambda x, y: x * y, nums)) +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace -C417.py:15:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) +C417.py:14:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) | -14 | # When inside f-string, then the fix should be surrounded by whitespace -15 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" +12 | all(map(lambda v: isinstance(v, dict), nums)) +13 | filter(func, map(lambda v: v, nums)) +14 | list(map(lambda x, y: x * y, nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +15 | +16 | # When inside f-string, then the fix should be surrounded by whitespace + | + = help: Replace `map` with a `list` comprehension + +ℹ Suggested fix +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 13 | filter(func, map(lambda v: v, nums)) +14 |-list(map(lambda x, y: x * y, nums)) + 14 |+[x * y for x, y in nums] +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace +17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" + +C417.py:17:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) + | +16 | # When inside f-string, then the fix should be surrounded by whitespace +17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -16 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" +18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" | = help: Replace `map` with a `set` comprehension ℹ Suggested fix -12 12 | filter(func, map(lambda v: v, nums)) -13 13 | -14 14 | # When inside f-string, then the fix should be surrounded by whitespace -15 |-_ = f"{set(map(lambda x: x % 2 == 0, nums))}" - 15 |+_ = f"{ {x % 2 == 0 for x in nums} }" -16 16 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" -17 17 | -18 18 | # False negatives. +14 14 | list(map(lambda x, y: x * y, nums)) +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace +17 |-_ = f"{set(map(lambda x: x % 2 == 0, nums))}" + 17 |+_ = f"{ {x % 2 == 0 for x in nums} }" +18 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" +19 19 | +20 20 | # False negatives. -C417.py:16:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) +C417.py:18:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) | -14 | # When inside f-string, then the fix should be surrounded by whitespace -15 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" -16 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" +16 | # When inside f-string, then the fix should be surrounded by whitespace +17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" +18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -17 | -18 | # False negatives. +19 | +20 | # False negatives. | = help: Replace `map` with a `dict` comprehension ℹ Suggested fix -13 13 | -14 14 | # When inside f-string, then the fix should be surrounded by whitespace -15 15 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" -16 |-_ = f"{dict(map(lambda v: (v, v**2), nums))}" - 16 |+_ = f"{ {v: v**2 for v in nums} }" -17 17 | -18 18 | # False negatives. -19 19 | map(lambda x=2, y=1: x + y, nums, nums) +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace +17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" +18 |-_ = f"{dict(map(lambda v: (v, v**2), nums))}" + 18 |+_ = f"{ {v: v**2 for v in nums} }" +19 19 | +20 20 | # False negatives. +21 21 | map(lambda x=2, y=1: x + y, nums, nums) -C417.py:34:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) +C417.py:36:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) | -33 | # Error: the `x` is overridden by the inner lambda. -34 | map(lambda x: lambda x: x, range(4)) +35 | # Error: the `x` is overridden by the inner lambda. +36 | map(lambda x: lambda x: x, range(4)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -35 | -36 | # Ok because of the default parameters, and variadic arguments. +37 | +38 | # Ok because of the default parameters, and variadic arguments. | = help: Replace `map` with a generator expression ℹ Suggested fix -31 31 | map(lambda x: lambda: x, range(4)) -32 32 | -33 33 | # Error: the `x` is overridden by the inner lambda. -34 |-map(lambda x: lambda x: x, range(4)) - 34 |+(lambda x: x for x in range(4)) -35 35 | -36 36 | # Ok because of the default parameters, and variadic arguments. -37 37 | map(lambda x=1: x, nums) +33 33 | map(lambda x: lambda: x, range(4)) +34 34 | +35 35 | # Error: the `x` is overridden by the inner lambda. +36 |-map(lambda x: lambda x: x, range(4)) + 36 |+(lambda x: x for x in range(4)) +37 37 | +38 38 | # Ok because of the default parameters, and variadic arguments. +39 39 | map(lambda x=1: x, nums) + +C417.py:47:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 | map(lambda x: x, y if y else z) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +48 | map(lambda x: x, (y if y else z)) +49 | map(lambda x: x, (x, y, z)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +44 44 | dict(map(lambda k, v: (k, v), keys, values)) +45 45 | +46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 |-map(lambda x: x, y if y else z) + 47 |+(x for x in (y if y else z)) +48 48 | map(lambda x: x, (y if y else z)) +49 49 | map(lambda x: x, (x, y, z)) + +C417.py:48:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 | map(lambda x: x, y if y else z) +48 | map(lambda x: x, (y if y else z)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +49 | map(lambda x: x, (x, y, z)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +45 45 | +46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 47 | map(lambda x: x, y if y else z) +48 |-map(lambda x: x, (y if y else z)) + 48 |+(x for x in (y if y else z)) +49 49 | map(lambda x: x, (x, y, z)) + +C417.py:49:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +47 | map(lambda x: x, y if y else z) +48 | map(lambda x: x, (y if y else z)) +49 | map(lambda x: x, (x, y, z)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 47 | map(lambda x: x, y if y else z) +48 48 | map(lambda x: x, (y if y else z)) +49 |-map(lambda x: x, (x, y, z)) + 49 |+(x for x in (x, y, z)) diff --git a/crates/ruff/src/rules/flake8_copyright/mod.rs b/crates/ruff/src/rules/flake8_copyright/mod.rs index 6e2a39c4cb..0d86c51cee 100644 --- a/crates/ruff/src/rules/flake8_copyright/mod.rs +++ b/crates/ruff/src/rules/flake8_copyright/mod.rs @@ -149,6 +149,17 @@ import os # Content Content Content Content Content Content Content Content Content Content # Copyright 2023 +"# + .trim(), + &settings::Settings::for_rules(vec![Rule::MissingCopyrightNotice]), + ); + assert_messages!(diagnostics); + } + + #[test] + fn char_boundary() { + let diagnostics = test_snippet( + r#"কককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককক "# .trim(), &settings::Settings::for_rules(vec![Rule::MissingCopyrightNotice]), diff --git a/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs b/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs index 3c99bb487f..6558580833 100644 --- a/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs +++ b/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs @@ -1,8 +1,7 @@ -use ruff_text_size::{TextRange, TextSize}; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_source_file::Locator; +use ruff_text_size::{TextRange, TextSize}; use crate::settings::Settings; @@ -33,11 +32,7 @@ pub(crate) fn missing_copyright_notice( } // Only search the first 1024 bytes in the file. - let contents = if locator.len() < 1024 { - locator.contents() - } else { - locator.up_to(TextSize::from(1024)) - }; + let contents = locator.up_to(locator.floor_char_boundary(TextSize::new(1024))); // Locate the copyright notice. if let Some(match_) = settings.flake8_copyright.notice_rgx.find(contents) { diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__char_boundary.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__char_boundary.snap new file mode 100644 index 0000000000..914f3528d0 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__char_boundary.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- +:1:1: CPY001 Missing copyright notice at top of file + | +1 | কককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককক + | CPY001 + | + + diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs index bde872c4da..f758fb0042 100644 --- a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs +++ b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs @@ -77,7 +77,6 @@ pub(crate) fn call_datetime_strptime_without_zone(checker: &mut Checker, call: & // Does the `strptime` call contain a format string with a timezone specifier? if let Some(Expr::Constant(ast::ExprConstant { value: Constant::Str(format), - kind: None, range: _, })) = call.arguments.args.get(1).as_ref() { diff --git a/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs b/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs index c251de8c90..c36c4f5a51 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs @@ -10,6 +10,24 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_text_size::Ranged; +/// ## What it does +/// Checks for duplicate union members. +/// +/// ## Why is this bad? +/// Duplicate union members are redundant and should be removed. +/// +/// ## Example +/// ```python +/// foo: str | str +/// ``` +/// +/// Use instead: +/// ```python +/// foo: str +/// ``` +/// +/// ## References +/// - [Python documentation: `typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union) #[violation] pub struct DuplicateUnionMember { duplicate_name: String, diff --git a/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs b/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs index 9ac914d2f9..2432df8faf 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs @@ -1,7 +1,7 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Stmt}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::helpers::is_docstring_stmt; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_text_size::Ranged; use crate::checkers::ast::Checker; @@ -23,18 +23,35 @@ impl AlwaysAutofixableViolation for NonEmptyStubBody { /// PYI010 pub(crate) fn non_empty_stub_body(checker: &mut Checker, body: &[Stmt]) { - if let [Stmt::Expr(ast::StmtExpr { value, range: _ })] = body { + // Ignore multi-statement bodies (covered by PYI048). + let [stmt] = body else { + return; + }; + + // Ignore `pass` statements (covered by PYI009). + if stmt.is_pass_stmt() { + return; + } + + // Ignore docstrings (covered by PYI021). + if is_docstring_stmt(stmt) { + return; + } + + // Ignore `...` (the desired case). + if let Stmt::Expr(ast::StmtExpr { value, range: _ }) = stmt { if let Expr::Constant(ast::ExprConstant { value, .. }) = value.as_ref() { - if matches!(value, Constant::Ellipsis | Constant::Str(_)) { + if value.is_ellipsis() { return; } } } - let mut diagnostic = Diagnostic::new(NonEmptyStubBody, body[0].range()); + + let mut diagnostic = Diagnostic::new(NonEmptyStubBody, stmt.range()); if checker.patch(Rule::NonEmptyStubBody) { - diagnostic.set_fix(Fix::automatic(Edit::range_replacement( + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( format!("..."), - body[0].range(), + stmt.range(), ))); }; checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs b/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs index e85433a9c5..e51b289808 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs @@ -22,17 +22,16 @@ impl AlwaysAutofixableViolation for PassStatementStubBody { /// PYI009 pub(crate) fn pass_statement_stub_body(checker: &mut Checker, body: &[Stmt]) { - let [stmt] = body else { + let [Stmt::Pass(pass)] = body else { return; }; - if stmt.is_pass_stmt() { - let mut diagnostic = Diagnostic::new(PassStatementStubBody, stmt.range()); - if checker.patch(Rule::PassStatementStubBody) { - diagnostic.set_fix(Fix::automatic(Edit::range_replacement( - format!("..."), - stmt.range(), - ))); - }; - checker.diagnostics.push(diagnostic); - } + + let mut diagnostic = Diagnostic::new(PassStatementStubBody, pass.range()); + if checker.patch(Rule::PassStatementStubBody) { + diagnostic.set_fix(Fix::automatic(Edit::range_replacement( + format!("..."), + pass.range(), + ))); + }; + checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs b/crates/ruff/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs index 6390441bad..77c20d5e94 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs @@ -1,9 +1,7 @@ -use ruff_python_ast::Stmt; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::helpers::is_docstring_stmt; use ruff_python_ast::identifier::Identifier; +use ruff_python_ast::Stmt; use crate::checkers::ast::Checker; @@ -17,21 +15,12 @@ impl Violation for StubBodyMultipleStatements { } } -/// PYI010 +/// PYI048 pub(crate) fn stub_body_multiple_statements(checker: &mut Checker, stmt: &Stmt, body: &[Stmt]) { - // If the function body consists of exactly one statement, abort. - if body.len() == 1 { - return; + if body.len() > 1 { + checker.diagnostics.push(Diagnostic::new( + StubBodyMultipleStatements, + stmt.identifier(), + )); } - - // If the function body consists of exactly two statements, and the first is a - // docstring, abort (this is covered by PYI021). - if body.len() == 2 && is_docstring_stmt(&body[0]) { - return; - } - - checker.diagnostics.push(Diagnostic::new( - StubBodyMultipleStatements, - stmt.identifier(), - )); } diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap index ad0bb4775f..1e757d8872 100644 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap +++ b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap @@ -11,8 +11,8 @@ PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` | = help: Replace function body with `...` -ℹ Fix -3 3 | """foo""" # OK, strings are handled by another rule +ℹ Suggested fix +3 3 | """foo""" # OK, docstrings are handled by another rule 4 4 | 5 5 | def buzz(): 6 |- print("buzz") # ERROR PYI010 @@ -31,7 +31,7 @@ PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` | = help: Replace function body with `...` -ℹ Fix +ℹ Suggested fix 6 6 | print("buzz") # ERROR PYI010 7 7 | 8 8 | def foo2(): @@ -46,14 +46,19 @@ PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` 11 | def bizz(): 12 | x = 123 # ERROR PYI010 | ^^^^^^^ PYI010 +13 | +14 | def foo3(): | = help: Replace function body with `...` -ℹ Fix +ℹ Suggested fix 9 9 | 123 # ERROR PYI010 10 10 | 11 11 | def bizz(): 12 |- x = 123 # ERROR PYI010 12 |+ ... # ERROR PYI010 +13 13 | +14 14 | def foo3(): +15 15 | pass # OK, pass is handled by another rule diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap index 725d9b7b4d..d897255d5d 100644 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap +++ b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap @@ -1,17 +1,31 @@ --- source: crates/ruff/src/rules/flake8_pyi/mod.rs --- -PYI048.pyi:11:5: PYI048 Function body must contain exactly one statement +PYI048.pyi:8:5: PYI048 Function body must contain exactly one statement | -11 | def foo(): # ERROR PYI048 + 6 | """oof""" # OK + 7 | + 8 | def oof(): # ERROR PYI048 | ^^^ PYI048 -12 | """foo""" -13 | print("foo") + 9 | """oof""" +10 | print("foo") + | + +PYI048.pyi:12:5: PYI048 Function body must contain exactly one statement + | +10 | print("foo") +11 | +12 | def foo(): # ERROR PYI048 + | ^^^ PYI048 +13 | """foo""" +14 | print("foo") | PYI048.pyi:17:5: PYI048 Function body must contain exactly one statement | -17 | def buzz(): # ERROR PYI048 +15 | print("foo") +16 | +17 | def buzz(): # ERROR PYI048 | ^^^^ PYI048 18 | print("fizz") 19 | print("buzz") diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs index 816348f187..abdcf85985 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs @@ -3,9 +3,8 @@ use std::borrow::Cow; use anyhow::Result; use anyhow::{bail, Context}; use libcst_native::{ - self, Assert, BooleanOp, CompoundStatement, Expression, ParenthesizableWhitespace, - ParenthesizedNode, SimpleStatementLine, SimpleWhitespace, SmallStatement, Statement, - TrailingWhitespace, UnaryOperation, + self, Assert, BooleanOp, CompoundStatement, Expression, ParenthesizedNode, SimpleStatementLine, + SimpleWhitespace, SmallStatement, Statement, TrailingWhitespace, UnaryOperation, }; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; @@ -22,6 +21,7 @@ use ruff_text_size::Ranged; use crate::autofix::codemods::CodegenStylist; use crate::checkers::ast::Checker; +use crate::cst::helpers::space; use crate::cst::matchers::match_indented_block; use crate::cst::matchers::match_module; use crate::importer::ImportRequest; @@ -576,7 +576,7 @@ fn negate<'a>(expression: &Expression<'a>) -> Expression<'a> { } Expression::UnaryOperation(Box::new(UnaryOperation { operator: libcst_native::UnaryOp::Not { - whitespace_after: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), + whitespace_after: space(), }, expression: Box::new(expression.clone()), lpar: vec![], @@ -598,7 +598,7 @@ fn negate<'a>(expression: &Expression<'a>) -> Expression<'a> { /// assert (b == /// "") /// ``` -fn parenthesize<'a>(expression: Expression<'a>, parent: &Expression<'a>) -> Expression<'a> { +fn parenthesize<'a>(expression: &Expression<'a>, parent: &Expression<'a>) -> Expression<'a> { if matches!( expression, Expression::Comparison(_) @@ -626,10 +626,10 @@ fn parenthesize<'a>(expression: Expression<'a>, parent: &Expression<'a>) -> Expr | Expression::NamedExpr(_) ) { if let (Some(left), Some(right)) = (parent.lpar().first(), parent.rpar().first()) { - return expression.with_parens(left.clone(), right.clone()); + return expression.clone().with_parens(left.clone(), right.clone()); } } - expression + expression.clone() } /// Replace composite condition `assert a == "hello" and b == "world"` with two statements @@ -685,10 +685,16 @@ fn fix_composite_condition(stmt: &Stmt, locator: &Locator, stylist: &Stylist) -> match &assert_statement.test { Expression::UnaryOperation(op) => { if matches!(op.operator, libcst_native::UnaryOp::Not { .. }) { - if let Expression::BooleanOperation(op) = &*op.expression { - if matches!(op.operator, BooleanOp::Or { .. }) { - conditions.push(parenthesize(negate(&op.left), &assert_statement.test)); - conditions.push(parenthesize(negate(&op.right), &assert_statement.test)); + if let Expression::BooleanOperation(boolean_operation) = &*op.expression { + if matches!(boolean_operation.operator, BooleanOp::Or { .. }) { + conditions.push(negate(&parenthesize( + &boolean_operation.left, + &op.expression, + ))); + conditions.push(negate(&parenthesize( + &boolean_operation.right, + &op.expression, + ))); } else { bail!("Expected assert statement to be a composite condition"); } @@ -699,8 +705,8 @@ fn fix_composite_condition(stmt: &Stmt, locator: &Locator, stylist: &Stylist) -> } Expression::BooleanOperation(op) => { if matches!(op.operator, BooleanOp::And { .. }) { - conditions.push(parenthesize(*op.left.clone(), &assert_statement.test)); - conditions.push(parenthesize(*op.right.clone(), &assert_statement.test)); + conditions.push(parenthesize(&op.left, &assert_statement.test)); + conditions.push(parenthesize(&op.right, &assert_statement.test)); } else { bail!("Expected assert statement to be a composite condition"); } diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs index 221b017e6c..fbe674dc1c 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -278,8 +278,6 @@ fn elts_to_csv(elts: &[Expr], generator: Generator) -> Option { acc }) .into(), - - kind: None, range: TextRange::default(), }); Some(generator.expr(&node)) @@ -340,7 +338,6 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) { .map(|name| { Expr::Constant(ast::ExprConstant { value: (*name).to_string().into(), - kind: None, range: TextRange::default(), }) }) @@ -375,7 +372,6 @@ fn check_names(checker: &mut Checker, decorator: &Decorator, expr: &Expr) { .map(|name| { Expr::Constant(ast::ExprConstant { value: (*name).to_string().into(), - kind: None, range: TextRange::default(), }) }) diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/unittest_assert.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/unittest_assert.rs index 49c78e10d4..d319cd32b3 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/unittest_assert.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/unittest_assert.rs @@ -370,7 +370,6 @@ impl UnittestAssert { }; let node = Expr::Constant(ast::ExprConstant { value: Constant::None, - kind: None, range: TextRange::default(), }); let expr = compare(expr, cmp_op, &node); diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap index d9c9771a7d..1d24f27b3a 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap +++ b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap @@ -148,7 +148,7 @@ PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts 18 18 | assert not something and something_else 19 19 | assert not (something or something_else) 20 |- assert not (something or something_else or something_third) - 20 |+ assert not something or something_else + 20 |+ assert not (something or something_else) 21 |+ assert not something_third 21 22 | assert something and something_else == """error 22 23 | message @@ -351,4 +351,67 @@ PT018.py:54:9: PT018 Assertion should be broken down into multiple parts | = help: Break down assertion into multiple parts +PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts + | +57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7143 +58 | def test_parenthesized_not(): +59 | assert not ( + | _____^ +60 | | self.find_graph_output(node.output[0]) +61 | | or self.find_graph_input(node.input[0]) +62 | | or self.find_graph_output(node.input[0]) +63 | | ) + | |_____^ PT018 +64 | +65 | assert (not ( + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +59 59 | assert not ( +60 60 | self.find_graph_output(node.output[0]) +61 61 | or self.find_graph_input(node.input[0]) +62 |- or self.find_graph_output(node.input[0]) +63 62 | ) + 63 |+ assert not ( + 64 |+ self.find_graph_output(node.input[0]) + 65 |+ ) +64 66 | +65 67 | assert (not ( +66 68 | self.find_graph_output(node.output[0]) + +PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts + | +63 | ) +64 | +65 | assert (not ( + | _____^ +66 | | self.find_graph_output(node.output[0]) +67 | | or self.find_graph_input(node.input[0]) +68 | | or self.find_graph_output(node.input[0]) +69 | | )) + | |______^ PT018 +70 | +71 | assert (not self.find_graph_output(node.output[0]) or + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +62 62 | or self.find_graph_output(node.input[0]) +63 63 | ) +64 64 | +65 |- assert (not ( + 65 |+ assert not ( +66 66 | self.find_graph_output(node.output[0]) +67 67 | or self.find_graph_input(node.input[0]) +68 |- or self.find_graph_output(node.input[0]) +69 |- )) + 68 |+ ) + 69 |+ assert not ( + 70 |+ self.find_graph_output(node.input[0]) + 71 |+ ) +70 72 | +71 73 | assert (not self.find_graph_output(node.output[0]) or +72 74 | self.find_graph_input(node.input[0])) + diff --git a/crates/ruff/src/rules/flake8_return/rules/function.rs b/crates/ruff/src/rules/flake8_return/rules/function.rs index d5c62b7d78..a3002e9bac 100644 --- a/crates/ruff/src/rules/flake8_return/rules/function.rs +++ b/crates/ruff/src/rules/flake8_return/rules/function.rs @@ -12,6 +12,7 @@ use ruff_python_ast::stmt_if::elif_else_range; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::whitespace::indentation; use ruff_python_semantic::SemanticModel; +use ruff_python_trivia::is_python_whitespace; use crate::autofix::edits; use crate::checkers::ast::Checker; @@ -549,11 +550,11 @@ fn unnecessary_assign(checker: &mut Checker, stack: &Stack) { if content[after_equals..] .chars() .next() - .is_some_and(char::is_alphabetic) + .is_some_and(is_python_whitespace) { - "return ".to_string() - } else { "return".to_string() + } else { + "return ".to_string() }, // Replace from the start of the assignment statement to the end of the equals // sign. diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap index ae04abcf8c..33608dd533 100644 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap +++ b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap @@ -197,5 +197,25 @@ RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` state 358 |- a = 1 # Comment 359 |- return a 358 |+ return 1 # Comment +360 359 | +361 360 | +362 361 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 + +RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` statement + | +363 | def mavko_debari(P_kbar): +364 | D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 +365 | return D + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +361 361 | +362 362 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 +363 363 | def mavko_debari(P_kbar): +364 |- D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 +365 |- return D + 364 |+ return 0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 diff --git a/crates/ruff/src/rules/flake8_self/mod.rs b/crates/ruff/src/rules/flake8_self/mod.rs index 3866aa49c4..8c9ab60d7e 100644 --- a/crates/ruff/src/rules/flake8_self/mod.rs +++ b/crates/ruff/src/rules/flake8_self/mod.rs @@ -11,6 +11,7 @@ mod tests { use test_case::test_case; use crate::registry::Rule; + use crate::rules::flake8_self; use crate::test::test_path; use crate::{assert_messages, settings}; @@ -24,4 +25,19 @@ mod tests { assert_messages!(snapshot, diagnostics); Ok(()) } + + #[test] + fn ignore_names() -> Result<()> { + let diagnostics = test_path( + Path::new("flake8_self/SLF001_extended.py"), + &settings::Settings { + flake8_self: flake8_self::settings::Settings { + ignore_names: vec!["_meta".to_string()], + }, + ..settings::Settings::for_rule(Rule::PrivateMemberAccess) + }, + )?; + assert_messages!(diagnostics); + Ok(()) + } } diff --git a/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__ignore_names.snap b/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__ignore_names.snap new file mode 100644 index 0000000000..6d3072d4e8 --- /dev/null +++ b/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__ignore_names.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff/src/rules/flake8_self/mod.rs +--- +SLF001_extended.py:6:5: SLF001 Private member accessed: `_asdict` + | +5 | def foo(obj): +6 | obj._asdict # SLF001 + | ^^^^^^^^^^^ SLF001 + | + +SLF001_extended.py:10:5: SLF001 Private member accessed: `_bar` + | + 9 | def foo(obj): +10 | obj._bar # SLF001 + | ^^^^^^^^ SLF001 + | + + diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs index cbd348cc38..ea895e5123 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs @@ -11,6 +11,8 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, AutofixKind, Diagnostic, Edit use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::helpers::{contains_effect, Truthiness}; +use ruff_python_ast::parenthesize::parenthesized_range; +use ruff_python_codegen::Generator; use crate::checkers::ast::Checker; use crate::registry::AsRule; @@ -692,12 +694,12 @@ pub(crate) fn expr_or_not_expr(checker: &mut Checker, expr: &Expr) { } } -pub(crate) fn get_short_circuit_edit( +fn get_short_circuit_edit( expr: &Expr, range: TextRange, truthiness: Truthiness, in_boolean_test: bool, - checker: &Checker, + generator: Generator, ) -> Edit { let content = if in_boolean_test { match truthiness { @@ -708,9 +710,17 @@ pub(crate) fn get_short_circuit_edit( } } } else { - checker.generator().expr(expr) + generator.expr(expr) }; - Edit::range_replacement(content, range) + Edit::range_replacement( + if matches!(expr, Expr::Tuple(ast::ExprTuple { elts, ctx: _, range: _}) if !elts.is_empty()) + { + format!("({content})") + } else { + content + }, + range, + ) } fn is_short_circuit( @@ -734,7 +744,7 @@ fn is_short_circuit( BoolOp::Or => Truthiness::Truthy, }; - let mut location = expr.start(); + let mut furthest = expr; let mut edit = None; let mut remove = None; @@ -749,7 +759,7 @@ fn is_short_circuit( && (!checker.semantic().in_boolean_test() || contains_effect(value, |id| checker.semantic().is_builtin(id))) { - location = next_value.start(); + furthest = next_value; continue; } @@ -758,17 +768,19 @@ fn is_short_circuit( // short-circuit expression is the first expression in the list; otherwise, we'll see it // as `next_value` before we see it as `value`. if value_truthiness == short_circuit_truthiness { - remove = Some(if location == value.start() { - ContentAround::After - } else { - ContentAround::Both - }); + remove = Some(ContentAround::After); + edit = Some(get_short_circuit_edit( value, - TextRange::new(location, expr.end()), + TextRange::new( + parenthesized_range(furthest.into(), expr.into(), checker.locator().contents()) + .unwrap_or(furthest.range()) + .start(), + expr.end(), + ), short_circuit_truthiness, checker.semantic().in_boolean_test(), - checker, + checker.generator(), )); break; } @@ -776,17 +788,22 @@ fn is_short_circuit( // If the next expression is a constant, and it matches the short-circuit value, then // we can return the location of the expression. if next_value_truthiness == short_circuit_truthiness { - remove = Some(if index == values.len() - 2 { + remove = Some(if index + 1 == values.len() - 1 { ContentAround::Before } else { ContentAround::Both }); edit = Some(get_short_circuit_edit( next_value, - TextRange::new(location, expr.end()), + TextRange::new( + parenthesized_range(furthest.into(), expr.into(), checker.locator().contents()) + .unwrap_or(furthest.range()) + .start(), + expr.end(), + ), short_circuit_truthiness, checker.semantic().in_boolean_test(), - checker, + checker.generator(), )); break; } diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs index 9ecef0af34..40ac939d0b 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs @@ -184,8 +184,12 @@ fn check_os_environ_subscript(checker: &mut Checker, expr: &Expr) { return; } let Expr::Constant(ast::ExprConstant { - value: Constant::Str(ast::StringConstant { value: env_var, .. }), - kind, + value: + Constant::Str(ast::StringConstant { + value: env_var, + unicode, + .. + }), range: _, }) = slice.as_ref() else { @@ -205,8 +209,11 @@ fn check_os_environ_subscript(checker: &mut Checker, expr: &Expr) { ); if checker.patch(diagnostic.kind.rule()) { let node = ast::ExprConstant { - value: capital_env_var.into(), - kind: kind.clone(), + value: ast::Constant::Str(ast::StringConstant { + value: capital_env_var, + unicode: *unicode, + implicit_concatenated: false, + }), range: TextRange::default(), }; let new_env_var = node.into(); diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs index 312cf01ecc..1dc4919308 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -4,6 +4,7 @@ use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::{is_const_false, is_const_true}; +use ruff_python_ast::parenthesize::parenthesized_range; use crate::checkers::ast::Checker; use crate::registry::AsRule; @@ -30,7 +31,7 @@ use crate::registry::AsRule; /// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing) #[violation] pub struct IfExprWithTrueFalse { - expr: String, + is_compare: bool, } impl Violation for IfExprWithTrueFalse { @@ -38,13 +39,21 @@ impl Violation for IfExprWithTrueFalse { #[derive_message_formats] fn message(&self) -> String { - let IfExprWithTrueFalse { expr } = self; - format!("Use `bool({expr})` instead of `True if {expr} else False`") + let IfExprWithTrueFalse { is_compare } = self; + if *is_compare { + format!("Remove unnecessary `True if ... else False`") + } else { + format!("Use `bool(...)` instead of `True if ... else False`") + } } fn autofix_title(&self) -> Option { - let IfExprWithTrueFalse { expr } = self; - Some(format!("Replace with `not {expr}")) + let IfExprWithTrueFalse { is_compare } = self; + if *is_compare { + Some(format!("Remove unnecessary `True if ... else False`")) + } else { + Some(format!("Replace with `bool(...)")) + } } } @@ -70,20 +79,16 @@ impl Violation for IfExprWithTrueFalse { /// ## References /// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing) #[violation] -pub struct IfExprWithFalseTrue { - expr: String, -} +pub struct IfExprWithFalseTrue; impl AlwaysAutofixableViolation for IfExprWithFalseTrue { #[derive_message_formats] fn message(&self) -> String { - let IfExprWithFalseTrue { expr } = self; - format!("Use `not {expr}` instead of `False if {expr} else True`") + format!("Use `not ...` instead of `False if ... else True`") } fn autofix_title(&self) -> String { - let IfExprWithFalseTrue { expr } = self; - format!("Replace with `bool({expr})") + format!("Replace with `not ...`") } } @@ -135,7 +140,7 @@ impl AlwaysAutofixableViolation for IfExprWithTwistedArms { } /// SIM210 -pub(crate) fn explicit_true_false_in_ifexpr( +pub(crate) fn if_expr_with_true_false( checker: &mut Checker, expr: &Expr, test: &Expr, @@ -148,33 +153,43 @@ pub(crate) fn explicit_true_false_in_ifexpr( let mut diagnostic = Diagnostic::new( IfExprWithTrueFalse { - expr: checker.generator().expr(test), + is_compare: test.is_compare_expr(), }, expr.range(), ); if checker.patch(diagnostic.kind.rule()) { if test.is_compare_expr() { diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - checker.locator().slice(test).to_string(), + checker + .locator() + .slice( + parenthesized_range(test.into(), expr.into(), checker.locator().contents()) + .unwrap_or(test.range()), + ) + .to_string(), expr.range(), ))); } else if checker.semantic().is_builtin("bool") { - let node = ast::ExprName { - id: "bool".into(), - ctx: ExprContext::Load, - range: TextRange::default(), - }; - let node1 = ast::ExprCall { - func: Box::new(node.into()), - arguments: Arguments { - args: vec![test.clone()], - keywords: vec![], - range: TextRange::default(), - }, - range: TextRange::default(), - }; diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - checker.generator().expr(&node1.into()), + checker.generator().expr( + &ast::ExprCall { + func: Box::new( + ast::ExprName { + id: "bool".into(), + ctx: ExprContext::Load, + range: TextRange::default(), + } + .into(), + ), + arguments: Arguments { + args: vec![test.clone()], + keywords: vec![], + range: TextRange::default(), + }, + range: TextRange::default(), + } + .into(), + ), expr.range(), ))); }; @@ -183,7 +198,7 @@ pub(crate) fn explicit_true_false_in_ifexpr( } /// SIM211 -pub(crate) fn explicit_false_true_in_ifexpr( +pub(crate) fn if_expr_with_false_true( checker: &mut Checker, expr: &Expr, test: &Expr, @@ -194,21 +209,17 @@ pub(crate) fn explicit_false_true_in_ifexpr( return; } - let mut diagnostic = Diagnostic::new( - IfExprWithFalseTrue { - expr: checker.generator().expr(test), - }, - expr.range(), - ); + let mut diagnostic = Diagnostic::new(IfExprWithFalseTrue, expr.range()); if checker.patch(diagnostic.kind.rule()) { - let node = test.clone(); - let node1 = ast::ExprUnaryOp { - op: UnaryOp::Not, - operand: Box::new(node), - range: TextRange::default(), - }; diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - checker.generator().expr(&node1.into()), + checker.generator().expr( + &ast::ExprUnaryOp { + op: UnaryOp::Not, + operand: Box::new(test.clone()), + range: TextRange::default(), + } + .into(), + ), expr.range(), ))); } diff --git a/crates/ruff/src/rules/flake8_simplify/rules/fix_if.rs b/crates/ruff/src/rules/flake8_simplify/rules/fix_if.rs index f2f69690bb..e03b685abb 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/fix_if.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/fix_if.rs @@ -2,17 +2,18 @@ use std::borrow::Cow; use anyhow::{bail, Result}; use libcst_native::{ - BooleanOp, BooleanOperation, CompoundStatement, Expression, If, LeftParen, - ParenthesizableWhitespace, ParenthesizedNode, RightParen, SimpleWhitespace, Statement, Suite, + BooleanOp, BooleanOperation, CompoundStatement, Expression, If, LeftParen, ParenthesizedNode, + RightParen, Statement, Suite, }; -use ruff_text_size::TextRange; use ruff_diagnostics::Edit; use ruff_python_ast::whitespace; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::TextRange; use crate::autofix::codemods::CodegenStylist; +use crate::cst::helpers::space; use crate::cst::matchers::{match_function_def, match_if, match_indented_block, match_statement}; fn parenthesize_and_operand(expr: Expression) -> Expression { @@ -102,8 +103,8 @@ pub(crate) fn fix_nested_if_statements( outer_if.test = Expression::BooleanOperation(Box::new(BooleanOperation { left: Box::new(parenthesize_and_operand(outer_if.test.clone())), operator: BooleanOp::And { - whitespace_before: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), - whitespace_after: ParenthesizableWhitespace::SimpleWhitespace(SimpleWhitespace(" ")), + whitespace_before: space(), + whitespace_after: space(), }, right: Box::new(parenthesize_and_operand(inner_if.test.clone())), lpar: vec![], diff --git a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs b/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs index f6bf6cf940..9fe20266f2 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs @@ -4,6 +4,7 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::parenthesize::parenthesized_range; use ruff_python_ast::{self as ast, Arguments, CmpOp, Comprehension, Expr}; +use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; @@ -31,29 +32,19 @@ use crate::registry::AsRule; /// - [Python documentation: Mapping Types](https://docs.python.org/3/library/stdtypes.html#mapping-types-dict) #[violation] pub struct InDictKeys { - key: String, - dict: String, operator: String, } impl AlwaysAutofixableViolation for InDictKeys { #[derive_message_formats] fn message(&self) -> String { - let InDictKeys { - key, - dict, - operator, - } = self; - format!("Use `{key} {operator} {dict}` instead of `{key} {operator} {dict}.keys()`") + let InDictKeys { operator } = self; + format!("Use `key {operator} dict` instead of `key {operator} dict.keys()`") } fn autofix_title(&self) -> String { - let InDictKeys { - key, - dict, - operator, - } = self; - format!("Convert to `{key} {operator} {dict}`") + let InDictKeys { operator: _ } = self; + format!("Remove `.keys()`") } } @@ -101,25 +92,40 @@ fn key_in_dict( .unwrap_or(left.range()); let right_range = parenthesized_range(right.into(), parent, checker.locator().contents()) .unwrap_or(right.range()); - let value_range = parenthesized_range(value.into(), parent, checker.locator().contents()) - .unwrap_or(value.range()); - - let left_content = checker.locator().slice(left_range); - let value_content = checker.locator().slice(value_range); let mut diagnostic = Diagnostic::new( InDictKeys { - key: left_content.to_string(), - dict: value_content.to_string(), operator: operator.as_str().to_string(), }, TextRange::new(left_range.start(), right_range.end()), ); if checker.patch(diagnostic.kind.rule()) { - diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - value_content.to_string(), - right_range, - ))); + // Delete from the start of the dot to the end of the expression. + if let Some(dot) = SimpleTokenizer::starts_at(value.end(), checker.locator().contents()) + .skip_trivia() + .find(|token| token.kind == SimpleTokenKind::Dot) + { + // If the `.keys()` is followed by (e.g.) a keyword, we need to insert a space, + // since we're removing parentheses, which could lead to invalid syntax, as in: + // ```python + // if key in foo.keys()and bar: + // ``` + let range = TextRange::new(dot.start(), right.end()); + if checker + .locator() + .after(range.end()) + .chars() + .next() + .is_some_and(|char| char.is_ascii_alphabetic()) + { + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( + " ".to_string(), + range, + ))); + } else { + diagnostic.set_fix(Fix::suggested(Edit::range_deletion(range))); + } + } } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs b/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs index 1d9571324e..03e4b2f08c 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs @@ -1,11 +1,10 @@ -use ruff_python_ast::{self as ast, Constant, ExceptHandler, Expr, Stmt}; -use ruff_text_size::{TextLen, TextRange}; - use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::compose_call_path; use ruff_python_ast::helpers; +use ruff_python_ast::{self as ast, Constant, ExceptHandler, Expr, Stmt}; use ruff_text_size::Ranged; +use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; @@ -136,6 +135,8 @@ pub(crate) fn suppressible_exception( if checker.patch(diagnostic.kind.rule()) { if !checker.indexer().has_comments(stmt, checker.locator()) { diagnostic.try_set_fix(|| { + // let range = statement_range(stmt, checker.locator(), checker.indexer()); + let (import_edit, binding) = checker.importer().get_or_import_symbol( &ImportRequest::import("contextlib", "suppress"), stmt.start(), @@ -145,8 +146,8 @@ pub(crate) fn suppressible_exception( format!("with {binding}({exception})"), TextRange::at(stmt.start(), "try".text_len()), ); - let handler_line_begin = checker.locator().line_start(range.start()); - let remove_handler = Edit::deletion(handler_line_begin, range.end()); + let remove_handler = + Edit::range_deletion(checker.locator().full_lines_range(*range)); Ok(Fix::suggested_edits( import_edit, [replace_try, remove_handler], diff --git a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs b/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs index 99ae4f5a39..2fc1ae1fb1 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs @@ -9,8 +9,10 @@ use ruff_python_stdlib::str::{self}; use ruff_source_file::Locator; use ruff_text_size::Ranged; +use crate::autofix::edits::pad; use crate::autofix::snippet::SourceCodeSnippet; use crate::checkers::ast::Checker; +use crate::cst::helpers::or_space; use crate::cst::matchers::{match_comparison, transform_expression}; use crate::registry::AsRule; @@ -116,43 +118,43 @@ fn reverse_comparison(expr: &Expr, locator: &Locator, stylist: &Stylist) -> Resu whitespace_before, whitespace_after, } => CompOp::GreaterThan { - whitespace_before, - whitespace_after, + whitespace_before: or_space(whitespace_before), + whitespace_after: or_space(whitespace_after), }, CompOp::GreaterThan { whitespace_before, whitespace_after, } => CompOp::LessThan { - whitespace_before, - whitespace_after, + whitespace_before: or_space(whitespace_before), + whitespace_after: or_space(whitespace_after), }, CompOp::LessThanEqual { whitespace_before, whitespace_after, } => CompOp::GreaterThanEqual { - whitespace_before, - whitespace_after, + whitespace_before: or_space(whitespace_before), + whitespace_after: or_space(whitespace_after), }, CompOp::GreaterThanEqual { whitespace_before, whitespace_after, } => CompOp::LessThanEqual { - whitespace_before, - whitespace_after, + whitespace_before: or_space(whitespace_before), + whitespace_after: or_space(whitespace_after), }, CompOp::Equal { whitespace_before, whitespace_after, } => CompOp::Equal { - whitespace_before, - whitespace_after, + whitespace_before: or_space(whitespace_before), + whitespace_after: or_space(whitespace_after), }, CompOp::NotEqual { whitespace_before, whitespace_after, } => CompOp::NotEqual { - whitespace_before, - whitespace_after, + whitespace_before: or_space(whitespace_before), + whitespace_after: or_space(whitespace_after), }, _ => panic!("Expected comparison operator"), }; @@ -193,7 +195,7 @@ pub(crate) fn yoda_conditions( ); if checker.patch(diagnostic.kind.rule()) { diagnostic.set_fix(Fix::automatic(Edit::range_replacement( - suggestion, + pad(suggestion, expr.range(), checker.locator()), expr.range(), ))); } diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap index b771624399..f11cb66d1d 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap @@ -2,17 +2,15 @@ source: crates/ruff/src/rules/flake8_simplify/mod.rs --- SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` - | - 5 | # SIM105 - 6 | / try: - 7 | | foo() - 8 | | except ValueError: - 9 | | pass - | |________^ SIM105 -10 | -11 | # SIM105 - | - = help: Replace with `contextlib.suppress(ValueError)` + | +5 | # SIM105 +6 | / try: +7 | | foo() +8 | | except ValueError: +9 | | pass + | |________^ SIM105 + | + = help: Replace with `contextlib.suppress(ValueError)` ℹ Suggested fix 1 |+import contextlib @@ -27,21 +25,19 @@ SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `tr 8 |-except ValueError: 9 |- pass 10 9 | - 10 |+ -11 11 | # SIM105 -12 12 | try: -13 13 | foo() +11 10 | +12 11 | # SIM105 -SIM105_0.py:12:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` +SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | -11 | # SIM105 -12 | / try: -13 | | foo() -14 | | except (ValueError, OSError): -15 | | pass +12 | # SIM105 +13 | / try: +14 | | foo() +15 | | except (ValueError, OSError): +16 | | pass | |________^ SIM105 -16 | -17 | # SIM105 +17 | +18 | # SIM105 | = help: Replace with `contextlib.suppress(ValueError, OSError)` @@ -51,30 +47,28 @@ SIM105_0.py:12:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst 2 3 | pass 3 4 | -------------------------------------------------------------------------------- -9 10 | pass 10 11 | -11 12 | # SIM105 -12 |-try: - 13 |+with contextlib.suppress(ValueError, OSError): -13 14 | foo() -14 |-except (ValueError, OSError): -15 |- pass -16 15 | - 16 |+ -17 17 | # SIM105 -18 18 | try: -19 19 | foo() +11 12 | +12 13 | # SIM105 +13 |-try: + 14 |+with contextlib.suppress(ValueError, OSError): +14 15 | foo() +15 |-except (ValueError, OSError): +16 |- pass +17 16 | +18 17 | # SIM105 +19 18 | try: -SIM105_0.py:18:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` +SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | -17 | # SIM105 -18 | / try: -19 | | foo() -20 | | except (ValueError, OSError) as e: -21 | | pass +18 | # SIM105 +19 | / try: +20 | | foo() +21 | | except (ValueError, OSError) as e: +22 | | pass | |________^ SIM105 -22 | -23 | # SIM105 +23 | +24 | # SIM105 | = help: Replace with `contextlib.suppress(ValueError, OSError)` @@ -84,30 +78,28 @@ SIM105_0.py:18:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst 2 3 | pass 3 4 | -------------------------------------------------------------------------------- -15 16 | pass -16 17 | -17 18 | # SIM105 -18 |-try: - 19 |+with contextlib.suppress(ValueError, OSError): -19 20 | foo() -20 |-except (ValueError, OSError) as e: -21 |- pass -22 21 | - 22 |+ -23 23 | # SIM105 -24 24 | try: -25 25 | foo() +16 17 | pass +17 18 | +18 19 | # SIM105 +19 |-try: + 20 |+with contextlib.suppress(ValueError, OSError): +20 21 | foo() +21 |-except (ValueError, OSError) as e: +22 |- pass +23 22 | +24 23 | # SIM105 +25 24 | try: -SIM105_0.py:24:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `try`-`except`-`pass` +SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `try`-`except`-`pass` | -23 | # SIM105 -24 | / try: -25 | | foo() -26 | | except: -27 | | pass +24 | # SIM105 +25 | / try: +26 | | foo() +27 | | except: +28 | | pass | |________^ SIM105 -28 | -29 | # SIM105 +29 | +30 | # SIM105 | = help: Replace with `contextlib.suppress(Exception)` @@ -117,30 +109,28 @@ SIM105_0.py:24:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `tr 2 3 | pass 3 4 | -------------------------------------------------------------------------------- -21 22 | pass -22 23 | -23 24 | # SIM105 -24 |-try: - 25 |+with contextlib.suppress(Exception): -25 26 | foo() -26 |-except: -27 |- pass -28 27 | - 28 |+ -29 29 | # SIM105 -30 30 | try: -31 31 | foo() +22 23 | pass +23 24 | +24 25 | # SIM105 +25 |-try: + 26 |+with contextlib.suppress(Exception): +26 27 | foo() +27 |-except: +28 |- pass +29 28 | +30 29 | # SIM105 +31 30 | try: -SIM105_0.py:30:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` +SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` | -29 | # SIM105 -30 | / try: -31 | | foo() -32 | | except (a.Error, b.Error): -33 | | pass +30 | # SIM105 +31 | / try: +32 | | foo() +33 | | except (a.Error, b.Error): +34 | | pass | |________^ SIM105 -34 | -35 | # OK +35 | +36 | # OK | = help: Replace with `contextlib.suppress(a.Error, b.Error)` @@ -150,29 +140,27 @@ SIM105_0.py:30:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead 2 3 | pass 3 4 | -------------------------------------------------------------------------------- -27 28 | pass -28 29 | -29 30 | # SIM105 -30 |-try: - 31 |+with contextlib.suppress(a.Error, b.Error): -31 32 | foo() -32 |-except (a.Error, b.Error): -33 |- pass -34 33 | - 34 |+ -35 35 | # OK -36 36 | try: -37 37 | foo() +28 29 | pass +29 30 | +30 31 | # SIM105 +31 |-try: + 32 |+with contextlib.suppress(a.Error, b.Error): +32 33 | foo() +33 |-except (a.Error, b.Error): +34 |- pass +35 34 | +36 35 | # OK +37 36 | try: -SIM105_0.py:84:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` +SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` | -82 | def with_ellipsis(): -83 | # OK -84 | try: +83 | def with_ellipsis(): +84 | # OK +85 | try: | _____^ -85 | | foo() -86 | | except ValueError: -87 | | ... +86 | | foo() +87 | | except ValueError: +88 | | ... | |___________^ SIM105 | = help: Replace with `contextlib.suppress(ValueError)` @@ -183,33 +171,124 @@ SIM105_0.py:84:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t 2 3 | pass 3 4 | -------------------------------------------------------------------------------- -81 82 | -82 83 | def with_ellipsis(): -83 84 | # OK -84 |- try: - 85 |+ with contextlib.suppress(ValueError): -85 86 | foo() -86 |- except ValueError: -87 |- ... -88 87 | +82 83 | +83 84 | def with_ellipsis(): +84 85 | # OK +85 |- try: + 86 |+ with contextlib.suppress(ValueError): +86 87 | foo() +87 |- except ValueError: +88 |- ... 89 88 | - 89 |+ -90 90 | def with_ellipsis_and_return(): -91 91 | # OK -92 92 | try: +90 89 | +91 90 | def with_ellipsis_and_return(): -SIM105_0.py:99:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` +SIM105_0.py:100:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` | - 98 | def with_comment(): - 99 | try: + 99 | def with_comment(): +100 | try: | _____^ -100 | | foo() -101 | | except (ValueError, OSError): -102 | | pass # Trailing comment. +101 | | foo() +102 | | except (ValueError, OSError): +103 | | pass # Trailing comment. | |____________^ SIM105 -103 | -104 | try: +104 | +105 | try: | = help: Replace with `contextlib.suppress(ValueError, OSError)` +SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + | +115 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 +116 | def write_models(directory, Models): +117 | try: + | _____^ +118 | | os.makedirs(model_dir); +119 | | except OSError: +120 | | pass; + | |____________^ SIM105 +121 | +122 | try: os.makedirs(model_dir); + | + = help: Replace with `contextlib.suppress(OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +114 115 | +115 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 +116 117 | def write_models(directory, Models): +117 |- try: + 118 |+ with contextlib.suppress(OSError): +118 119 | os.makedirs(model_dir); +119 |- except OSError: +120 |- pass; +121 120 | +122 121 | try: os.makedirs(model_dir); +123 122 | except OSError: + +SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + | +120 | pass; +121 | +122 | try: os.makedirs(model_dir); + | _____^ +123 | | except OSError: +124 | | pass; + | |____________^ SIM105 +125 | +126 | try: os.makedirs(model_dir); + | + = help: Replace with `contextlib.suppress(OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +119 120 | except OSError: +120 121 | pass; +121 122 | +122 |- try: os.makedirs(model_dir); +123 |- except OSError: +124 |- pass; + 123 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); +125 124 | +126 125 | try: os.makedirs(model_dir); +127 126 | except OSError: + +SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + | +124 | pass; +125 | +126 | try: os.makedirs(model_dir); + | _____^ +127 | | except OSError: +128 | | pass; \ + | |____________^ SIM105 +129 | \ +130 | # + | + = help: Replace with `contextlib.suppress(OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +123 124 | except OSError: +124 125 | pass; +125 126 | +126 |- try: os.makedirs(model_dir); +127 |- except OSError: +128 |- pass; \ + 127 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); +129 128 | \ +130 129 | # + diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap index e9fd647daf..2d8426b90e 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap @@ -23,6 +23,5 @@ SIM105_1.py:5:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `tr 6 7 | math.sqrt(-1) 7 |-except ValueError: 8 |- pass - 8 |+ diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap index 5eee10ea83..6a41bb27e1 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap @@ -21,6 +21,5 @@ SIM105_2.py:10:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t 11 11 | foo() 12 |-except ValueError: 13 |- pass - 12 |+ diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap index 09dac25801..59b0d3558c 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff/src/rules/flake8_simplify/mod.rs --- -SIM118.py:1:1: SIM118 [*] Use `key in obj` instead of `key in obj.keys()` +SIM118.py:1:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 1 | key in obj.keys() # SIM118 | ^^^^^^^^^^^^^^^^^ SIM118 2 | 3 | key not in obj.keys() # SIM118 | - = help: Convert to `key in obj` + = help: Remove `.keys()` ℹ Suggested fix 1 |-key in obj.keys() # SIM118 @@ -17,7 +17,7 @@ SIM118.py:1:1: SIM118 [*] Use `key in obj` instead of `key in obj.keys()` 3 3 | key not in obj.keys() # SIM118 4 4 | -SIM118.py:3:1: SIM118 [*] Use `key not in obj` instead of `key not in obj.keys()` +SIM118.py:3:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 1 | key in obj.keys() # SIM118 2 | @@ -26,7 +26,7 @@ SIM118.py:3:1: SIM118 [*] Use `key not in obj` instead of `key not in obj.keys() 4 | 5 | foo["bar"] in obj.keys() # SIM118 | - = help: Convert to `key not in obj` + = help: Remove `.keys()` ℹ Suggested fix 1 1 | key in obj.keys() # SIM118 @@ -37,7 +37,7 @@ SIM118.py:3:1: SIM118 [*] Use `key not in obj` instead of `key not in obj.keys() 5 5 | foo["bar"] in obj.keys() # SIM118 6 6 | -SIM118.py:5:1: SIM118 [*] Use `foo["bar"] in obj` instead of `foo["bar"] in obj.keys()` +SIM118.py:5:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 3 | key not in obj.keys() # SIM118 4 | @@ -46,7 +46,7 @@ SIM118.py:5:1: SIM118 [*] Use `foo["bar"] in obj` instead of `foo["bar"] in obj. 6 | 7 | foo["bar"] not in obj.keys() # SIM118 | - = help: Convert to `foo["bar"] in obj` + = help: Remove `.keys()` ℹ Suggested fix 2 2 | @@ -58,7 +58,7 @@ SIM118.py:5:1: SIM118 [*] Use `foo["bar"] in obj` instead of `foo["bar"] in obj. 7 7 | foo["bar"] not in obj.keys() # SIM118 8 8 | -SIM118.py:7:1: SIM118 [*] Use `foo["bar"] not in obj` instead of `foo["bar"] not in obj.keys()` +SIM118.py:7:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 5 | foo["bar"] in obj.keys() # SIM118 6 | @@ -67,7 +67,7 @@ SIM118.py:7:1: SIM118 [*] Use `foo["bar"] not in obj` instead of `foo["bar"] not 8 | 9 | foo['bar'] in obj.keys() # SIM118 | - = help: Convert to `foo["bar"] not in obj` + = help: Remove `.keys()` ℹ Suggested fix 4 4 | @@ -79,7 +79,7 @@ SIM118.py:7:1: SIM118 [*] Use `foo["bar"] not in obj` instead of `foo["bar"] not 9 9 | foo['bar'] in obj.keys() # SIM118 10 10 | -SIM118.py:9:1: SIM118 [*] Use `foo['bar'] in obj` instead of `foo['bar'] in obj.keys()` +SIM118.py:9:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 7 | foo["bar"] not in obj.keys() # SIM118 8 | @@ -88,7 +88,7 @@ SIM118.py:9:1: SIM118 [*] Use `foo['bar'] in obj` instead of `foo['bar'] in obj. 10 | 11 | foo['bar'] not in obj.keys() # SIM118 | - = help: Convert to `foo['bar'] in obj` + = help: Remove `.keys()` ℹ Suggested fix 6 6 | @@ -100,7 +100,7 @@ SIM118.py:9:1: SIM118 [*] Use `foo['bar'] in obj` instead of `foo['bar'] in obj. 11 11 | foo['bar'] not in obj.keys() # SIM118 12 12 | -SIM118.py:11:1: SIM118 [*] Use `foo['bar'] not in obj` instead of `foo['bar'] not in obj.keys()` +SIM118.py:11:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 9 | foo['bar'] in obj.keys() # SIM118 10 | @@ -109,7 +109,7 @@ SIM118.py:11:1: SIM118 [*] Use `foo['bar'] not in obj` instead of `foo['bar'] no 12 | 13 | foo() in obj.keys() # SIM118 | - = help: Convert to `foo['bar'] not in obj` + = help: Remove `.keys()` ℹ Suggested fix 8 8 | @@ -121,7 +121,7 @@ SIM118.py:11:1: SIM118 [*] Use `foo['bar'] not in obj` instead of `foo['bar'] no 13 13 | foo() in obj.keys() # SIM118 14 14 | -SIM118.py:13:1: SIM118 [*] Use `foo() in obj` instead of `foo() in obj.keys()` +SIM118.py:13:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 11 | foo['bar'] not in obj.keys() # SIM118 12 | @@ -130,7 +130,7 @@ SIM118.py:13:1: SIM118 [*] Use `foo() in obj` instead of `foo() in obj.keys()` 14 | 15 | foo() not in obj.keys() # SIM118 | - = help: Convert to `foo() in obj` + = help: Remove `.keys()` ℹ Suggested fix 10 10 | @@ -142,7 +142,7 @@ SIM118.py:13:1: SIM118 [*] Use `foo() in obj` instead of `foo() in obj.keys()` 15 15 | foo() not in obj.keys() # SIM118 16 16 | -SIM118.py:15:1: SIM118 [*] Use `foo() not in obj` instead of `foo() not in obj.keys()` +SIM118.py:15:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` | 13 | foo() in obj.keys() # SIM118 14 | @@ -151,7 +151,7 @@ SIM118.py:15:1: SIM118 [*] Use `foo() not in obj` instead of `foo() not in obj.k 16 | 17 | for key in obj.keys(): # SIM118 | - = help: Convert to `foo() not in obj` + = help: Remove `.keys()` ℹ Suggested fix 12 12 | @@ -163,7 +163,7 @@ SIM118.py:15:1: SIM118 [*] Use `foo() not in obj` instead of `foo() not in obj.k 17 17 | for key in obj.keys(): # SIM118 18 18 | pass -SIM118.py:17:5: SIM118 [*] Use `key in obj` instead of `key in obj.keys()` +SIM118.py:17:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 15 | foo() not in obj.keys() # SIM118 16 | @@ -171,7 +171,7 @@ SIM118.py:17:5: SIM118 [*] Use `key in obj` instead of `key in obj.keys()` | ^^^^^^^^^^^^^^^^^ SIM118 18 | pass | - = help: Convert to `key in obj` + = help: Remove `.keys()` ℹ Suggested fix 14 14 | @@ -183,7 +183,7 @@ SIM118.py:17:5: SIM118 [*] Use `key in obj` instead of `key in obj.keys()` 19 19 | 20 20 | for key in list(obj.keys()): -SIM118.py:24:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` +SIM118.py:24:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 22 | del obj[key] 23 | @@ -192,7 +192,7 @@ SIM118.py:24:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 25 | 26 | {k for k in obj.keys()} # SIM118 | - = help: Convert to `k in obj` + = help: Remove `.keys()` ℹ Suggested fix 21 21 | if some_property(key): @@ -204,7 +204,7 @@ SIM118.py:24:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 26 26 | {k for k in obj.keys()} # SIM118 27 27 | -SIM118.py:26:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` +SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 24 | [k for k in obj.keys()] # SIM118 25 | @@ -213,7 +213,7 @@ SIM118.py:26:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 27 | 28 | {k: k for k in obj.keys()} # SIM118 | - = help: Convert to `k in obj` + = help: Remove `.keys()` ℹ Suggested fix 23 23 | @@ -225,7 +225,7 @@ SIM118.py:26:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 28 28 | {k: k for k in obj.keys()} # SIM118 29 29 | -SIM118.py:28:11: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` +SIM118.py:28:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 26 | {k for k in obj.keys()} # SIM118 27 | @@ -234,7 +234,7 @@ SIM118.py:28:11: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 29 | 30 | (k for k in obj.keys()) # SIM118 | - = help: Convert to `k in obj` + = help: Remove `.keys()` ℹ Suggested fix 25 25 | @@ -246,7 +246,7 @@ SIM118.py:28:11: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 30 30 | (k for k in obj.keys()) # SIM118 31 31 | -SIM118.py:30:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` +SIM118.py:30:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 28 | {k: k for k in obj.keys()} # SIM118 29 | @@ -255,7 +255,7 @@ SIM118.py:30:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 31 | 32 | key in (obj or {}).keys() # SIM118 | - = help: Convert to `k in obj` + = help: Remove `.keys()` ℹ Suggested fix 27 27 | @@ -267,7 +267,7 @@ SIM118.py:30:8: SIM118 [*] Use `k in obj` instead of `k in obj.keys()` 32 32 | key in (obj or {}).keys() # SIM118 33 33 | -SIM118.py:32:1: SIM118 [*] Use `key in (obj or {})` instead of `key in (obj or {}).keys()` +SIM118.py:32:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 30 | (k for k in obj.keys()) # SIM118 31 | @@ -276,7 +276,7 @@ SIM118.py:32:1: SIM118 [*] Use `key in (obj or {})` instead of `key in (obj or { 33 | 34 | (key) in (obj or {}).keys() # SIM118 | - = help: Convert to `key in (obj or {})` + = help: Remove `.keys()` ℹ Suggested fix 29 29 | @@ -288,7 +288,7 @@ SIM118.py:32:1: SIM118 [*] Use `key in (obj or {})` instead of `key in (obj or { 34 34 | (key) in (obj or {}).keys() # SIM118 35 35 | -SIM118.py:34:1: SIM118 [*] Use `(key) in (obj or {})` instead of `(key) in (obj or {}).keys()` +SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` | 32 | key in (obj or {}).keys() # SIM118 33 | @@ -297,7 +297,7 @@ SIM118.py:34:1: SIM118 [*] Use `(key) in (obj or {})` instead of `(key) in (obj 35 | 36 | from typing import KeysView | - = help: Convert to `(key) in (obj or {})` + = help: Remove `.keys()` ℹ Suggested fix 31 31 | @@ -309,4 +309,88 @@ SIM118.py:34:1: SIM118 [*] Use `(key) in (obj or {})` instead of `(key) in (obj 36 36 | from typing import KeysView 37 37 | +SIM118.py:48:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 | key in obj.keys()and foo + | ^^^^^^^^^^^^^^^^^ SIM118 +49 | (key in obj.keys())and foo +50 | key in (obj.keys())and foo + | + = help: Remove `.keys()` + +ℹ Suggested fix +45 45 | +46 46 | +47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 |-key in obj.keys()and foo + 48 |+key in obj and foo +49 49 | (key in obj.keys())and foo +50 50 | key in (obj.keys())and foo +51 51 | + +SIM118.py:49:2: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 | key in obj.keys()and foo +49 | (key in obj.keys())and foo + | ^^^^^^^^^^^^^^^^^ SIM118 +50 | key in (obj.keys())and foo + | + = help: Remove `.keys()` + +ℹ Suggested fix +46 46 | +47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 48 | key in obj.keys()and foo +49 |-(key in obj.keys())and foo + 49 |+(key in obj)and foo +50 50 | key in (obj.keys())and foo +51 51 | +52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 + +SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +48 | key in obj.keys()and foo +49 | (key in obj.keys())and foo +50 | key in (obj.keys())and foo + | ^^^^^^^^^^^^^^^^^^^ SIM118 +51 | +52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 + | + = help: Remove `.keys()` + +ℹ Suggested fix +47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 48 | key in obj.keys()and foo +49 49 | (key in obj.keys())and foo +50 |-key in (obj.keys())and foo + 50 |+key in (obj)and foo +51 51 | +52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 +53 53 | for key in ( + +SIM118.py:53:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 +53 | for key in ( + | _____^ +54 | | self.experiment.surveys[0] +55 | | .stations[0] +56 | | .keys() +57 | | ): + | |_^ SIM118 +58 | continue + | + = help: Remove `.keys()` + +ℹ Suggested fix +53 53 | for key in ( +54 54 | self.experiment.surveys[0] +55 55 | .stations[0] +56 |- .keys() + 56 |+ +57 57 | ): +58 58 | continue + diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap index 717740927a..66f2e91bcf 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff/src/rules/flake8_simplify/mod.rs --- -SIM210.py:1:5: SIM210 [*] Use `bool(b)` instead of `True if b else False` +SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | 1 | a = True if b else False # SIM210 | ^^^^^^^^^^^^^^^^^^^^ SIM210 2 | 3 | a = True if b != c else False # SIM210 | - = help: Replace with `not b + = help: Replace with `bool(...) ℹ Suggested fix 1 |-a = True if b else False # SIM210 @@ -17,7 +17,7 @@ SIM210.py:1:5: SIM210 [*] Use `bool(b)` instead of `True if b else False` 3 3 | a = True if b != c else False # SIM210 4 4 | -SIM210.py:3:5: SIM210 [*] Use `bool(b != c)` instead of `True if b != c else False` +SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` | 1 | a = True if b else False # SIM210 2 | @@ -26,7 +26,7 @@ SIM210.py:3:5: SIM210 [*] Use `bool(b != c)` instead of `True if b != c else Fal 4 | 5 | a = True if b + c else False # SIM210 | - = help: Replace with `not b != c + = help: Remove unnecessary `True if ... else False` ℹ Suggested fix 1 1 | a = True if b else False # SIM210 @@ -37,7 +37,7 @@ SIM210.py:3:5: SIM210 [*] Use `bool(b != c)` instead of `True if b != c else Fal 5 5 | a = True if b + c else False # SIM210 6 6 | -SIM210.py:5:5: SIM210 [*] Use `bool(b + c)` instead of `True if b + c else False` +SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` | 3 | a = True if b != c else False # SIM210 4 | @@ -46,7 +46,7 @@ SIM210.py:5:5: SIM210 [*] Use `bool(b + c)` instead of `True if b + c else False 6 | 7 | a = False if b else True # OK | - = help: Replace with `not b + c + = help: Replace with `bool(...) ℹ Suggested fix 2 2 | @@ -58,13 +58,32 @@ SIM210.py:5:5: SIM210 [*] Use `bool(b + c)` instead of `True if b + c else False 7 7 | a = False if b else True # OK 8 8 | -SIM210.py:15:9: SIM210 Use `bool(b)` instead of `True if b else False` +SIM210.py:15:9: SIM210 Use `bool(...)` instead of `True if ... else False` | 13 | return False 14 | 15 | a = True if b else False | ^^^^^^^^^^^^^^^^^^^^ SIM210 | - = help: Replace with `not b + = help: Replace with `bool(...) + +SIM210.py:19:11: SIM210 [*] Remove unnecessary `True if ... else False` + | +18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 +19 | samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == + | ___________^ +20 | | psl.privatesuffix(src.netloc)) else False + | |____________________________________________________________________________^ SIM210 + | + = help: Remove unnecessary `True if ... else False` + +ℹ Suggested fix +16 16 | +17 17 | +18 18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 +19 |-samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == +20 |- psl.privatesuffix(src.netloc)) else False + 19 |+samesld = (psl.privatesuffix(urlparse(response.url).netloc) == + 20 |+ psl.privatesuffix(src.netloc)) diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap index e221b2b3dc..b6d6d2570f 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff/src/rules/flake8_simplify/mod.rs --- -SIM211.py:1:5: SIM211 [*] Use `not b` instead of `False if b else True` +SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | 1 | a = False if b else True # SIM211 | ^^^^^^^^^^^^^^^^^^^^ SIM211 2 | 3 | a = False if b != c else True # SIM211 | - = help: Replace with `bool(b) + = help: Replace with `not ...` ℹ Suggested fix 1 |-a = False if b else True # SIM211 @@ -17,7 +17,7 @@ SIM211.py:1:5: SIM211 [*] Use `not b` instead of `False if b else True` 3 3 | a = False if b != c else True # SIM211 4 4 | -SIM211.py:3:5: SIM211 [*] Use `not b != c` instead of `False if b != c else True` +SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | 1 | a = False if b else True # SIM211 2 | @@ -26,7 +26,7 @@ SIM211.py:3:5: SIM211 [*] Use `not b != c` instead of `False if b != c else True 4 | 5 | a = False if b + c else True # SIM211 | - = help: Replace with `bool(b != c) + = help: Replace with `not ...` ℹ Suggested fix 1 1 | a = False if b else True # SIM211 @@ -37,7 +37,7 @@ SIM211.py:3:5: SIM211 [*] Use `not b != c` instead of `False if b != c else True 5 5 | a = False if b + c else True # SIM211 6 6 | -SIM211.py:5:5: SIM211 [*] Use `not b + c` instead of `False if b + c else True` +SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` | 3 | a = False if b != c else True # SIM211 4 | @@ -46,7 +46,7 @@ SIM211.py:5:5: SIM211 [*] Use `not b + c` instead of `False if b + c else True` 6 | 7 | a = True if b else False # OK | - = help: Replace with `bool(b + c) + = help: Replace with `not ...` ℹ Suggested fix 2 2 | diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap index 91a804d98a..a4bf8aa027 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -534,7 +534,7 @@ SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` 87 87 | a or (1,) or True or (2,) # SIM222 88 88 | -SIM222.py:87:6: SIM222 [*] Use `1,` instead of `1, or ...` +SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` | 85 | a or tuple(()) or True # SIM222 86 | @@ -543,14 +543,14 @@ SIM222.py:87:6: SIM222 [*] Use `1,` instead of `1, or ...` 88 | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 | - = help: Replace with `1,` + = help: Replace with `(1,)` ℹ Suggested fix 84 84 | 85 85 | a or tuple(()) or True # SIM222 86 86 | 87 |-a or (1,) or True or (2,) # SIM222 - 87 |+a or 1, # SIM222 + 87 |+a or (1,) # SIM222 88 88 | 89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 90 90 | @@ -1003,5 +1003,42 @@ SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` 153 |-if f(a or [1] or True or [2]): # SIM222 153 |+if f(a or [1]): # SIM222 154 154 | pass +155 155 | +156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 + +SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` + | +156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 +157 | def secondToTime(s0: int) -> (int, int, int) or str: + | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 +158 | m, s = divmod(s0, 60) + | + = help: Replace with `(int, int, int)` + +ℹ Suggested fix +154 154 | pass +155 155 | +156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 +157 |-def secondToTime(s0: int) -> (int, int, int) or str: + 157 |+def secondToTime(s0: int) -> (int, int, int): +158 158 | m, s = divmod(s0, 60) +159 159 | +160 160 | + +SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` + | +161 | def secondToTime(s0: int) -> ((int, int, int) or str): + | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 +162 | m, s = divmod(s0, 60) + | + = help: Replace with `(int, int, int)` + +ℹ Suggested fix +158 158 | m, s = divmod(s0, 60) +159 159 | +160 160 | +161 |-def secondToTime(s0: int) -> ((int, int, int) or str): + 161 |+def secondToTime(s0: int) -> ((int, int, int)): +162 162 | m, s = divmod(s0, 60) diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap index 50c2af9f8c..997f098472 100644 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -268,7 +268,7 @@ SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrde 14 |+age == JediOrder.YODA # SIM300 15 15 | 0 < (number - 100) # SIM300 16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 17 | +17 17 | B 0` instead | @@ -277,6 +277,7 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) 15 | 0 < (number - 100) # SIM300 | ^^^^^^^^^^^^^^^^^^ SIM300 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 | B 0` @@ -287,8 +288,8 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) 15 |-0 < (number - 100) # SIM300 15 |+(number - 100) > 0 # SIM300 16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 17 | -18 18 | # OK +17 17 | B (60 * 60) # SIM300 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300 -17 | -18 | # OK +17 | B (60 * 60) # SIM300 16 |+(60 * 60) < SomeClass().settings.SOME_CONSTANT_VALUE # SIM300 -17 17 | -18 18 | # OK -19 19 | compare == "yoda" +17 17 | B B` instead + | +15 | 0 < (number - 100) # SIM300 +16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 | B B` + +ℹ Fix +14 14 | JediOrder.YODA == age # SIM300 +15 15 | 0 < (number - 100) # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 |-B B or B +18 18 | B or(B) (B)` instead + | +16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 | B (B)` + +ℹ Fix +15 15 | 0 < (number - 100) # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 17 | B (B) +19 19 | +20 20 | # OK +21 21 | compare == "yoda" diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs b/crates/ruff/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs index 2a814c01a6..3103f0577e 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs @@ -68,7 +68,6 @@ pub(crate) fn path_constructor_current_directory(checker: &mut Checker, expr: &E let [Expr::Constant(ExprConstant { value: Constant::Str(ast::StringConstant { value, .. }), - kind: _, range, })] = args.as_slice() else { diff --git a/crates/ruff/src/rules/flynt/helpers.rs b/crates/ruff/src/rules/flynt/helpers.rs index 35183bb020..bc2e18197a 100644 --- a/crates/ruff/src/rules/flynt/helpers.rs +++ b/crates/ruff/src/rules/flynt/helpers.rs @@ -17,7 +17,6 @@ fn to_formatted_value_expr(inner: &Expr) -> Expr { pub(super) fn to_constant_string(s: &str) -> Expr { let node = ast::ExprConstant { value: s.to_owned().into(), - kind: None, range: TextRange::default(), }; node.into() diff --git a/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs b/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs index d89e98a444..8cb4268c1a 100644 --- a/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs +++ b/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs @@ -1,5 +1,6 @@ use itertools::Itertools; +use crate::autofix::edits::pad; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::{self as ast, Arguments, Constant, Expr}; @@ -86,7 +87,6 @@ fn build_fstring(joiner: &str, joinees: &[Expr]) -> Option { .join(joiner) .into(), range: TextRange::default(), - kind: None, }; return Some(node.into()); } @@ -114,6 +114,7 @@ fn build_fstring(joiner: &str, joinees: &[Expr]) -> Option { Some(node.into()) } +/// FLY002 pub(crate) fn static_join_to_fstring(checker: &mut Checker, expr: &Expr, joiner: &str) { let Expr::Call(ast::ExprCall { arguments: Arguments { args, keywords, .. }, @@ -155,7 +156,7 @@ pub(crate) fn static_join_to_fstring(checker: &mut Checker, expr: &Expr, joiner: ); if checker.patch(diagnostic.kind.rule()) { diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - contents, + pad(contents, expr.range(), checker.locator()), expr.range(), ))); } diff --git a/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap b/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap index def47016d3..aff724b257 100644 --- a/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap +++ b/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap @@ -125,4 +125,20 @@ FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_ 12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) 13 13 | nok2 = a.join(["1", "2", "3"]) # Not OK (not a static joiner) +FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join + | +21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 +22 | def create_file_public_url(url, filename): +23 | return''.join([url, filename]) + | ^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | + = help: Replace with `f"{url}{filename}"` + +ℹ Suggested fix +20 20 | +21 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 +22 22 | def create_file_public_url(url, filename): +23 |- return''.join([url, filename]) + 23 |+ return f"{url}{filename}" + diff --git a/crates/ruff/src/rules/isort/block.rs b/crates/ruff/src/rules/isort/block.rs index b4fdee6d44..4f24a1c1d2 100644 --- a/crates/ruff/src/rules/isort/block.rs +++ b/crates/ruff/src/rules/isort/block.rs @@ -1,13 +1,13 @@ -use ruff_python_ast::{self as ast, ElifElseClause, ExceptHandler, MatchCase, Stmt}; -use ruff_text_size::{Ranged, TextRange, TextSize}; use std::iter::Peekable; use std::slice; +use ruff_notebook::Notebook; use ruff_python_ast::statement_visitor::StatementVisitor; +use ruff_python_ast::{self as ast, ElifElseClause, ExceptHandler, MatchCase, Stmt}; use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::directives::IsortDirectives; -use crate::jupyter::Notebook; use crate::rules::isort::helpers; use crate::source_kind::SourceKind; @@ -43,7 +43,7 @@ impl<'a> BlockBuilder<'a> { locator: &'a Locator<'a>, directives: &'a IsortDirectives, is_stub: bool, - source_kind: Option<&'a SourceKind>, + source_kind: &'a SourceKind, ) -> Self { Self { locator, @@ -53,7 +53,7 @@ impl<'a> BlockBuilder<'a> { exclusions: &directives.exclusions, nested: false, cell_offsets: source_kind - .and_then(SourceKind::notebook) + .as_ipy_notebook() .map(Notebook::cell_offsets) .map(|offsets| offsets.iter().peekable()), } diff --git a/crates/ruff/src/rules/numpy/rules/deprecated_function.rs b/crates/ruff/src/rules/numpy/rules/deprecated_function.rs index 6c422c0cc0..b88581fe91 100644 --- a/crates/ruff/src/rules/numpy/rules/deprecated_function.rs +++ b/crates/ruff/src/rules/numpy/rules/deprecated_function.rs @@ -1,10 +1,10 @@ -use ruff_python_ast::{self as ast, Expr}; - use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::Expr; use ruff_text_size::Ranged; use crate::checkers::ast::Checker; +use crate::importer::ImportRequest; use crate::registry::AsRule; /// ## What it does @@ -77,21 +77,15 @@ pub(crate) fn deprecated_function(checker: &mut Checker, expr: &Expr) { expr.range(), ); if checker.patch(diagnostic.kind.rule()) { - match expr { - Expr::Name(_) => { - diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - replacement.to_string(), - expr.range(), - ))); - } - Expr::Attribute(ast::ExprAttribute { attr, .. }) => { - diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - replacement.to_string(), - attr.range(), - ))); - } - _ => {} - } + diagnostic.try_set_fix(|| { + let (import_edit, binding) = checker.importer().get_or_import_symbol( + &ImportRequest::import_from("numpy", replacement), + expr.start(), + checker.semantic(), + )?; + let replacement_edit = Edit::range_replacement(binding, expr.range()); + Ok(Fix::suggested_edits(import_edit, [replacement_edit])) + }); } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs b/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs index 3fcba94b3f..fe24ec08dd 100644 --- a/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs +++ b/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs @@ -1,7 +1,6 @@ -use ruff_python_ast::Expr; - -use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; +use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::Expr; use ruff_text_size::Ranged; use crate::checkers::ast::Checker; @@ -34,16 +33,18 @@ pub struct NumpyDeprecatedTypeAlias { type_name: String, } -impl AlwaysAutofixableViolation for NumpyDeprecatedTypeAlias { +impl Violation for NumpyDeprecatedTypeAlias { + const AUTOFIX: AutofixKind = AutofixKind::Sometimes; + #[derive_message_formats] fn message(&self) -> String { let NumpyDeprecatedTypeAlias { type_name } = self; format!("Type alias `np.{type_name}` is deprecated, replace with builtin type") } - fn autofix_title(&self) -> String { + fn autofix_title(&self) -> Option { let NumpyDeprecatedTypeAlias { type_name } = self; - format!("Replace `np.{type_name}` with builtin type") + Some(format!("Replace `np.{type_name}` with builtin type")) } } @@ -73,15 +74,17 @@ pub(crate) fn deprecated_type_alias(checker: &mut Checker, expr: &Expr) { expr.range(), ); if checker.patch(diagnostic.kind.rule()) { - diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - match type_name { - "unicode" => "str", - "long" => "int", - _ => type_name, - } - .to_string(), - expr.range(), - ))); + let type_name = match type_name { + "unicode" => "str", + "long" => "int", + _ => type_name, + }; + if checker.semantic().is_builtin(type_name) { + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( + type_name.to_string(), + expr.range(), + ))); + } } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap index 1165e5f488..a1593e920e 100644 --- a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap +++ b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap @@ -1,201 +1,225 @@ --- source: crates/ruff/src/rules/numpy/mod.rs --- -NPY003.py:3:1: NPY003 [*] `np.round_` is deprecated; use `np.round` instead +NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead | -1 | import numpy as np -2 | -3 | np.round_(np.random.rand(5, 5), 2) - | ^^^^^^^^^ NPY003 -4 | np.product(np.random.rand(5, 5)) -5 | np.cumproduct(np.random.rand(5, 5)) +2 | import numpy as np +3 | +4 | np.round_(np.random.rand(5, 5), 2) + | ^^^^^^^^^ NPY003 +5 | np.product(np.random.rand(5, 5)) +6 | np.cumproduct(np.random.rand(5, 5)) | = help: Replace with `np.round` ℹ Suggested fix -1 1 | import numpy as np -2 2 | -3 |-np.round_(np.random.rand(5, 5), 2) - 3 |+np.round(np.random.rand(5, 5), 2) -4 4 | np.product(np.random.rand(5, 5)) -5 5 | np.cumproduct(np.random.rand(5, 5)) -6 6 | np.sometrue(np.random.rand(5, 5)) +1 1 | def func(): +2 2 | import numpy as np +3 3 | +4 |- np.round_(np.random.rand(5, 5), 2) + 4 |+ np.round(np.random.rand(5, 5), 2) +5 5 | np.product(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) -NPY003.py:4:1: NPY003 [*] `np.product` is deprecated; use `np.prod` instead +NPY003.py:5:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead | -3 | np.round_(np.random.rand(5, 5), 2) -4 | np.product(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 -5 | np.cumproduct(np.random.rand(5, 5)) -6 | np.sometrue(np.random.rand(5, 5)) +4 | np.round_(np.random.rand(5, 5), 2) +5 | np.product(np.random.rand(5, 5)) + | ^^^^^^^^^^ NPY003 +6 | np.cumproduct(np.random.rand(5, 5)) +7 | np.sometrue(np.random.rand(5, 5)) | = help: Replace with `np.prod` ℹ Suggested fix -1 1 | import numpy as np -2 2 | -3 3 | np.round_(np.random.rand(5, 5), 2) -4 |-np.product(np.random.rand(5, 5)) - 4 |+np.prod(np.random.rand(5, 5)) -5 5 | np.cumproduct(np.random.rand(5, 5)) -6 6 | np.sometrue(np.random.rand(5, 5)) -7 7 | np.alltrue(np.random.rand(5, 5)) +2 2 | import numpy as np +3 3 | +4 4 | np.round_(np.random.rand(5, 5), 2) +5 |- np.product(np.random.rand(5, 5)) + 5 |+ np.prod(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) +8 8 | np.alltrue(np.random.rand(5, 5)) -NPY003.py:5:1: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead +NPY003.py:6:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead | -3 | np.round_(np.random.rand(5, 5), 2) -4 | np.product(np.random.rand(5, 5)) -5 | np.cumproduct(np.random.rand(5, 5)) - | ^^^^^^^^^^^^^ NPY003 -6 | np.sometrue(np.random.rand(5, 5)) -7 | np.alltrue(np.random.rand(5, 5)) +4 | np.round_(np.random.rand(5, 5), 2) +5 | np.product(np.random.rand(5, 5)) +6 | np.cumproduct(np.random.rand(5, 5)) + | ^^^^^^^^^^^^^ NPY003 +7 | np.sometrue(np.random.rand(5, 5)) +8 | np.alltrue(np.random.rand(5, 5)) | = help: Replace with `np.cumprod` ℹ Suggested fix -2 2 | -3 3 | np.round_(np.random.rand(5, 5), 2) -4 4 | np.product(np.random.rand(5, 5)) -5 |-np.cumproduct(np.random.rand(5, 5)) - 5 |+np.cumprod(np.random.rand(5, 5)) -6 6 | np.sometrue(np.random.rand(5, 5)) -7 7 | np.alltrue(np.random.rand(5, 5)) -8 8 | +3 3 | +4 4 | np.round_(np.random.rand(5, 5), 2) +5 5 | np.product(np.random.rand(5, 5)) +6 |- np.cumproduct(np.random.rand(5, 5)) + 6 |+ np.cumprod(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) +8 8 | np.alltrue(np.random.rand(5, 5)) +9 9 | -NPY003.py:6:1: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead +NPY003.py:7:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead | -4 | np.product(np.random.rand(5, 5)) -5 | np.cumproduct(np.random.rand(5, 5)) -6 | np.sometrue(np.random.rand(5, 5)) - | ^^^^^^^^^^^ NPY003 -7 | np.alltrue(np.random.rand(5, 5)) +5 | np.product(np.random.rand(5, 5)) +6 | np.cumproduct(np.random.rand(5, 5)) +7 | np.sometrue(np.random.rand(5, 5)) + | ^^^^^^^^^^^ NPY003 +8 | np.alltrue(np.random.rand(5, 5)) | = help: Replace with `np.any` ℹ Suggested fix -3 3 | np.round_(np.random.rand(5, 5), 2) -4 4 | np.product(np.random.rand(5, 5)) -5 5 | np.cumproduct(np.random.rand(5, 5)) -6 |-np.sometrue(np.random.rand(5, 5)) - 6 |+np.any(np.random.rand(5, 5)) -7 7 | np.alltrue(np.random.rand(5, 5)) -8 8 | -9 9 | from numpy import round_, product, cumproduct, sometrue, alltrue +4 4 | np.round_(np.random.rand(5, 5), 2) +5 5 | np.product(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 |- np.sometrue(np.random.rand(5, 5)) + 7 |+ np.any(np.random.rand(5, 5)) +8 8 | np.alltrue(np.random.rand(5, 5)) +9 9 | +10 10 | -NPY003.py:7:1: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead +NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead | -5 | np.cumproduct(np.random.rand(5, 5)) -6 | np.sometrue(np.random.rand(5, 5)) -7 | np.alltrue(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 -8 | -9 | from numpy import round_, product, cumproduct, sometrue, alltrue +6 | np.cumproduct(np.random.rand(5, 5)) +7 | np.sometrue(np.random.rand(5, 5)) +8 | np.alltrue(np.random.rand(5, 5)) + | ^^^^^^^^^^ NPY003 | = help: Replace with `np.all` ℹ Suggested fix -4 4 | np.product(np.random.rand(5, 5)) -5 5 | np.cumproduct(np.random.rand(5, 5)) -6 6 | np.sometrue(np.random.rand(5, 5)) -7 |-np.alltrue(np.random.rand(5, 5)) - 7 |+np.all(np.random.rand(5, 5)) -8 8 | -9 9 | from numpy import round_, product, cumproduct, sometrue, alltrue +5 5 | np.product(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) +8 |- np.alltrue(np.random.rand(5, 5)) + 8 |+ np.all(np.random.rand(5, 5)) +9 9 | 10 10 | +11 11 | def func(): -NPY003.py:11:1: NPY003 [*] `np.round_` is deprecated; use `np.round` instead +NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead | - 9 | from numpy import round_, product, cumproduct, sometrue, alltrue -10 | -11 | round_(np.random.rand(5, 5), 2) - | ^^^^^^ NPY003 -12 | product(np.random.rand(5, 5)) -13 | cumproduct(np.random.rand(5, 5)) +12 | from numpy import round_, product, cumproduct, sometrue, alltrue +13 | +14 | round_(np.random.rand(5, 5), 2) + | ^^^^^^ NPY003 +15 | product(np.random.rand(5, 5)) +16 | cumproduct(np.random.rand(5, 5)) | = help: Replace with `np.round` ℹ Suggested fix -8 8 | -9 9 | from numpy import round_, product, cumproduct, sometrue, alltrue -10 10 | -11 |-round_(np.random.rand(5, 5), 2) - 11 |+round(np.random.rand(5, 5), 2) -12 12 | product(np.random.rand(5, 5)) -13 13 | cumproduct(np.random.rand(5, 5)) -14 14 | sometrue(np.random.rand(5, 5)) + 1 |+from numpy import round +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +11 12 | def func(): +12 13 | from numpy import round_, product, cumproduct, sometrue, alltrue +13 14 | +14 |- round_(np.random.rand(5, 5), 2) + 15 |+ round(np.random.rand(5, 5), 2) +15 16 | product(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) -NPY003.py:12:1: NPY003 [*] `np.product` is deprecated; use `np.prod` instead +NPY003.py:15:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead | -11 | round_(np.random.rand(5, 5), 2) -12 | product(np.random.rand(5, 5)) - | ^^^^^^^ NPY003 -13 | cumproduct(np.random.rand(5, 5)) -14 | sometrue(np.random.rand(5, 5)) +14 | round_(np.random.rand(5, 5), 2) +15 | product(np.random.rand(5, 5)) + | ^^^^^^^ NPY003 +16 | cumproduct(np.random.rand(5, 5)) +17 | sometrue(np.random.rand(5, 5)) | = help: Replace with `np.prod` ℹ Suggested fix -9 9 | from numpy import round_, product, cumproduct, sometrue, alltrue -10 10 | -11 11 | round_(np.random.rand(5, 5), 2) -12 |-product(np.random.rand(5, 5)) - 12 |+prod(np.random.rand(5, 5)) -13 13 | cumproduct(np.random.rand(5, 5)) -14 14 | sometrue(np.random.rand(5, 5)) -15 15 | alltrue(np.random.rand(5, 5)) + 1 |+from numpy import prod +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +12 13 | from numpy import round_, product, cumproduct, sometrue, alltrue +13 14 | +14 15 | round_(np.random.rand(5, 5), 2) +15 |- product(np.random.rand(5, 5)) + 16 |+ prod(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) +18 19 | alltrue(np.random.rand(5, 5)) -NPY003.py:13:1: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead +NPY003.py:16:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead | -11 | round_(np.random.rand(5, 5), 2) -12 | product(np.random.rand(5, 5)) -13 | cumproduct(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 -14 | sometrue(np.random.rand(5, 5)) -15 | alltrue(np.random.rand(5, 5)) +14 | round_(np.random.rand(5, 5), 2) +15 | product(np.random.rand(5, 5)) +16 | cumproduct(np.random.rand(5, 5)) + | ^^^^^^^^^^ NPY003 +17 | sometrue(np.random.rand(5, 5)) +18 | alltrue(np.random.rand(5, 5)) | = help: Replace with `np.cumprod` ℹ Suggested fix -10 10 | -11 11 | round_(np.random.rand(5, 5), 2) -12 12 | product(np.random.rand(5, 5)) -13 |-cumproduct(np.random.rand(5, 5)) - 13 |+cumprod(np.random.rand(5, 5)) -14 14 | sometrue(np.random.rand(5, 5)) -15 15 | alltrue(np.random.rand(5, 5)) + 1 |+from numpy import cumprod +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +13 14 | +14 15 | round_(np.random.rand(5, 5), 2) +15 16 | product(np.random.rand(5, 5)) +16 |- cumproduct(np.random.rand(5, 5)) + 17 |+ cumprod(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) +18 19 | alltrue(np.random.rand(5, 5)) -NPY003.py:14:1: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead +NPY003.py:17:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead | -12 | product(np.random.rand(5, 5)) -13 | cumproduct(np.random.rand(5, 5)) -14 | sometrue(np.random.rand(5, 5)) - | ^^^^^^^^ NPY003 -15 | alltrue(np.random.rand(5, 5)) +15 | product(np.random.rand(5, 5)) +16 | cumproduct(np.random.rand(5, 5)) +17 | sometrue(np.random.rand(5, 5)) + | ^^^^^^^^ NPY003 +18 | alltrue(np.random.rand(5, 5)) | = help: Replace with `np.any` ℹ Suggested fix -11 11 | round_(np.random.rand(5, 5), 2) -12 12 | product(np.random.rand(5, 5)) -13 13 | cumproduct(np.random.rand(5, 5)) -14 |-sometrue(np.random.rand(5, 5)) - 14 |+any(np.random.rand(5, 5)) -15 15 | alltrue(np.random.rand(5, 5)) + 1 |+from numpy import any +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +14 15 | round_(np.random.rand(5, 5), 2) +15 16 | product(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 |- sometrue(np.random.rand(5, 5)) + 18 |+ any(np.random.rand(5, 5)) +18 19 | alltrue(np.random.rand(5, 5)) -NPY003.py:15:1: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead +NPY003.py:18:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead | -13 | cumproduct(np.random.rand(5, 5)) -14 | sometrue(np.random.rand(5, 5)) -15 | alltrue(np.random.rand(5, 5)) - | ^^^^^^^ NPY003 +16 | cumproduct(np.random.rand(5, 5)) +17 | sometrue(np.random.rand(5, 5)) +18 | alltrue(np.random.rand(5, 5)) + | ^^^^^^^ NPY003 | = help: Replace with `np.all` ℹ Suggested fix -12 12 | product(np.random.rand(5, 5)) -13 13 | cumproduct(np.random.rand(5, 5)) -14 14 | sometrue(np.random.rand(5, 5)) -15 |-alltrue(np.random.rand(5, 5)) - 15 |+all(np.random.rand(5, 5)) + 1 |+from numpy import all +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +15 16 | product(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) +18 |- alltrue(np.random.rand(5, 5)) + 19 |+ all(np.random.rand(5, 5)) diff --git a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap index ce05756d93..6326a97859 100644 --- a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap +++ b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap @@ -129,6 +129,8 @@ NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with buil 19 | 20 | _ = arr.astype(np.int) | ^^^^^^ NPY001 +21 | +22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 | = help: Replace `np.int` with builtin type @@ -138,5 +140,17 @@ NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with buil 19 19 | 20 |-_ = arr.astype(np.int) 20 |+_ = arr.astype(int) +21 21 | +22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 +23 23 | from numpy import float + +NPY001.py:25:1: NPY001 Type alias `np.float` is deprecated, replace with builtin type + | +23 | from numpy import float +24 | +25 | float(1) + | ^^^^^ NPY001 + | + = help: Replace `np.float` with builtin type diff --git a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs index a7d9dc9f7e..0c88965082 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; -use ruff_python_ast::{self as ast, Keyword}; +use ruff_python_ast::parenthesize::parenthesized_range; +use ruff_python_ast::{self as ast, Keyword, Stmt}; use ruff_source_file::Locator; use ruff_text_size::Ranged; @@ -75,13 +76,17 @@ pub(crate) fn inplace_argument(checker: &mut Checker, call: &ast::ExprCall) { // the star argument _doesn't_ contain an override). // 2. The call is part of a larger expression (we're converting an expression to a // statement, and expressions can't contain statements). + let statement = checker.semantic().current_statement(); if !seen_star - && checker.semantic().current_statement().is_expr_stmt() && checker.semantic().current_expression_parent().is_none() + && statement.is_expr_stmt() { - if let Some(fix) = - convert_inplace_argument_to_assignment(call, keyword, checker.locator()) - { + if let Some(fix) = convert_inplace_argument_to_assignment( + call, + keyword, + statement, + checker.locator(), + ) { diagnostic.set_fix(fix); } } @@ -101,13 +106,16 @@ pub(crate) fn inplace_argument(checker: &mut Checker, call: &ast::ExprCall) { fn convert_inplace_argument_to_assignment( call: &ast::ExprCall, keyword: &Keyword, + statement: &Stmt, locator: &Locator, ) -> Option { // Add the assignment. let attr = call.func.as_attribute_expr()?; let insert_assignment = Edit::insertion( format!("{name} = ", name = locator.slice(attr.value.range())), - call.start(), + parenthesized_range(call.into(), statement.into(), locator.contents()) + .unwrap_or(call.range()) + .start(), ); // Remove the `inplace` argument. diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap index 513c426e64..a57280c4ba 100644 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -158,4 +158,20 @@ PD002.py:28:38: PD002 `inplace=True` should be avoided; it has inconsistent beha | = help: Assign to variable; remove `inplace` arg +PD002.py:33:24: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call +32 | +33 | (x.drop(["a"], axis=1, inplace=True)) + | ^^^^^^^^^^^^ PD002 + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +30 30 | +31 31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call +32 32 | +33 |-(x.drop(["a"], axis=1, inplace=True)) + 33 |+x = (x.drop(["a"], axis=1)) + diff --git a/crates/ruff/src/rules/pep8_naming/helpers.rs b/crates/ruff/src/rules/pep8_naming/helpers.rs index ac23f6c511..6d09971253 100644 --- a/crates/ruff/src/rules/pep8_naming/helpers.rs +++ b/crates/ruff/src/rules/pep8_naming/helpers.rs @@ -22,6 +22,7 @@ pub(super) fn is_acronym(name: &str, asname: &str) -> bool { name.chars().filter(|c| c.is_uppercase()).join("") == asname } +/// Returns `true` if the statement is an assignment to a named tuple. pub(super) fn is_named_tuple_assignment(stmt: &Stmt, semantic: &SemanticModel) -> bool { let Stmt::Assign(ast::StmtAssign { value, .. }) = stmt else { return false; @@ -30,13 +31,12 @@ pub(super) fn is_named_tuple_assignment(stmt: &Stmt, semantic: &SemanticModel) - return false; }; semantic.resolve_call_path(func).is_some_and(|call_path| { - matches!( - call_path.as_slice(), - ["collections", "namedtuple"] | ["typing", "NamedTuple"] - ) + matches!(call_path.as_slice(), ["collections", "namedtuple"]) + || semantic.match_typing_call_path(&call_path, "NamedTuple") }) } +/// Returns `true` if the statement is an assignment to a `TypedDict`. pub(super) fn is_typed_dict_assignment(stmt: &Stmt, semantic: &SemanticModel) -> bool { let Stmt::Assign(ast::StmtAssign { value, .. }) = stmt else { return false; @@ -44,11 +44,10 @@ pub(super) fn is_typed_dict_assignment(stmt: &Stmt, semantic: &SemanticModel) -> let Expr::Call(ast::ExprCall { func, .. }) = value.as_ref() else { return false; }; - semantic - .resolve_call_path(func) - .is_some_and(|call_path| matches!(call_path.as_slice(), ["typing", "TypedDict"])) + semantic.match_typing_expr(func, "TypedDict") } +/// Returns `true` if the statement is an assignment to a `TypeVar` or `NewType`. pub(super) fn is_type_var_assignment(stmt: &Stmt, semantic: &SemanticModel) -> bool { let Stmt::Assign(ast::StmtAssign { value, .. }) = stmt else { return false; @@ -56,9 +55,18 @@ pub(super) fn is_type_var_assignment(stmt: &Stmt, semantic: &SemanticModel) -> b let Expr::Call(ast::ExprCall { func, .. }) = value.as_ref() else { return false; }; - semantic - .resolve_call_path(func) - .is_some_and(|call_path| matches!(call_path.as_slice(), ["typing", "TypeVar" | "NewType"])) + semantic.resolve_call_path(func).is_some_and(|call_path| { + semantic.match_typing_call_path(&call_path, "TypeVar") + || semantic.match_typing_call_path(&call_path, "NewType") + }) +} + +/// Returns `true` if the statement is an assignment to a `TypeAlias`. +pub(super) fn is_type_alias_assignment(stmt: &Stmt, semantic: &SemanticModel) -> bool { + let Stmt::AnnAssign(ast::StmtAnnAssign { annotation, .. }) = stmt else { + return false; + }; + semantic.match_typing_expr(annotation, "TypeAlias") } pub(super) fn is_typed_dict_class(arguments: Option<&Arguments>, semantic: &SemanticModel) -> bool { diff --git a/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs b/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs index 9cbb325e53..e8bae1c0ee 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs @@ -70,6 +70,7 @@ pub(crate) fn non_lowercase_variable_in_function(checker: &mut Checker, expr: &E if helpers::is_named_tuple_assignment(parent, checker.semantic()) || helpers::is_typed_dict_assignment(parent, checker.semantic()) || helpers::is_type_var_assignment(parent, checker.semantic()) + || helpers::is_type_alias_assignment(parent, checker.semantic()) { return; } diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap index dc5a0080a2..f2a3d321b4 100644 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap +++ b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap @@ -1,23 +1,23 @@ --- source: crates/ruff/src/rules/pep8_naming/mod.rs --- -N806.py:14:5: N806 Variable `Camel` in function should be lowercase +N806.py:12:5: N806 Variable `Camel` in function should be lowercase | -12 | GLOBAL = "bar" -13 | lower = 0 -14 | Camel = 0 +10 | GLOBAL = "bar" +11 | lower = 0 +12 | Camel = 0 | ^^^^^ N806 -15 | CONSTANT = 0 -16 | _ = 0 +13 | CONSTANT = 0 +14 | _ = 0 | -N806.py:15:5: N806 Variable `CONSTANT` in function should be lowercase +N806.py:13:5: N806 Variable `CONSTANT` in function should be lowercase | -13 | lower = 0 -14 | Camel = 0 -15 | CONSTANT = 0 +11 | lower = 0 +12 | Camel = 0 +13 | CONSTANT = 0 | ^^^^^^^^ N806 -16 | _ = 0 +14 | _ = 0 | diff --git a/crates/ruff/src/rules/perflint/rules/manual_list_comprehension.rs b/crates/ruff/src/rules/perflint/rules/manual_list_comprehension.rs index d3d4476b8f..bf04777f79 100644 --- a/crates/ruff/src/rules/perflint/rules/manual_list_comprehension.rs +++ b/crates/ruff/src/rules/perflint/rules/manual_list_comprehension.rs @@ -4,6 +4,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::helpers::any_over_expr; +use ruff_python_semantic::analyze::typing::is_list; +use ruff_python_semantic::Binding; use crate::checkers::ast::Checker; @@ -112,13 +114,6 @@ pub(crate) fn manual_list_comprehension(checker: &mut Checker, target: &Expr, bo return; }; - // Ignore direct list copies (e.g., `for x in y: filtered.append(x)`). - if if_test.is_none() { - if arg.as_name_expr().is_some_and(|arg| arg.id == *id) { - return; - } - } - let Expr::Attribute(ast::ExprAttribute { attr, value, .. }) = func.as_ref() else { return; }; @@ -127,6 +122,13 @@ pub(crate) fn manual_list_comprehension(checker: &mut Checker, target: &Expr, bo return; } + // Ignore direct list copies (e.g., `for x in y: filtered.append(x)`). + if if_test.is_none() { + if arg.as_name_expr().is_some_and(|arg| arg.id == *id) { + return; + } + } + // Avoid, e.g., `for x in y: filtered[x].append(x * x)`. if any_over_expr(value, &|expr| { expr.as_name_expr().is_some_and(|expr| expr.id == *id) @@ -141,6 +143,25 @@ pub(crate) fn manual_list_comprehension(checker: &mut Checker, target: &Expr, bo return; } + // Avoid non-list values. + let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() else { + return; + }; + let bindings: Vec<&Binding> = checker + .semantic() + .current_scope() + .get_all(id) + .map(|binding_id| checker.semantic().binding(binding_id)) + .collect(); + + let [binding] = bindings.as_slice() else { + return; + }; + + if !is_list(binding, checker.semantic()) { + return; + } + // Avoid if the value is used in the conditional test, e.g., // // ```python diff --git a/crates/ruff/src/rules/perflint/rules/manual_list_copy.rs b/crates/ruff/src/rules/perflint/rules/manual_list_copy.rs index 7e12dccf76..39ad7dc059 100644 --- a/crates/ruff/src/rules/perflint/rules/manual_list_copy.rs +++ b/crates/ruff/src/rules/perflint/rules/manual_list_copy.rs @@ -2,6 +2,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::any_over_expr; use ruff_python_ast::{self as ast, Arguments, Expr, Stmt}; +use ruff_python_semantic::analyze::typing::is_list; +use ruff_python_semantic::Binding; use crate::checkers::ast::Checker; @@ -79,11 +81,6 @@ pub(crate) fn manual_list_copy(checker: &mut Checker, target: &Expr, body: &[Stm return; }; - // Only flag direct list copies (e.g., `for x in y: filtered.append(x)`). - if !arg.as_name_expr().is_some_and(|arg| arg.id == *id) { - return; - } - let Expr::Attribute(ast::ExprAttribute { attr, value, .. }) = func.as_ref() else { return; }; @@ -92,6 +89,11 @@ pub(crate) fn manual_list_copy(checker: &mut Checker, target: &Expr, body: &[Stm return; } + // Only flag direct list copies (e.g., `for x in y: filtered.append(x)`). + if !arg.as_name_expr().is_some_and(|arg| arg.id == *id) { + return; + } + // Avoid, e.g., `for x in y: filtered[x].append(x)`. if any_over_expr(value, &|expr| { expr.as_name_expr().is_some_and(|expr| expr.id == *id) @@ -99,6 +101,25 @@ pub(crate) fn manual_list_copy(checker: &mut Checker, target: &Expr, body: &[Stm return; } + // Avoid non-list values. + let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() else { + return; + }; + let bindings: Vec<&Binding> = checker + .semantic() + .current_scope() + .get_all(id) + .map(|binding_id| checker.semantic().binding(binding_id)) + .collect(); + + let [binding] = bindings.as_slice() else { + return; + }; + + if !is_list(binding, checker.semantic()) { + return; + } + checker .diagnostics .push(Diagnostic::new(ManualListCopy, *range)); diff --git a/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs b/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs index 286344a7ca..8cf0466c5c 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs @@ -1,10 +1,12 @@ use memchr::memchr_iter; -use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::str::{leading_quote, trailing_quote}; use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; + +use crate::autofix::edits::pad_start; /// ## What it does /// Checks for invalid escape sequences. @@ -138,18 +140,8 @@ pub(crate) fn invalid_escape_sequence( // If necessary, add a space between any leading keyword (`return`, `yield`, // `assert`, etc.) and the string. For example, `return"foo"` is valid, but // `returnr"foo"` is not. - let requires_space = locator - .slice(TextRange::up_to(range.start())) - .chars() - .last() - .is_some_and(|char| char.is_ascii_alphabetic()); - diagnostic.set_fix(Fix::automatic(Edit::insertion( - if requires_space { - " r".to_string() - } else { - "r".to_string() - }, + pad_start("r".to_string(), range.start(), locator), range.start(), ))); } diff --git a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs b/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs index 1d8885b115..20536c4125 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs @@ -172,7 +172,6 @@ pub(crate) fn literal_comparisons(checker: &mut Checker, compare: &ast::ExprComp if checker.enabled(Rule::TrueFalseComparison) { if let Expr::Constant(ast::ExprConstant { value: Constant::Bool(value), - kind: None, range: _, }) = comparator { @@ -241,7 +240,6 @@ pub(crate) fn literal_comparisons(checker: &mut Checker, compare: &ast::ExprComp if checker.enabled(Rule::TrueFalseComparison) { if let Expr::Constant(ast::ExprConstant { value: Constant::Bool(value), - kind: None, range: _, }) = next { diff --git a/crates/ruff/src/rules/pycodestyle/rules/mod.rs b/crates/ruff/src/rules/pycodestyle/rules/mod.rs index c9fceb87a6..33b8cc4960 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/mod.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/mod.rs @@ -4,8 +4,8 @@ pub(crate) use ambiguous_variable_name::*; pub(crate) use bare_except::*; pub(crate) use compound_statements::*; pub(crate) use doc_line_too_long::*; -pub use errors::IOError; pub(crate) use errors::*; +pub use errors::{IOError, SyntaxError}; pub(crate) use imports::*; pub(crate) use invalid_escape_sequence::*; diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap index 39603bd0c2..976423061a 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap @@ -339,6 +339,8 @@ E731.py:139:5: E731 [*] Do not assign a `lambda` expression, use a `def` 139 |+ def CELSIUS(deg_c): 140 |+ return deg_c 140 141 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) +141 142 | +142 143 | E731.py:140:5: E731 [*] Do not assign a `lambda` expression, use a `def` | @@ -356,5 +358,30 @@ E731.py:140:5: E731 [*] Do not assign a `lambda` expression, use a `def` 140 |- FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) 140 |+ def FAHRENHEIT(deg_c): 141 |+ return deg_c * 9 / 5 + 32 +141 142 | +142 143 | +143 144 | # Regression test for: https://github.com/astral-sh/ruff/issues/7141 + +E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +145 | # E731 +146 | +147 | f = lambda: ( + | _____^ +148 | | i := 1, +149 | | ) + | |_____^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +144 144 | def scope(): +145 145 | # E731 +146 146 | +147 |- f = lambda: ( +148 |- i := 1, +149 |- ) + 147 |+ def f(): + 148 |+ return (i := 1), diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs index d57c5183a9..2df31e3fe5 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_trivia::PythonWhitespace; -use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines}; +use ruff_python_trivia::{indentation_at_offset, PythonWhitespace}; +use ruff_source_file::{Line, UniversalNewlineIterator}; use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; @@ -216,25 +216,61 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr } if checker.enabled(Rule::OneBlankLineAfterClass) { - let after_range = TextRange::new(docstring.end(), class.end()); + let class_after_docstring_range = TextRange::new(docstring.end(), class.end()); + let class_after_docstring = checker.locator().slice(class_after_docstring_range); + let mut lines = UniversalNewlineIterator::with_offset( + class_after_docstring, + class_after_docstring_range.start(), + ); - let after = checker.locator().slice(after_range); - - let all_blank_after = after.universal_newlines().skip(1).all(|line| { + // If the class is empty except for comments, we don't need to insert a newline between + // docstring and no content + let all_blank_after = lines.clone().all(|line| { line.trim_whitespace().is_empty() || line.trim_whitespace_start().starts_with('#') }); if all_blank_after { return; } - let mut lines = UniversalNewlineIterator::with_offset(after, after_range.start()); + let first_line = lines.next(); + let mut replacement_start = first_line.as_ref().map(Line::start).unwrap_or_default(); + + // Edge case: There is trailing end-of-line content after the docstring, either a statement + // separated by a semicolon or a comment. + if let Some(first_line) = &first_line { + let trailing = first_line.as_str().trim_whitespace_start(); + if let Some(next_statement) = trailing.strip_prefix(';') { + let indentation = indentation_at_offset(docstring.start(), checker.locator()) + .expect("Own line docstring must have indentation"); + let mut diagnostic = Diagnostic::new(OneBlankLineAfterClass, docstring.range()); + if checker.patch(diagnostic.kind.rule()) { + let line_ending = checker.stylist().line_ending().as_str(); + // We have to trim the whitespace twice, once before the semicolon above and + // once after the semicolon here, or we get invalid indents: + // ```rust + // class Priority: + // """Has priorities""" ; priorities=1 + // ``` + let next_statement = next_statement.trim_whitespace_start(); + diagnostic.set_fix(Fix::automatic(Edit::replacement( + line_ending.to_string() + line_ending + indentation + next_statement, + replacement_start, + first_line.end(), + ))); + } + checker.diagnostics.push(diagnostic); + return; + } else if trailing.starts_with('#') { + // Keep the end-of-line comment, start counting empty lines after it + replacement_start = first_line.end(); + } + } - let first_line_start = lines.next().map(|l| l.start()).unwrap_or_default(); let mut blank_lines_after = 0usize; - let mut blank_lines_end = docstring.end(); + let mut blank_lines_end = first_line.as_ref().map_or(docstring.end(), Line::end); for line in lines { - if line.trim().is_empty() { + if line.trim_whitespace().is_empty() { blank_lines_end = line.end(); blank_lines_after += 1; } else { @@ -248,7 +284,7 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr // Insert a blank line before the class (replacing any existing lines). diagnostic.set_fix(Fix::automatic(Edit::replacement( checker.stylist().line_ending().to_string(), - first_line_start, + replacement_start, blank_lines_end, ))); } diff --git a/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs b/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs index 65cea763f0..57c2b63fd0 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs @@ -90,13 +90,21 @@ pub(crate) fn ends_with_period(checker: &mut Checker, docstring: &Docstring) { let line = lines.nth(index).unwrap(); let trimmed = line.trim_end(); + if trimmed.ends_with('\\') { + // Ignore the edge case whether a single quoted string is multiple lines through an + // escape (https://github.com/astral-sh/ruff/issues/7139). Single quote docstrings are + // flagged by D300. + // ```python + // "\ + // " + // ``` + return; + } + if !trimmed.ends_with('.') { let mut diagnostic = Diagnostic::new(EndsInPeriod, docstring.range()); // Best-effort autofix: avoid adding a period after other punctuation marks. - if checker.patch(diagnostic.kind.rule()) - && !trimmed.ends_with(':') - && !trimmed.ends_with(';') - { + if checker.patch(diagnostic.kind.rule()) && !trimmed.ends_with([':', ';']) { diagnostic.set_fix(Fix::suggested(Edit::insertion( ".".to_string(), line.start() + trimmed.text_len(), diff --git a/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs b/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs index 39b42105d5..05ec17ddb1 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs @@ -89,6 +89,17 @@ pub(crate) fn ends_with_punctuation(checker: &mut Checker, docstring: &Docstring let line = lines.next().unwrap(); let trimmed = line.trim_end(); + if trimmed.ends_with('\\') { + // Ignore the edge case whether a single quoted string is multiple lines through an + // escape (https://github.com/astral-sh/ruff/issues/7139). Single quote docstrings are + // flagged by D300. + // ```python + // "\ + // " + // ``` + return; + } + if !trimmed.ends_with(['.', '!', '?']) { let mut diagnostic = Diagnostic::new(EndsInPunctuation, docstring.range()); // Best-effort autofix: avoid adding a period after other punctuation marks. diff --git a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs b/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs index f78caf5987..27c5804928 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs @@ -151,6 +151,15 @@ pub(crate) fn multi_line_summary_start(checker: &mut Checker, docstring: &Docstr } checker.diagnostics.push(diagnostic); } + } else if first_line.as_str().ends_with('\\') { + // Ignore the edge case whether a single quoted string is multiple lines through an + // escape (https://github.com/astral-sh/ruff/issues/7139). Single quote docstrings are + // flagged by D300. + // ```python + // "\ + // " + // ``` + return; } else { if checker.enabled(Rule::MultiLineSummarySecondLine) { let mut diagnostic = Diagnostic::new(MultiLineSummarySecondLine, docstring.range()); diff --git a/crates/ruff/src/rules/pydocstyle/rules/sections.rs b/crates/ruff/src/rules/pydocstyle/rules/sections.rs index 5303b77a77..34f78655c8 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/sections.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/sections.rs @@ -1377,9 +1377,7 @@ fn blanks_and_section_underline( } if let Some(non_blank_line) = following_lines.next() { - let dash_line_found = non_blank_line - .chars() - .all(|char| char.is_whitespace() || char == '-'); + let dash_line_found = is_dashed_underline(&non_blank_line); if dash_line_found { if blank_lines_after_header > 0 { @@ -1693,7 +1691,10 @@ fn common_section( } if checker.enabled(Rule::NoBlankLineBeforeSection) { - if !context.previous_line().is_some_and(str::is_empty) { + if !context + .previous_line() + .is_some_and(|line| line.trim().is_empty()) + { let mut diagnostic = Diagnostic::new( NoBlankLineBeforeSection { name: context.section_name().to_string(), @@ -1798,7 +1799,9 @@ fn args_section(context: &SectionContext) -> FxHashSet { let relevant_lines = std::iter::once(first_line) .chain(following_lines) .map(|l| l.as_str()) - .filter(|line| line.starts_with(leading_space) || line.is_empty()) + .filter(|line| { + line.is_empty() || (line.starts_with(leading_space) && !is_dashed_underline(line)) + }) .join("\n"); let args_content = dedent(&relevant_lines); @@ -1989,3 +1992,8 @@ fn parse_google_sections( } } } + +fn is_dashed_underline(line: &str) -> bool { + let trimmed_line = line.trim(); + !trimmed_line.is_empty() && trimmed_line.chars().all(|char| char == '-') +} diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap index 9a6eeb820b..557a1a840c 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap @@ -25,4 +25,22 @@ D.py:68:9: D102 Missing docstring in public method 69 | pass | +D.py:650:9: D102 Missing docstring in public method + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 +650 | def sort_services(self): + | ^^^^^^^^^^^^^ D102 +651 | pass + | + +D.py:659:9: D102 Missing docstring in public method + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 +659 | def sort_services(self): + | ^^^^^^^^^^^^^ D102 +660 | pass + | + diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap index 0adf91a9b6..0d1feaafc6 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap @@ -97,4 +97,16 @@ D.py:624:5: D200 One-line docstring should fit on one line | = help: Reformat to one line +D.py:645:5: D200 One-line docstring should fit on one line + | +644 | def single_line_docstring_with_an_escaped_backslash(): +645 | "\ + | _____^ +646 | | " + | |_____^ D200 +647 | +648 | class StatementOnSameLineAsDocstring: + | + = help: Reformat to one line + diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap index 154bcd0e52..214a5f0424 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap @@ -63,4 +63,59 @@ D.py:526:5: D203 [*] 1 blank line required before class docstring 527 528 | 528 529 | Parameters +D.py:649:5: D203 [*] 1 blank line required before class docstring + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 +650 | def sort_services(self): +651 | pass + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +646 646 | " +647 647 | +648 648 | class StatementOnSameLineAsDocstring: + 649 |+ +649 650 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 +650 651 | def sort_services(self): +651 652 | pass + +D.py:654:5: D203 [*] 1 blank line required before class docstring + | +653 | class StatementOnSameLineAsDocstring: +654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +651 651 | pass +652 652 | +653 653 | class StatementOnSameLineAsDocstring: + 654 |+ +654 655 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 +655 656 | +656 657 | + +D.py:658:5: D203 [*] 1 blank line required before class docstring + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 +659 | def sort_services(self): +660 | pass + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +655 655 | +656 656 | +657 657 | class CommentAfterDocstring: + 658 |+ +658 659 | "After this docstring there's a comment." # priorities=1 +659 660 | def sort_services(self): +660 661 | pass + diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap index 3d7025563d..3d0d0384e9 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap @@ -38,4 +38,64 @@ D.py:192:5: D204 [*] 1 blank line required after class docstring 194 195 | 195 196 | +D.py:649:5: D204 [*] 1 blank line required after class docstring + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 +650 | def sort_services(self): +651 | pass + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +646 646 | " +647 647 | +648 648 | class StatementOnSameLineAsDocstring: +649 |- "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + 649 |+ "After this docstring there's another statement on the same line separated by a semicolon." + 650 |+ + 651 |+ priorities=1 +650 652 | def sort_services(self): +651 653 | pass +652 654 | + +D.py:654:5: D204 [*] 1 blank line required after class docstring + | +653 | class StatementOnSameLineAsDocstring: +654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +651 651 | pass +652 652 | +653 653 | class StatementOnSameLineAsDocstring: +654 |- "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + 654 |+ "After this docstring there's another statement on the same line separated by a semicolon." + 655 |+ + 656 |+ priorities=1 +655 657 | +656 658 | +657 659 | class CommentAfterDocstring: + +D.py:658:5: D204 [*] 1 blank line required after class docstring + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 +659 | def sort_services(self): +660 | pass + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +656 656 | +657 657 | class CommentAfterDocstring: +658 658 | "After this docstring there's a comment." # priorities=1 + 659 |+ +659 660 | def sort_services(self): +660 661 | pass + diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap index a65966e43e..33ff3d12f9 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap @@ -41,4 +41,40 @@ D.py:328:5: D300 Use triple double quotes `"""` | ^^^^^^^^^^^^ D300 | +D.py:645:5: D300 Use triple double quotes `"""` + | +644 | def single_line_docstring_with_an_escaped_backslash(): +645 | "\ + | _____^ +646 | | " + | |_____^ D300 +647 | +648 | class StatementOnSameLineAsDocstring: + | + +D.py:649:5: D300 Use triple double quotes `"""` + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 +650 | def sort_services(self): +651 | pass + | + +D.py:654:5: D300 Use triple double quotes `"""` + | +653 | class StatementOnSameLineAsDocstring: +654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 + | + +D.py:658:5: D300 Use triple double quotes `"""` + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 +659 | def sort_services(self): +660 | pass + | + diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap index 3b92b97fd1..45481187d8 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap @@ -289,6 +289,7 @@ D.py:639:17: D400 [*] First line should end with a period 639 |+class SameLine: """This is a docstring on the same line.""" 640 640 | 641 641 | def same_line(): """This is a docstring on the same line""" +642 642 | D.py:641:18: D400 [*] First line should end with a period | @@ -305,5 +306,8 @@ D.py:641:18: D400 [*] First line should end with a period 640 640 | 641 |-def same_line(): """This is a docstring on the same line""" 641 |+def same_line(): """This is a docstring on the same line.""" +642 642 | +643 643 | +644 644 | def single_line_docstring_with_an_escaped_backslash(): diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap index f0eac75133..6c296e9ca0 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap @@ -496,5 +496,6 @@ sections.py:527:5: D407 [*] Missing dashed underline after section ("Parameters" 530 |+ ---------- 530 531 | =========== 531 532 | """ +532 533 | diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap index 73725b09cf..a5630beb76 100644 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap +++ b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap @@ -271,6 +271,7 @@ D.py:639:17: D415 [*] First line should end with a period, question mark, or exc 639 |+class SameLine: """This is a docstring on the same line.""" 640 640 | 641 641 | def same_line(): """This is a docstring on the same line""" +642 642 | D.py:641:18: D415 [*] First line should end with a period, question mark, or exclamation point | @@ -287,5 +288,8 @@ D.py:641:18: D415 [*] First line should end with a period, question mark, or exc 640 640 | 641 |-def same_line(): """This is a docstring on the same line""" 641 |+def same_line(): """This is a docstring on the same line.""" +642 642 | +643 643 | +644 644 | def single_line_docstring_with_an_escaped_backslash(): diff --git a/crates/ruff/src/rules/pyflakes/mod.rs b/crates/ruff/src/rules/pyflakes/mod.rs index 8268fc11bf..97ab5d158e 100644 --- a/crates/ruff/src/rules/pyflakes/mod.rs +++ b/crates/ruff/src/rules/pyflakes/mod.rs @@ -27,6 +27,7 @@ mod tests { use crate::registry::{AsRule, Linter, Rule}; use crate::rules::pyflakes; use crate::settings::{flags, Settings}; + use crate::source_kind::SourceKind; use crate::test::{test_path, test_snippet}; use crate::{assert_messages, directives}; @@ -508,6 +509,7 @@ mod tests { fn flakes(contents: &str, expected: &[Rule]) { let contents = dedent(contents); let source_type = PySourceType::default(); + let source_kind = SourceKind::Python(contents.to_string()); let settings = Settings::for_rules(Linter::Pyflakes.rules()); let tokens: Vec = ruff_python_parser::tokenize(&contents, source_type.as_mode()); let locator = Locator::new(&contents); @@ -532,7 +534,7 @@ mod tests { &directives, &settings, flags::Noqa::Enabled, - None, + &source_kind, source_type, ); diagnostics.sort_by_key(Ranged::start); diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs b/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs index 4058c3e748..89eebff824 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs @@ -3,6 +3,7 @@ use itertools::Itertools; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::contains_effect; +use ruff_python_ast::parenthesize::parenthesized_range; use ruff_python_ast::{self as ast, PySourceType, Stmt}; use ruff_python_parser::{lexer, AsMode, Tok}; use ruff_python_semantic::{Binding, Scope}; @@ -220,12 +221,20 @@ fn remove_unused_variable(binding: &Binding, checker: &Checker) -> Option { { // If the expression is complex (`x = foo()`), remove the assignment, // but preserve the right-hand side. - let start = target.start(); - let end = - match_token_after(start, checker.locator(), checker.source_type, |tok| { - tok == Tok::Equal - })? - .start(); + let start = parenthesized_range( + target.into(), + statement.into(), + checker.locator().contents(), + ) + .unwrap_or(target.range()) + .start(); + let end = match_token_after( + target.end(), + checker.locator(), + checker.source_type, + |tok| tok == Tok::Equal, + )? + .start(); let edit = Edit::deletion(start, end); Some(Fix::suggested(edit)) } else { diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap index 3ae9fc7308..4968fd1616 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap @@ -248,6 +248,7 @@ F401_0.py:112:16: F401 [*] `b1` imported but unused 112 |- import b1 113 112 | 114 113 | import b2 +115 114 | F401_0.py:114:16: F401 [*] `b2` imported but unused | @@ -263,5 +264,23 @@ F401_0.py:114:16: F401 [*] `b2` imported but unused 112 112 | import b1 113 113 | 114 |- import b2 +115 114 | +116 115 | +117 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7244 + +F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused + | +121 | from datameta_client_lib.model_helpers import ( +122 | noqa ) + | ^^^^ F401 + | + = help: Remove unused import: `datameta_client_lib.model_helpers.noqa` + +ℹ Fix +118 118 | from datameta_client_lib.model_utils import ( # noqa: F401 +119 119 | noqa ) +120 120 | +121 |-from datameta_client_lib.model_helpers import ( +122 |-noqa ) diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap index e72bdbd62b..c9035cd3c4 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap @@ -59,6 +59,7 @@ F504.py:9:1: F504 [*] `%`-format string has unused named argument(s): b 9 |+"%(a)s" % {'a': 1, } # F504 ("b" not used) 10 10 | 11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) +12 12 | F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab | @@ -66,6 +67,8 @@ F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab 10 | 11 | '' % {'a''b' : ''} # F504 ("ab" not used) | ^^^^^^^^^^^^^^^^^^ F504 +12 | +13 | # https://github.com/astral-sh/ruff/issues/4899 | = help: Remove extra named arguments: ab @@ -75,5 +78,26 @@ F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab 10 10 | 11 |-'' % {'a''b' : ''} # F504 ("ab" not used) 11 |+'' % {} # F504 ("ab" not used) +12 12 | +13 13 | # https://github.com/astral-sh/ruff/issues/4899 +14 14 | "" % { + +F504.py:14:1: F504 [*] `%`-format string has unused named argument(s): test1, test2 + | +13 | # https://github.com/astral-sh/ruff/issues/4899 +14 | / "" % { +15 | | 'test1': '', 'test2': '', +16 | | } + | |_^ F504 + | + = help: Remove extra named arguments: test1, test2 + +ℹ Fix +12 12 | +13 13 | # https://github.com/astral-sh/ruff/issues/4899 +14 14 | "" % { +15 |- 'test1': '', 16 |- 'test2': '', + 15 |+ +17 16 | } diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap index 85c614015c..c428d3b5ec 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap @@ -657,6 +657,7 @@ F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used 165 |- x = 1 166 165 | 167 166 | y = 2 +168 167 | F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used | @@ -672,5 +673,24 @@ F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used 165 165 | x = 1 166 166 | 167 |- y = 2 +168 167 | +169 168 | +170 169 | def f(): + +F841_3.py:173:6: F841 [*] Local variable `x` is assigned to but never used + | +171 | (x) = foo() +172 | ((x)) = foo() +173 | (x) = (y.z) = foo() + | ^ F841 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +170 170 | def f(): +171 171 | (x) = foo() +172 172 | ((x)) = foo() +173 |- (x) = (y.z) = foo() + 173 |+ (y.z) = foo() diff --git a/crates/ruff/src/rules/pylint/mod.rs b/crates/ruff/src/rules/pylint/mod.rs index 670797b2ac..ad3f7f3d66 100644 --- a/crates/ruff/src/rules/pylint/mod.rs +++ b/crates/ruff/src/rules/pylint/mod.rs @@ -119,8 +119,8 @@ mod tests { #[test_case(Rule::YieldInInit, Path::new("yield_in_init.py"))] #[test_case(Rule::NestedMinMax, Path::new("nested_min_max.py"))] #[test_case( - Rule::RepeatedEqualityComparisonTarget, - Path::new("repeated_equality_comparison_target.py") + Rule::RepeatedEqualityComparison, + Path::new("repeated_equality_comparison.py") )] #[test_case(Rule::SelfAssigningVariable, Path::new("self_assigning_variable.py"))] #[test_case( diff --git a/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs b/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs index 8cf05d436b..50589bc6ec 100644 --- a/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs +++ b/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs @@ -77,7 +77,7 @@ pub(crate) fn assert_on_string_literal(checker: &mut Checker, test: &Expr) { AssertOnStringLiteral { kind: if values.iter().all(|value| match value { Expr::Constant(ast::ExprConstant { value, .. }) => match value { - Constant::Str(value, ..) => value.is_empty(), + Constant::Str(value) => value.is_empty(), Constant::Bytes(value) => value.is_empty(), _ => false, }, @@ -86,7 +86,7 @@ pub(crate) fn assert_on_string_literal(checker: &mut Checker, test: &Expr) { Kind::Empty } else if values.iter().any(|value| match value { Expr::Constant(ast::ExprConstant { value, .. }) => match value { - Constant::Str(value, ..) => !value.is_empty(), + Constant::Str(value) => !value.is_empty(), Constant::Bytes(value) => !value.is_empty(), _ => false, }, diff --git a/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs b/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs index e7a3149e4f..5ac20b018f 100644 --- a/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs +++ b/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs @@ -2,18 +2,12 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::identifier::Identifier; use ruff_python_ast::Stmt; +use ruff_python_semantic::analyze::visibility; use crate::checkers::ast::Checker; /// ## What it does -/// Checks for any misspelled dunder name method and for any method -/// defined with `_..._` that's not one of the pre-defined methods -/// -/// The pre-defined methods encompass all of Python's standard dunder -/// methods. -/// -/// Note this includes all methods starting and ending with at least -/// one underscore to detect mistakes. +/// Checks for misspelled and unknown dunder names in method definitions. /// /// ## Why is this bad? /// Misspelled dunder name methods may cause your code to not function @@ -24,6 +18,10 @@ use crate::checkers::ast::Checker; /// that diverges from standard Python dunder methods could potentially /// confuse someone reading the code. /// +/// This rule will detect all methods starting and ending with at least +/// one underscore (e.g., `_str_`), but ignores known dunder methods (like +/// `__init__`), as well as methods that are marked with `@override`. +/// /// ## Example /// ```python /// class Foo: @@ -62,6 +60,9 @@ pub(crate) fn bad_dunder_method_name(checker: &mut Checker, class_body: &[Stmt]) method.name.starts_with('_') && method.name.ends_with('_') }) { + if visibility::is_override(&method.decorator_list, checker.semantic()) { + continue; + } checker.diagnostics.push(Diagnostic::new( BadDunderMethodName { name: method.name.to_string(), diff --git a/crates/ruff/src/rules/pylint/rules/mod.rs b/crates/ruff/src/rules/pylint/rules/mod.rs index b45b857f46..7643b55b52 100644 --- a/crates/ruff/src/rules/pylint/rules/mod.rs +++ b/crates/ruff/src/rules/pylint/rules/mod.rs @@ -33,7 +33,7 @@ pub(crate) use no_self_use::*; pub(crate) use nonlocal_without_binding::*; pub(crate) use property_with_parameters::*; pub(crate) use redefined_loop_name::*; -pub(crate) use repeated_equality_comparison_target::*; +pub(crate) use repeated_equality_comparison::*; pub(crate) use repeated_isinstance_calls::*; pub(crate) use return_in_init::*; pub(crate) use self_assigning_variable::*; @@ -92,7 +92,7 @@ mod no_self_use; mod nonlocal_without_binding; mod property_with_parameters; mod redefined_loop_name; -mod repeated_equality_comparison_target; +mod repeated_equality_comparison; mod repeated_isinstance_calls; mod return_in_init; mod self_assigning_variable; diff --git a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs index e4c28f7ba3..7e76598817 100644 --- a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs +++ b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs @@ -106,14 +106,16 @@ fn collect_nested_args(min_max: MinMax, args: &[Expr], semantic: &SemanticModel) range: _, }) = arg { - if args.len() == 1 { - let new_arg = Expr::Starred(ast::ExprStarred { - value: Box::new(args[0].clone()), - ctx: ast::ExprContext::Load, - range: TextRange::default(), - }); - new_args.push(new_arg); - continue; + if let [arg] = args.as_slice() { + if arg.as_starred_expr().is_none() { + let new_arg = Expr::Starred(ast::ExprStarred { + value: Box::new(arg.clone()), + ctx: ast::ExprContext::Load, + range: TextRange::default(), + }); + new_args.push(new_arg); + continue; + } } if MinMax::try_from_call(func, keywords, semantic) == Some(min_max) { inner(min_max, args, semantic, new_args); @@ -129,7 +131,7 @@ fn collect_nested_args(min_max: MinMax, args: &[Expr], semantic: &SemanticModel) new_args } -/// W3301 +/// PLW3301 pub(crate) fn nested_min_max( checker: &mut Checker, expr: &Expr, diff --git a/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs b/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison.rs similarity index 94% rename from crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs rename to crates/ruff/src/rules/pylint/rules/repeated_equality_comparison.rs index b61ca52994..03841a7adc 100644 --- a/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs +++ b/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison.rs @@ -44,14 +44,14 @@ use crate::checkers::ast::Checker; /// - [Python documentation: Membership test operations](https://docs.python.org/3/reference/expressions.html#membership-test-operations) /// - [Python documentation: `set`](https://docs.python.org/3/library/stdtypes.html#set) #[violation] -pub struct RepeatedEqualityComparisonTarget { +pub struct RepeatedEqualityComparison { expression: SourceCodeSnippet, } -impl Violation for RepeatedEqualityComparisonTarget { +impl Violation for RepeatedEqualityComparison { #[derive_message_formats] fn message(&self) -> String { - let RepeatedEqualityComparisonTarget { expression } = self; + let RepeatedEqualityComparison { expression } = self; if let Some(expression) = expression.full_display() { format!( "Consider merging multiple comparisons: `{expression}`. Use a `set` if the elements are hashable." @@ -65,10 +65,7 @@ impl Violation for RepeatedEqualityComparisonTarget { } /// PLR1714 -pub(crate) fn repeated_equality_comparison_target( - checker: &mut Checker, - bool_op: &ast::ExprBoolOp, -) { +pub(crate) fn repeated_equality_comparison(checker: &mut Checker, bool_op: &ast::ExprBoolOp) { if bool_op .values .iter() @@ -117,7 +114,7 @@ pub(crate) fn repeated_equality_comparison_target( for (value, (count, comparators)) in value_to_comparators { if count > 1 { checker.diagnostics.push(Diagnostic::new( - RepeatedEqualityComparisonTarget { + RepeatedEqualityComparison { expression: SourceCodeSnippet::new(merged_membership_test( value.as_expr(), bool_op.op, diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison_target.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap similarity index 57% rename from crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison_target.py.snap rename to crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap index 40373cea07..0b5c497221 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison_target.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff/src/rules/pylint/mod.rs --- -repeated_equality_comparison_target.py:2:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:2:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. | 1 | # Errors. 2 | foo == "a" or foo == "b" @@ -10,7 +10,7 @@ repeated_equality_comparison_target.py:2:1: PLR1714 Consider merging multiple co 4 | foo != "a" and foo != "b" | -repeated_equality_comparison_target.py:4:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:4:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b")`. Use a `set` if the elements are hashable. | 2 | foo == "a" or foo == "b" 3 | @@ -20,7 +20,7 @@ repeated_equality_comparison_target.py:4:1: PLR1714 Consider merging multiple co 6 | foo == "a" or foo == "b" or foo == "c" | -repeated_equality_comparison_target.py:6:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:6:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 4 | foo != "a" and foo != "b" 5 | @@ -30,7 +30,7 @@ repeated_equality_comparison_target.py:6:1: PLR1714 Consider merging multiple co 8 | foo != "a" and foo != "b" and foo != "c" | -repeated_equality_comparison_target.py:8:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:8:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 6 | foo == "a" or foo == "b" or foo == "c" 7 | @@ -40,7 +40,7 @@ repeated_equality_comparison_target.py:8:1: PLR1714 Consider merging multiple co 10 | foo == a or foo == "b" or foo == 3 # Mixed types. | -repeated_equality_comparison_target.py:10:1: PLR1714 Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:10:1: PLR1714 Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. | 8 | foo != "a" and foo != "b" and foo != "c" 9 | @@ -50,7 +50,7 @@ repeated_equality_comparison_target.py:10:1: PLR1714 Consider merging multiple c 12 | "a" == foo or "b" == foo or "c" == foo | -repeated_equality_comparison_target.py:12:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:12:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. 11 | @@ -60,7 +60,7 @@ repeated_equality_comparison_target.py:12:1: PLR1714 Consider merging multiple c 14 | "a" != foo and "b" != foo and "c" != foo | -repeated_equality_comparison_target.py:14:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:14:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 12 | "a" == foo or "b" == foo or "c" == foo 13 | @@ -70,7 +70,7 @@ repeated_equality_comparison_target.py:14:1: PLR1714 Consider merging multiple c 16 | "a" == foo or foo == "b" or "c" == foo | -repeated_equality_comparison_target.py:16:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:16:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 14 | "a" != foo and "b" != foo and "c" != foo 15 | @@ -80,7 +80,7 @@ repeated_equality_comparison_target.py:16:1: PLR1714 Consider merging multiple c 18 | foo == bar or baz == foo or qux == foo | -repeated_equality_comparison_target.py:18:1: PLR1714 Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:18:1: PLR1714 Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. | 16 | "a" == foo or foo == "b" or "c" == foo 17 | @@ -90,7 +90,7 @@ repeated_equality_comparison_target.py:18:1: PLR1714 Consider merging multiple c 20 | foo == "a" or "b" == foo or foo == "c" | -repeated_equality_comparison_target.py:20:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:20:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 18 | foo == bar or baz == foo or qux == foo 19 | @@ -100,7 +100,7 @@ repeated_equality_comparison_target.py:20:1: PLR1714 Consider merging multiple c 22 | foo != "a" and "b" != foo and foo != "c" | -repeated_equality_comparison_target.py:22:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:22:1: PLR1714 Consider merging multiple comparisons: `foo not in ("a", "b", "c")`. Use a `set` if the elements are hashable. | 20 | foo == "a" or "b" == foo or foo == "c" 21 | @@ -110,7 +110,7 @@ repeated_equality_comparison_target.py:22:1: PLR1714 Consider merging multiple c 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | -repeated_equality_comparison_target.py:24:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:24:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. | 22 | foo != "a" and "b" != foo and foo != "c" 23 | @@ -120,7 +120,7 @@ repeated_equality_comparison_target.py:24:1: PLR1714 Consider merging multiple c 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | -repeated_equality_comparison_target.py:24:1: PLR1714 Consider merging multiple comparisons: `bar in ("c", "d")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:24:1: PLR1714 Consider merging multiple comparisons: `bar in ("c", "d")`. Use a `set` if the elements are hashable. | 22 | foo != "a" and "b" != foo and foo != "c" 23 | @@ -130,7 +130,7 @@ repeated_equality_comparison_target.py:24:1: PLR1714 Consider merging multiple c 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | -repeated_equality_comparison_target.py:26:1: PLR1714 Consider merging multiple comparisons: `foo.bar in ("a", "b")`. Use a `set` if the elements are hashable. +repeated_equality_comparison.py:26:1: PLR1714 Consider merging multiple comparisons: `foo.bar in ("a", "b")`. Use a `set` if the elements are hashable. | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets 25 | diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap index f3c6b81661..286c40fb39 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap @@ -1,61 +1,61 @@ --- source: crates/ruff/src/rules/pylint/mod.rs --- -bad_dunder_method_name.py:2:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) +bad_dunder_method_name.py:5:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) | -1 | class Apples: -2 | def _init_(self): # [bad-dunder-name] +4 | class Apples: +5 | def _init_(self): # [bad-dunder-name] | ^^^^^^ PLW3201 -3 | pass +6 | pass | -bad_dunder_method_name.py:5:9: PLW3201 Bad or misspelled dunder method name `__hello__`. (bad-dunder-name) +bad_dunder_method_name.py:8:9: PLW3201 Bad or misspelled dunder method name `__hello__`. (bad-dunder-name) | -3 | pass -4 | -5 | def __hello__(self): # [bad-dunder-name] +6 | pass +7 | +8 | def __hello__(self): # [bad-dunder-name] | ^^^^^^^^^ PLW3201 -6 | print("hello") +9 | print("hello") | -bad_dunder_method_name.py:8:9: PLW3201 Bad or misspelled dunder method name `__init_`. (bad-dunder-name) +bad_dunder_method_name.py:11:9: PLW3201 Bad or misspelled dunder method name `__init_`. (bad-dunder-name) | - 6 | print("hello") - 7 | - 8 | def __init_(self): # [bad-dunder-name] + 9 | print("hello") +10 | +11 | def __init_(self): # [bad-dunder-name] | ^^^^^^^ PLW3201 - 9 | # author likely unintentionally misspelled the correct init dunder. -10 | pass +12 | # author likely unintentionally misspelled the correct init dunder. +13 | pass | -bad_dunder_method_name.py:12:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) +bad_dunder_method_name.py:15:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) | -10 | pass -11 | -12 | def _init_(self): # [bad-dunder-name] +13 | pass +14 | +15 | def _init_(self): # [bad-dunder-name] | ^^^^^^ PLW3201 -13 | # author likely unintentionally misspelled the correct init dunder. -14 | pass +16 | # author likely unintentionally misspelled the correct init dunder. +17 | pass | -bad_dunder_method_name.py:16:9: PLW3201 Bad or misspelled dunder method name `___neg__`. (bad-dunder-name) +bad_dunder_method_name.py:19:9: PLW3201 Bad or misspelled dunder method name `___neg__`. (bad-dunder-name) | -14 | pass -15 | -16 | def ___neg__(self): # [bad-dunder-name] +17 | pass +18 | +19 | def ___neg__(self): # [bad-dunder-name] | ^^^^^^^^ PLW3201 -17 | # author likely accidentally added an additional `_` -18 | pass +20 | # author likely accidentally added an additional `_` +21 | pass | -bad_dunder_method_name.py:20:9: PLW3201 Bad or misspelled dunder method name `__inv__`. (bad-dunder-name) +bad_dunder_method_name.py:23:9: PLW3201 Bad or misspelled dunder method name `__inv__`. (bad-dunder-name) | -18 | pass -19 | -20 | def __inv__(self): # [bad-dunder-name] +21 | pass +22 | +23 | def __inv__(self): # [bad-dunder-name] | ^^^^^^^ PLW3201 -21 | # author likely meant to call the invert dunder method -22 | pass +24 | # author likely meant to call the invert dunder method +25 | pass | diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap index 48c034f1f2..efd914b5da 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap @@ -278,4 +278,19 @@ nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened 29 29 | tuples_list = [ 30 30 | (1, 2), +nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened + | +40 | # Starred argument should be copied as it is. +41 | max(1, max(*a)) + | ^^^^^^^^^^^^^^^ PLW3301 + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +38 38 | max(max(tuples_list)) +39 39 | +40 40 | # Starred argument should be copied as it is. +41 |-max(1, max(*a)) + 41 |+max(1, *a) + diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs index b4898f8a07..6a2f385215 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs @@ -138,16 +138,52 @@ const PIPES_TO_SHLEX: &[&str] = &["quote"]; // Members of `typing_extensions` that were moved to `typing`. const TYPING_EXTENSIONS_TO_TYPING: &[&str] = &[ + "AbstractSet", + "AnyStr", "AsyncIterable", "AsyncIterator", "Awaitable", + "BinaryIO", + "Callable", "ClassVar", + "Collection", + "Container", "ContextManager", "Coroutine", "DefaultDict", + "Dict", + "FrozenSet", + "Generator", + "Generic", + "Hashable", + "IO", + "ItemsView", + "Iterable", + "Iterator", + "KeysView", + "List", + "Mapping", + "MappingView", + "Match", + "MutableMapping", + "MutableSequence", + "MutableSet", + "Optional", + "Pattern", + "Reversible", + "Sequence", + "Set", + "Sized", "TYPE_CHECKING", "Text", + "TextIO", + "Tuple", "Type", + "Union", + "ValuesView", + "cast", + "no_type_check", + "no_type_check_decorator", // Introduced in Python 3.5.2, but `typing_extensions` contains backported bugfixes and // optimizations, // "NewType", @@ -165,6 +201,7 @@ const TYPING_EXTENSIONS_TO_TYPING_37: &[&str] = &[ "ChainMap", "Counter", "Deque", + "ForwardRef", "NoReturn", ]; @@ -287,6 +324,18 @@ const TYPING_EXTENSIONS_TO_TYPING_311: &[&str] = &[ // Members of `typing_extensions` that were moved to `typing`. const TYPING_EXTENSIONS_TO_TYPING_312: &[&str] = &[ + "NamedTuple", + // Introduced in Python 3.8, but `typing_extensions` backports a ton of optimizations that were + // added in Python 3.12. + "Protocol", + "SupportsAbs", + "SupportsBytes", + "SupportsComplex", + "SupportsFloat", + "SupportsInt", + "SupportsRound", + "TypedDict", + "Unpack", // Introduced in Python 3.11, but `typing_extensions` backports the `frozen_default` argument, // which was introduced in Python 3.12. "dataclass_transform", diff --git a/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs b/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs index fd26343b66..18b9670acb 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs @@ -40,6 +40,7 @@ impl From for Constant { match value { LiteralType::Str => Constant::Str(ast::StringConstant { value: String::new(), + unicode: false, implicit_concatenated: false, }), LiteralType::Bytes => Constant::Bytes(ast::BytesConstant { diff --git a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs index 1e4e659c92..45510ccfc1 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs @@ -1,6 +1,7 @@ use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext}; use ruff_text_size::{Ranged, TextRange}; +use crate::autofix::edits::pad; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::compose_call_path; @@ -122,22 +123,21 @@ fn tuple_diagnostic(checker: &mut Checker, target: &Expr, aliases: &[&Expr]) { remaining.insert(0, node.into()); } - if remaining.len() == 1 { - diagnostic.set_fix(Fix::automatic(Edit::range_replacement( - "OSError".to_string(), - target.range(), - ))); + let content = if remaining.len() == 1 { + "OSError".to_string() } else { let node = ast::ExprTuple { elts: remaining, ctx: ExprContext::Load, range: TextRange::default(), }; - diagnostic.set_fix(Fix::automatic(Edit::range_replacement( - format!("({})", checker.generator().expr(&node.into())), - target.range(), - ))); - } + format!("({})", checker.generator().expr(&node.into())) + }; + + diagnostic.set_fix(Fix::automatic(Edit::range_replacement( + pad(content, target.range(), checker.locator()), + target.range(), + ))); } } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs b/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs index fe32ef24da..1e8c94abd7 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs @@ -60,66 +60,147 @@ impl AlwaysAutofixableViolation for OutdatedVersionBlock { } } -/// Converts a `BigInt` to a `u32`. If the number is negative, it will return 0. -fn bigint_to_u32(number: &BigInt) -> u32 { - let the_number = number.to_u32_digits(); - match the_number.0 { - Sign::Minus | Sign::NoSign => 0, - Sign::Plus => *the_number.1.first().unwrap(), - } -} +/// UP036 +pub(crate) fn outdated_version_block(checker: &mut Checker, stmt_if: &StmtIf) { + for branch in if_elif_branches(stmt_if) { + let Expr::Compare(ast::ExprCompare { + left, + ops, + comparators, + range: _, + }) = &branch.test + else { + continue; + }; -/// Gets the version from the tuple -fn extract_version(elts: &[Expr]) -> Vec { - let mut version: Vec = vec![]; - for elt in elts { - if let Expr::Constant(ast::ExprConstant { - value: Constant::Int(item), - .. - }) = &elt + let ([op], [comparison]) = (ops.as_slice(), comparators.as_slice()) else { + continue; + }; + + if !checker + .semantic() + .resolve_call_path(left) + .is_some_and(|call_path| matches!(call_path.as_slice(), ["sys", "version_info"])) { - let number = bigint_to_u32(item); - version.push(number); - } else { - return version; + continue; } - } - version -} -/// Returns true if the `if_version` is less than the `PythonVersion` -fn compare_version(if_version: &[u32], py_version: PythonVersion, or_equal: bool) -> bool { - let mut if_version_iter = if_version.iter(); - if let Some(if_major) = if_version_iter.next() { - let (py_major, py_minor) = py_version.as_tuple(); - match if_major.cmp(&py_major) { - Ordering::Less => true, - Ordering::Equal => { - if let Some(if_minor) = if_version_iter.next() { - // Check the if_minor number (the minor version). - if or_equal { - *if_minor <= py_minor - } else { - *if_minor < py_minor + match comparison { + Expr::Tuple(ast::ExprTuple { elts, .. }) => match op { + CmpOp::Lt | CmpOp::LtE => { + let version = extract_version(elts); + let target = checker.settings.target_version; + if compare_version(&version, target, op == &CmpOp::LtE) { + let mut diagnostic = + Diagnostic::new(OutdatedVersionBlock, branch.test.range()); + if checker.patch(diagnostic.kind.rule()) { + if let Some(fix) = fix_always_false_branch(checker, stmt_if, &branch) { + diagnostic.set_fix(fix); + } + } + checker.diagnostics.push(diagnostic); + } + } + CmpOp::Gt | CmpOp::GtE => { + let version = extract_version(elts); + let target = checker.settings.target_version; + if compare_version(&version, target, op == &CmpOp::GtE) { + let mut diagnostic = + Diagnostic::new(OutdatedVersionBlock, branch.test.range()); + if checker.patch(diagnostic.kind.rule()) { + if let Some(fix) = fix_always_true_branch(checker, stmt_if, &branch) { + diagnostic.set_fix(fix); + } + } + checker.diagnostics.push(diagnostic); + } + } + _ => {} + }, + Expr::Constant(ast::ExprConstant { + value: Constant::Int(number), + .. + }) => { + if op == &CmpOp::Eq { + match bigint_to_u32(number) { + 2 => { + let mut diagnostic = + Diagnostic::new(OutdatedVersionBlock, branch.test.range()); + if checker.patch(diagnostic.kind.rule()) { + if let Some(fix) = + fix_always_false_branch(checker, stmt_if, &branch) + { + diagnostic.set_fix(fix); + } + } + checker.diagnostics.push(diagnostic); + } + 3 => { + let mut diagnostic = + Diagnostic::new(OutdatedVersionBlock, branch.test.range()); + if checker.patch(diagnostic.kind.rule()) { + if let Some(fix) = fix_always_true_branch(checker, stmt_if, &branch) + { + diagnostic.set_fix(fix); + } + } + checker.diagnostics.push(diagnostic); + } + _ => {} } - } else { - // Assume Python 3.0. - true } } - Ordering::Greater => false, + _ => (), } - } else { - false } } -/// For fixing, we have 4 cases: -/// * Just an if: delete as statement (insert pass in parent if required) -/// * If with an elif: delete, turn elif into if -/// * If with an else: delete, dedent else -/// * Just an elif: delete, `elif False` can always be removed -fn fix_py2_block(checker: &Checker, stmt_if: &StmtIf, branch: &IfElifBranch) -> Option { +/// Returns true if the `target_version` is always less than the [`PythonVersion`]. +fn compare_version(target_version: &[u32], py_version: PythonVersion, or_equal: bool) -> bool { + let mut target_version_iter = target_version.iter(); + + let Some(if_major) = target_version_iter.next() else { + return false; + }; + + let (py_major, py_minor) = py_version.as_tuple(); + + match if_major.cmp(&py_major) { + Ordering::Less => true, + Ordering::Greater => false, + Ordering::Equal => { + let Some(if_minor) = target_version_iter.next() else { + return true; + }; + if or_equal { + // Ex) `sys.version_info <= 3.8`. If Python 3.8 is the minimum supported version, + // the condition won't always evaluate to `false`, so we want to return `false`. + *if_minor < py_minor + } else { + // Ex) `sys.version_info < 3.8`. If Python 3.8 is the minimum supported version, + // the condition _will_ always evaluate to `false`, so we want to return `true`. + *if_minor <= py_minor + } + } + } +} + +/// Fix a branch that is known to always evaluate to `false`. +/// +/// For example, when running with a minimum supported version of Python 3.8, the following branch +/// would be considered redundant: +/// ```python +/// if sys.version_info < (3, 7): ... +/// ``` +/// +/// In this case, the fix would involve removing the branch; however, there are multiple cases to +/// consider. For example, if the `if` has an `else`, then the `if` should be removed, and the +/// `else` should be inlined at the top level. +fn fix_always_false_branch( + checker: &Checker, + stmt_if: &StmtIf, + branch: &IfElifBranch, +) -> Option { match branch.kind { BranchKind::If => match stmt_if.elif_else_clauses.first() { // If we have a lone `if`, delete as statement (insert pass in parent if required) @@ -210,8 +291,18 @@ fn fix_py2_block(checker: &Checker, stmt_if: &StmtIf, branch: &IfElifBranch) -> } } -/// Convert a [`Stmt::If`], removing the `else` block. -fn fix_py3_block(checker: &mut Checker, stmt_if: &StmtIf, branch: &IfElifBranch) -> Option { +/// Fix a branch that is known to always evaluate to `true`. +/// +/// For example, when running with a minimum supported version of Python 3.8, the following branch +/// would be considered redundant, as it's known to always evaluate to `true`: +/// ```python +/// if sys.version_info >= (3, 8): ... +/// ``` +fn fix_always_true_branch( + checker: &mut Checker, + stmt_if: &StmtIf, + branch: &IfElifBranch, +) -> Option { match branch.kind { BranchKind::If => { // If the first statement is an `if`, use the body of this statement, and ignore @@ -262,85 +353,31 @@ fn fix_py3_block(checker: &mut Checker, stmt_if: &StmtIf, branch: &IfElifBranch) } } -/// UP036 -pub(crate) fn outdated_version_block(checker: &mut Checker, stmt_if: &StmtIf) { - for branch in if_elif_branches(stmt_if) { - let Expr::Compare(ast::ExprCompare { - left, - ops, - comparators, - range: _, - }) = &branch.test - else { - continue; - }; +/// Converts a `BigInt` to a `u32`. If the number is negative, it will return 0. +fn bigint_to_u32(number: &BigInt) -> u32 { + let the_number = number.to_u32_digits(); + match the_number.0 { + Sign::Minus | Sign::NoSign => 0, + Sign::Plus => *the_number.1.first().unwrap(), + } +} - let ([op], [comparison]) = (ops.as_slice(), comparators.as_slice()) else { - continue; - }; - - if !checker - .semantic() - .resolve_call_path(left) - .is_some_and(|call_path| matches!(call_path.as_slice(), ["sys", "version_info"])) +/// Gets the version from the tuple +fn extract_version(elts: &[Expr]) -> Vec { + let mut version: Vec = vec![]; + for elt in elts { + if let Expr::Constant(ast::ExprConstant { + value: Constant::Int(item), + .. + }) = &elt { - continue; - } - - match comparison { - Expr::Tuple(ast::ExprTuple { elts, .. }) => { - let version = extract_version(elts); - let target = checker.settings.target_version; - if op == &CmpOp::Lt || op == &CmpOp::LtE { - if compare_version(&version, target, op == &CmpOp::LtE) { - let mut diagnostic = - Diagnostic::new(OutdatedVersionBlock, branch.test.range()); - if checker.patch(diagnostic.kind.rule()) { - if let Some(fix) = fix_py2_block(checker, stmt_if, &branch) { - diagnostic.set_fix(fix); - } - } - checker.diagnostics.push(diagnostic); - } - } else if op == &CmpOp::Gt || op == &CmpOp::GtE { - if compare_version(&version, target, op == &CmpOp::GtE) { - let mut diagnostic = - Diagnostic::new(OutdatedVersionBlock, branch.test.range()); - if checker.patch(diagnostic.kind.rule()) { - if let Some(fix) = fix_py3_block(checker, stmt_if, &branch) { - diagnostic.set_fix(fix); - } - } - checker.diagnostics.push(diagnostic); - } - } - } - Expr::Constant(ast::ExprConstant { - value: Constant::Int(number), - .. - }) => { - let version_number = bigint_to_u32(number); - if version_number == 2 && op == &CmpOp::Eq { - let mut diagnostic = Diagnostic::new(OutdatedVersionBlock, branch.test.range()); - if checker.patch(diagnostic.kind.rule()) { - if let Some(fix) = fix_py2_block(checker, stmt_if, &branch) { - diagnostic.set_fix(fix); - } - } - checker.diagnostics.push(diagnostic); - } else if version_number == 3 && op == &CmpOp::Eq { - let mut diagnostic = Diagnostic::new(OutdatedVersionBlock, branch.test.range()); - if checker.patch(diagnostic.kind.rule()) { - if let Some(fix) = fix_py3_block(checker, stmt_if, &branch) { - diagnostic.set_fix(fix); - } - } - checker.diagnostics.push(diagnostic); - } - } - _ => (), + let number = bigint_to_u32(item); + version.push(number); + } else { + return version; } } + version } #[cfg(test)] @@ -355,8 +392,8 @@ mod tests { #[test_case(PythonVersion::Py37, &[3, 0], true, true; "compare-3.0-whole")] #[test_case(PythonVersion::Py37, &[3, 1], true, true; "compare-3.1")] #[test_case(PythonVersion::Py37, &[3, 5], true, true; "compare-3.5")] - #[test_case(PythonVersion::Py37, &[3, 7], true, true; "compare-3.7")] - #[test_case(PythonVersion::Py37, &[3, 7], false, false; "compare-3.7-not-equal")] + #[test_case(PythonVersion::Py37, &[3, 7], true, false; "compare-3.7")] + #[test_case(PythonVersion::Py37, &[3, 7], false, true; "compare-3.7-not-equal")] #[test_case(PythonVersion::Py37, &[3, 8], false , false; "compare-3.8")] #[test_case(PythonVersion::Py310, &[3,9], true, true; "compare-3.9")] #[test_case(PythonVersion::Py310, &[3, 11], true, false; "compare-3.11")] diff --git a/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs b/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs index 86094b21fb..67ddaa118f 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs @@ -1,6 +1,6 @@ use anyhow::Result; -use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; +use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::{self as ast, Keyword}; use ruff_text_size::Ranged; @@ -39,40 +39,19 @@ use crate::registry::AsRule; #[violation] pub struct ReplaceStdoutStderr; -impl AlwaysAutofixableViolation for ReplaceStdoutStderr { +impl Violation for ReplaceStdoutStderr { + const AUTOFIX: AutofixKind = AutofixKind::Sometimes; + #[derive_message_formats] fn message(&self) -> String { format!("Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output`") } - fn autofix_title(&self) -> String { - "Replace with `capture_output` keyword argument".to_string() + fn autofix_title(&self) -> Option { + Some("Replace with `capture_output` keyword argument".to_string()) } } -/// Generate a [`Edit`] for a `stdout` and `stderr` [`Keyword`] pair. -fn generate_fix( - stdout: &Keyword, - stderr: &Keyword, - call: &ast::ExprCall, - source: &str, -) -> Result { - let (first, second) = if stdout.start() < stderr.start() { - (stdout, stderr) - } else { - (stderr, stdout) - }; - Ok(Fix::suggested_edits( - Edit::range_replacement("capture_output=True".to_string(), first.range()), - [remove_argument( - second, - &call.arguments, - Parentheses::Preserve, - source, - )?], - )) -} - /// UP022 pub(crate) fn replace_stdout_stderr(checker: &mut Checker, call: &ast::ExprCall) { if checker @@ -103,9 +82,36 @@ pub(crate) fn replace_stdout_stderr(checker: &mut Checker, call: &ast::ExprCall) let mut diagnostic = Diagnostic::new(ReplaceStdoutStderr, call.range()); if checker.patch(diagnostic.kind.rule()) { - diagnostic - .try_set_fix(|| generate_fix(stdout, stderr, call, checker.locator().contents())); + if call.arguments.find_keyword("capture_output").is_none() { + diagnostic.try_set_fix(|| { + generate_fix(stdout, stderr, call, checker.locator().contents()) + }); + } } checker.diagnostics.push(diagnostic); } } + +/// Generate a [`Edit`] for a `stdout` and `stderr` [`Keyword`] pair. +fn generate_fix( + stdout: &Keyword, + stderr: &Keyword, + call: &ast::ExprCall, + source: &str, +) -> Result { + let (first, second) = if stdout.start() < stderr.start() { + (stdout, stderr) + } else { + (stderr, stdout) + }; + // Replace one argument with `capture_output=True`, and remove the other. + Ok(Fix::suggested_edits( + Edit::range_replacement("capture_output=True".to_string(), first.range()), + [remove_argument( + second, + &call.arguments, + Parentheses::Preserve, + source, + )?], + )) +} diff --git a/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs b/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs index 46b8f96e88..6f82e5940f 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs @@ -1,9 +1,9 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast}; +use ruff_python_ast as ast; use ruff_text_size::Ranged; -use ruff_text_size::{TextLen, TextRange}; +use crate::autofix::edits::{remove_argument, Parentheses}; use crate::checkers::ast::Checker; use crate::registry::AsRule; @@ -58,13 +58,30 @@ pub(crate) fn replace_universal_newlines(checker: &mut Checker, call: &ast::Expr let Some(kwarg) = call.arguments.find_keyword("universal_newlines") else { return; }; - let range = TextRange::at(kwarg.start(), "universal_newlines".text_len()); - let mut diagnostic = Diagnostic::new(ReplaceUniversalNewlines, range); + + let Some(arg) = kwarg.arg.as_ref() else { + return; + }; + + let mut diagnostic = Diagnostic::new(ReplaceUniversalNewlines, arg.range()); + if checker.patch(diagnostic.kind.rule()) { - diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - "text".to_string(), - range, - ))); + if call.arguments.find_keyword("text").is_some() { + diagnostic.try_set_fix(|| { + remove_argument( + kwarg, + &call.arguments, + Parentheses::Preserve, + checker.locator().contents(), + ) + .map(Fix::suggested) + }); + } else { + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( + "text".to_string(), + arg.range(), + ))); + } } checker.diagnostics.push(diagnostic); } diff --git a/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs b/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs index 8947927764..887b98cb30 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs @@ -40,8 +40,8 @@ impl AlwaysAutofixableViolation for UnicodeKindPrefix { } /// UP025 -pub(crate) fn unicode_kind_prefix(checker: &mut Checker, expr: &Expr, kind: Option<&str>) { - if matches!(kind, Some("u" | "U")) { +pub(crate) fn unicode_kind_prefix(checker: &mut Checker, expr: &Expr, is_unicode: bool) { + if is_unicode { let mut diagnostic = Diagnostic::new(UnicodeKindPrefix, expr.range()); if checker.patch(diagnostic.kind.rule()) { diagnostic.set_fix(Fix::automatic(Edit::range_deletion(TextRange::at( diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs index 7873dc98ea..c1fbbfa6ce 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs @@ -1,13 +1,10 @@ -use itertools::Either::{Left, Right}; -use itertools::Itertools; -use ruff_python_ast::{self as ast, Expr}; - use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Constant, Expr, ExprContext, Operator}; use ruff_python_semantic::analyze::typing::Pep604Operator; -use ruff_source_file::Locator; -use ruff_text_size::Ranged; +use ruff_text_size::{Ranged, TextRange}; +use crate::autofix::edits::pad; use crate::checkers::ast::Checker; use crate::registry::AsRule; @@ -77,10 +74,21 @@ pub(crate) fn use_pep604_annotation( Pep604Operator::Optional => { let mut diagnostic = Diagnostic::new(NonPEP604Annotation, expr.range()); if fixable && checker.patch(diagnostic.kind.rule()) { - diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - optional(slice, checker.locator()), - expr.range(), - ))); + match slice { + Expr::Tuple(_) => { + // Invalid type annotation. + } + _ => { + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( + pad( + checker.generator().expr(&optional(slice)), + expr.range(), + checker.locator(), + ), + expr.range(), + ))); + } + } } checker.diagnostics.push(diagnostic); } @@ -93,14 +101,22 @@ pub(crate) fn use_pep604_annotation( } Expr::Tuple(ast::ExprTuple { elts, .. }) => { diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - union(elts, checker.locator()), + pad( + checker.generator().expr(&union(elts)), + expr.range(), + checker.locator(), + ), expr.range(), ))); } _ => { // Single argument. diagnostic.set_fix(Fix::suggested(Edit::range_replacement( - checker.locator().slice(slice).to_string(), + pad( + checker.locator().slice(slice).to_string(), + expr.range(), + checker.locator(), + ), expr.range(), ))); } @@ -112,23 +128,35 @@ pub(crate) fn use_pep604_annotation( } /// Format the expression as a PEP 604-style optional. -fn optional(expr: &Expr, locator: &Locator) -> String { - format!("{} | None", locator.slice(expr)) +fn optional(expr: &Expr) -> Expr { + ast::ExprBinOp { + left: Box::new(expr.clone()), + op: Operator::BitOr, + right: Box::new(Expr::Constant(ast::ExprConstant { + value: Constant::None, + range: TextRange::default(), + })), + range: TextRange::default(), + } + .into() } /// Format the expressions as a PEP 604-style union. -fn union(elts: &[Expr], locator: &Locator) -> String { - let mut elts = elts - .iter() - .flat_map(|expr| match expr { - Expr::Tuple(ast::ExprTuple { elts, .. }) => Left(elts.iter()), - _ => Right(std::iter::once(expr)), - }) - .peekable(); - if elts.peek().is_none() { - "()".to_string() - } else { - elts.map(|expr| locator.slice(expr)).join(" | ") +fn union(elts: &[Expr]) -> Expr { + match elts { + [] => Expr::Tuple(ast::ExprTuple { + elts: vec![], + ctx: ExprContext::Load, + range: TextRange::default(), + }), + [Expr::Tuple(ast::ExprTuple { elts, .. })] => union(elts), + [elt] => elt.clone(), + [elt, rest @ ..] => Expr::BinOp(ast::ExprBinOp { + left: Box::new(union(&[elt.clone()])), + op: Operator::BitOr, + right: Box::new(union(rest)), + range: TextRange::default(), + }), } } diff --git a/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs b/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs index be8de879f7..fb97cd42fd 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs @@ -1,5 +1,6 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::parenthesize::parenthesized_range; use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_text_size::Ranged; @@ -103,7 +104,14 @@ pub(crate) fn yield_in_for_loop(checker: &mut Checker, stmt_for: &ast::StmtFor) let mut diagnostic = Diagnostic::new(YieldInForLoop, stmt_for.range()); if checker.patch(diagnostic.kind.rule()) { - let contents = checker.locator().slice(iter.as_ref()); + let contents = checker.locator().slice( + parenthesized_range( + iter.as_ref().into(), + stmt_for.into(), + checker.locator().contents(), + ) + .unwrap_or(iter.range()), + ); let contents = format!("yield from {contents}"); diagnostic.set_fix(Fix::suggested(Edit::range_replacement( contents, diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap index b5b6998a18..e93227555c 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap @@ -50,7 +50,7 @@ UP007.py:14:10: UP007 [*] Use `X | Y` for type annotations 12 12 | 13 13 | 14 |-def f(x: Union[str, int, Union[float, bytes]]) -> None: - 14 |+def f(x: str | int | Union[float, bytes]) -> None: + 14 |+def f(x: str | (int | Union[float, bytes])) -> None: 15 15 | ... 16 16 | 17 17 | @@ -176,7 +176,7 @@ UP007.py:38:11: UP007 [*] Use `X | Y` for type annotations 36 36 | 37 37 | 38 |-def f(x: "Union[str, int, Union[float, bytes]]") -> None: - 38 |+def f(x: "str | int | Union[float, bytes]") -> None: + 38 |+def f(x: "str | (int | Union[float, bytes])") -> None: 39 39 | ... 40 40 | 41 41 | @@ -361,4 +361,54 @@ UP007.py:92:10: UP007 Use `X | Y` for type annotations | = help: Convert to `X | Y` +UP007.py:96:10: UP007 Use `X | Y` for type annotations + | +96 | def f(x: Optional[int, float]) -> None: + | ^^^^^^^^^^^^^^^^^^^^ UP007 +97 | ... + | + = help: Convert to `X | Y` + +UP007.py:102:28: UP007 [*] Use `X | Y` for type annotations + | +100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 +101 | class ServiceRefOrValue: +102 | service_specification: Optional[ + | ____________________________^ +103 | | list[ServiceSpecificationRef] +104 | | | list[ServiceSpecification] +105 | | ] = None + | |_____^ UP007 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +99 99 | +100 100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 +101 101 | class ServiceRefOrValue: +102 |- service_specification: Optional[ +103 |- list[ServiceSpecificationRef] +104 |- | list[ServiceSpecification] +105 |- ] = None + 102 |+ service_specification: list[ServiceSpecificationRef] | list[ServiceSpecification] | None = None +106 103 | +107 104 | +108 105 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 + +UP007.py:110:28: UP007 [*] Use `X | Y` for type annotations + | +108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 +109 | class ServiceRefOrValue: +110 | service_specification: Optional[str]is not True = None + | ^^^^^^^^^^^^^ UP007 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +107 107 | +108 108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 +109 109 | class ServiceRefOrValue: +110 |- service_specification: Optional[str]is not True = None + 110 |+ service_specification: str | None is not True = None + diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap index 605f560b22..6e82b0a418 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap @@ -1,83 +1,65 @@ --- source: crates/ruff/src/rules/pyupgrade/mod.rs --- +UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` + | +4 | # Errors +5 | subprocess.run(["foo"], universal_newlines=True, check=True) + | ^^^^^^^^^^^^^^^^^^ UP021 +6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 | run(["foo"], universal_newlines=True, check=False) + | + = help: Replace with `text` keyword argument + +ℹ Suggested fix +2 2 | from subprocess import run +3 3 | +4 4 | # Errors +5 |-subprocess.run(["foo"], universal_newlines=True, check=True) + 5 |+subprocess.run(["foo"], text=True, check=True) +6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 7 | run(["foo"], universal_newlines=True, check=False) +8 8 | + UP021.py:6:25: UP021 [*] `universal_newlines` is deprecated, use `text` | -4 | from subprocess import run as anothername -5 | -6 | subprocess.run(["foo"], universal_newlines=True, check=True) +4 | # Errors +5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 | subprocess.run(["foo"], universal_newlines=True, text=True) | ^^^^^^^^^^^^^^^^^^ UP021 -7 | somename.run(["foo"], universal_newlines=True) +7 | run(["foo"], universal_newlines=True, check=False) | = help: Replace with `text` keyword argument ℹ Suggested fix -3 3 | from subprocess import run -4 4 | from subprocess import run as anothername -5 5 | -6 |-subprocess.run(["foo"], universal_newlines=True, check=True) - 6 |+subprocess.run(["foo"], text=True, check=True) -7 7 | somename.run(["foo"], universal_newlines=True) +3 3 | +4 4 | # Errors +5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 |-subprocess.run(["foo"], universal_newlines=True, text=True) + 6 |+subprocess.run(["foo"], text=True) +7 7 | run(["foo"], universal_newlines=True, check=False) 8 8 | -9 9 | run(["foo"], universal_newlines=True, check=False) +9 9 | # OK -UP021.py:7:23: UP021 [*] `universal_newlines` is deprecated, use `text` +UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` | -6 | subprocess.run(["foo"], universal_newlines=True, check=True) -7 | somename.run(["foo"], universal_newlines=True) - | ^^^^^^^^^^^^^^^^^^ UP021 +5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 | run(["foo"], universal_newlines=True, check=False) + | ^^^^^^^^^^^^^^^^^^ UP021 8 | -9 | run(["foo"], universal_newlines=True, check=False) +9 | # OK | = help: Replace with `text` keyword argument ℹ Suggested fix -4 4 | from subprocess import run as anothername -5 5 | -6 6 | subprocess.run(["foo"], universal_newlines=True, check=True) -7 |-somename.run(["foo"], universal_newlines=True) - 7 |+somename.run(["foo"], text=True) +4 4 | # Errors +5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 |-run(["foo"], universal_newlines=True, check=False) + 7 |+run(["foo"], text=True, check=False) 8 8 | -9 9 | run(["foo"], universal_newlines=True, check=False) -10 10 | anothername(["foo"], universal_newlines=True) - -UP021.py:9:14: UP021 [*] `universal_newlines` is deprecated, use `text` - | - 7 | somename.run(["foo"], universal_newlines=True) - 8 | - 9 | run(["foo"], universal_newlines=True, check=False) - | ^^^^^^^^^^^^^^^^^^ UP021 -10 | anothername(["foo"], universal_newlines=True) - | - = help: Replace with `text` keyword argument - -ℹ Suggested fix -6 6 | subprocess.run(["foo"], universal_newlines=True, check=True) -7 7 | somename.run(["foo"], universal_newlines=True) -8 8 | -9 |-run(["foo"], universal_newlines=True, check=False) - 9 |+run(["foo"], text=True, check=False) -10 10 | anothername(["foo"], universal_newlines=True) -11 11 | -12 12 | subprocess.run(["foo"], check=True) - -UP021.py:10:22: UP021 [*] `universal_newlines` is deprecated, use `text` - | - 9 | run(["foo"], universal_newlines=True, check=False) -10 | anothername(["foo"], universal_newlines=True) - | ^^^^^^^^^^^^^^^^^^ UP021 -11 | -12 | subprocess.run(["foo"], check=True) - | - = help: Replace with `text` keyword argument - -ℹ Suggested fix -7 7 | somename.run(["foo"], universal_newlines=True) -8 8 | -9 9 | run(["foo"], universal_newlines=True, check=False) -10 |-anothername(["foo"], universal_newlines=True) - 10 |+anothername(["foo"], text=True) -11 11 | -12 12 | subprocess.run(["foo"], check=True) +9 9 | # OK +10 10 | subprocess.run(["foo"], check=True) diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap index 75df54757d..5d8ff0b364 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap @@ -157,6 +157,8 @@ UP022.py:29:14: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, 35 | | encoding="utf-8", 36 | | ) | |_____^ UP022 +37 | +38 | output = subprocess.run( | = help: Replace with `capture_output` keyword argument @@ -172,4 +174,46 @@ UP022.py:29:14: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, 35 34 | encoding="utf-8", 36 35 | ) +UP022.py:38:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +36 | ) +37 | +38 | output = subprocess.run( + | __________^ +39 | | ["foo"], stdout=subprocess.PIPE, capture_output=True, stderr=subprocess.PIPE +40 | | ) + | |_^ UP022 +41 | +42 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +UP022.py:42:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +40 | ) +41 | +42 | output = subprocess.run( + | __________^ +43 | | ["foo"], stdout=subprocess.PIPE, capture_output=False, stderr=subprocess.PIPE +44 | | ) + | |_^ UP022 +45 | +46 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +UP022.py:46:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +44 | ) +45 | +46 | output = subprocess.run( + | __________^ +47 | | ["foo"], capture_output=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE +48 | | ) + | |_^ UP022 +49 | +50 | # OK + | + = help: Replace with `capture_output` keyword argument + diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap index f77d7d36a6..aa0859fd46 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap @@ -264,4 +264,22 @@ UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError` 89 89 | 90 90 | try: +UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError` + | +103 | try: +104 | mac_address = get_primary_mac_address() +105 | except(IOError, OSError) as ex: + | ^^^^^^^^^^^^^^^^^^ UP024 +106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) + | + = help: Replace with builtin `OSError` + +ℹ Fix +102 102 | def get_owner_id_from_mac_address(): +103 103 | try: +104 104 | mac_address = get_primary_mac_address() +105 |- except(IOError, OSError) as ex: + 105 |+ except OSError as ex: +106 106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) + diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap index a897e0554e..56035122f8 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap @@ -270,5 +270,33 @@ UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 73 |- yield x, y 72 |+ yield from z() 74 73 | x = 1 +75 74 | +76 75 | + +UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 +78 | def _serve_method(fn): +79 | for h in ( + | _____^ +80 | | TaggedText.from_file(args.input) +81 | | .markup(highlight=args.region) +82 | | ): +83 | | yield h + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +76 76 | +77 77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 +78 78 | def _serve_method(fn): +79 |- for h in ( + 79 |+ yield from ( +80 80 | TaggedText.from_file(args.input) +81 81 | .markup(highlight=args.region) +82 |- ): +83 |- yield h + 82 |+ ) diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap index 04319f36dc..323380add2 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap @@ -931,7 +931,7 @@ UP035.py:74:1: UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` 74 |+from collections.abc import AsyncGenerator 75 75 | from typing import Reversible 76 76 | from typing import Generator -77 77 | +77 77 | from typing import Callable UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` | @@ -940,6 +940,7 @@ UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` 75 | from typing import Reversible | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 76 | from typing import Generator +77 | from typing import Callable | = help: Import from `collections.abc` @@ -950,8 +951,8 @@ UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` 75 |-from typing import Reversible 75 |+from collections.abc import Reversible 76 76 | from typing import Generator -77 77 | -78 78 | # OK +77 77 | from typing import Callable +78 78 | from typing import cast UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` | @@ -959,8 +960,8 @@ UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` 75 | from typing import Reversible 76 | from typing import Generator | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -77 | -78 | # OK +77 | from typing import Callable +78 | from typing import cast | = help: Import from `collections.abc` @@ -970,23 +971,63 @@ UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` 75 75 | from typing import Reversible 76 |-from typing import Generator 76 |+from collections.abc import Generator -77 77 | -78 78 | # OK -79 79 | from a import b +77 77 | from typing import Callable +78 78 | from typing import cast +79 79 | -UP035.py:88:1: UP035 [*] Import from `typing` instead: `dataclass_transform` +UP035.py:77:1: UP035 [*] Import from `collections.abc` instead: `Callable` | -87 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). -88 | from typing_extensions import dataclass_transform +75 | from typing import Reversible +76 | from typing import Generator +77 | from typing import Callable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +78 | from typing import cast + | + = help: Import from `collections.abc` + +ℹ Suggested fix +74 74 | from typing import AsyncGenerator +75 75 | from typing import Reversible +76 76 | from typing import Generator +77 |-from typing import Callable + 77 |+from collections.abc import Callable +78 78 | from typing import cast +79 79 | +80 80 | # OK + +UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` + | +86 | # Ok: `typing_extensions` contains backported improvements. +87 | from typing_extensions import NamedTuple + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +88 | +89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). + | + = help: Import from `typing` + +ℹ Suggested fix +84 84 | from typing_extensions import SupportsIndex +85 85 | +86 86 | # Ok: `typing_extensions` contains backported improvements. +87 |-from typing_extensions import NamedTuple + 87 |+from typing import NamedTuple +88 88 | +89 89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). +90 90 | from typing_extensions import dataclass_transform + +UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` + | +89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). +90 | from typing_extensions import dataclass_transform | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 | = help: Import from `typing` ℹ Suggested fix -85 85 | from typing_extensions import NamedTuple -86 86 | -87 87 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). -88 |-from typing_extensions import dataclass_transform - 88 |+from typing import dataclass_transform +87 87 | from typing_extensions import NamedTuple +88 88 | +89 89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). +90 |-from typing_extensions import dataclass_transform + 90 |+from typing import dataclass_transform diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap index 4fccfbe7b3..a2966d46d5 100644 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap +++ b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap @@ -662,5 +662,27 @@ UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version 178 178 | if True: 179 |- if sys.version_info > (3, 0): \ 180 179 | expected_error = [] +181 180 | +182 181 | if sys.version_info < (3,12): + +UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version + | +180 | expected_error = [] +181 | +182 | if sys.version_info < (3,12): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +183 | print("py3") + | + = help: Remove outdated version block + +ℹ Suggested fix +179 179 | if sys.version_info > (3, 0): \ +180 180 | expected_error = [] +181 181 | +182 |-if sys.version_info < (3,12): +183 |- print("py3") +184 182 | +185 183 | if sys.version_info <= (3,12): +186 184 | print("py3") diff --git a/crates/ruff/src/rules/refurb/helpers.rs b/crates/ruff/src/rules/refurb/helpers.rs new file mode 100644 index 0000000000..e432d5b7b8 --- /dev/null +++ b/crates/ruff/src/rules/refurb/helpers.rs @@ -0,0 +1,36 @@ +use ruff_python_ast as ast; +use ruff_python_codegen::Generator; +use ruff_text_size::TextRange; + +/// Format a code snippet to call `name.method()`. +pub(super) fn generate_method_call(name: &str, method: &str, generator: Generator) -> String { + // Construct `name`. + let var = ast::ExprName { + id: name.to_string(), + ctx: ast::ExprContext::Load, + range: TextRange::default(), + }; + // Construct `name.method`. + let attr = ast::ExprAttribute { + value: Box::new(var.into()), + attr: ast::Identifier::new(method.to_string(), TextRange::default()), + ctx: ast::ExprContext::Load, + range: TextRange::default(), + }; + // Make it into a call `name.method()` + let call = ast::ExprCall { + func: Box::new(attr.into()), + arguments: ast::Arguments { + args: vec![], + keywords: vec![], + range: TextRange::default(), + }, + range: TextRange::default(), + }; + // And finally, turn it into a statement. + let stmt = ast::StmtExpr { + value: Box::new(call.into()), + range: TextRange::default(), + }; + generator.stmt(&stmt.into()) +} diff --git a/crates/ruff/src/rules/refurb/mod.rs b/crates/ruff/src/rules/refurb/mod.rs index 2e5e5a59d9..a910946595 100644 --- a/crates/ruff/src/rules/refurb/mod.rs +++ b/crates/ruff/src/rules/refurb/mod.rs @@ -1,5 +1,6 @@ //! Rules from [refurb](https://pypi.org/project/refurb/)/ +mod helpers; pub(crate) mod rules; #[cfg(test)] @@ -16,6 +17,7 @@ mod tests { #[test_case(Rule::RepeatedAppend, Path::new("FURB113.py"))] #[test_case(Rule::DeleteFullSlice, Path::new("FURB131.py"))] #[test_case(Rule::CheckAndRemoveFromSet, Path::new("FURB132.py"))] + #[test_case(Rule::SliceCopy, Path::new("FURB145.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/refurb/rules/check_and_remove_from_set.rs b/crates/ruff/src/rules/refurb/rules/check_and_remove_from_set.rs index 80685be3f3..b251129db7 100644 --- a/crates/ruff/src/rules/refurb/rules/check_and_remove_from_set.rs +++ b/crates/ruff/src/rules/refurb/rules/check_and_remove_from_set.rs @@ -18,6 +18,11 @@ use crate::registry::AsRule; /// If an element should be removed from a set if it is present, it is more /// succinct and idiomatic to use `discard`. /// +/// ## Known problems +/// This rule is prone to false negatives due to type inference limitations, +/// as it will only detect sets that are instantiated as literals or annotated +/// with a type annotation. +/// /// ## Example /// ```python /// nums = {123, 456} diff --git a/crates/ruff/src/rules/refurb/rules/delete_full_slice.rs b/crates/ruff/src/rules/refurb/rules/delete_full_slice.rs index b284a744ae..e84b081761 100644 --- a/crates/ruff/src/rules/refurb/rules/delete_full_slice.rs +++ b/crates/ruff/src/rules/refurb/rules/delete_full_slice.rs @@ -1,13 +1,13 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::{self as ast, Expr}; -use ruff_python_codegen::Generator; use ruff_python_semantic::analyze::typing::{is_dict, is_list}; use ruff_python_semantic::{Binding, SemanticModel}; -use ruff_text_size::{Ranged, TextRange}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; +use crate::rules::refurb::helpers::generate_method_call; /// ## What it does /// Checks for `del` statements that delete the entire slice of a list or @@ -17,6 +17,11 @@ use crate::registry::AsRule; /// It's is faster and more succinct to remove all items via the `clear()` /// method. /// +/// ## Known problems +/// This rule is prone to false negatives due to type inference limitations, +/// as it will only detect lists and dictionaries that are instantiated as +/// literals or annotated with a type annotation. +/// /// ## Example /// ```python /// names = {"key": "value"} @@ -65,7 +70,7 @@ pub(crate) fn delete_full_slice(checker: &mut Checker, delete: &ast::StmtDelete) // Fix is only supported for single-target deletions. if checker.patch(diagnostic.kind.rule()) && delete.targets.len() == 1 { - let replacement = make_suggestion(name, checker.generator()); + let replacement = generate_method_call(name, "clear", checker.generator()); diagnostic.set_fix(Fix::suggested(Edit::replacement( replacement, delete.start(), @@ -118,38 +123,3 @@ fn match_full_slice<'a>(expr: &'a Expr, semantic: &SemanticModel) -> Option<&'a // Name is needed for the fix suggestion. Some(name) } - -/// Make fix suggestion for the given name, ie `name.clear()`. -fn make_suggestion(name: &str, generator: Generator) -> String { - // Here we construct `var.clear()` - // - // And start with construction of `var` - let var = ast::ExprName { - id: name.to_string(), - ctx: ast::ExprContext::Load, - range: TextRange::default(), - }; - // Make `var.clear`. - let attr = ast::ExprAttribute { - value: Box::new(var.into()), - attr: ast::Identifier::new("clear".to_string(), TextRange::default()), - ctx: ast::ExprContext::Load, - range: TextRange::default(), - }; - // Make it into a call `var.clear()` - let call = ast::ExprCall { - func: Box::new(attr.into()), - arguments: ast::Arguments { - args: vec![], - keywords: vec![], - range: TextRange::default(), - }, - range: TextRange::default(), - }; - // And finally, turn it into a statement. - let stmt = ast::StmtExpr { - value: Box::new(call.into()), - range: TextRange::default(), - }; - generator.stmt(&stmt.into()) -} diff --git a/crates/ruff/src/rules/refurb/rules/mod.rs b/crates/ruff/src/rules/refurb/rules/mod.rs index 1ea05511ee..414a4168f4 100644 --- a/crates/ruff/src/rules/refurb/rules/mod.rs +++ b/crates/ruff/src/rules/refurb/rules/mod.rs @@ -1,7 +1,9 @@ pub(crate) use check_and_remove_from_set::*; pub(crate) use delete_full_slice::*; pub(crate) use repeated_append::*; +pub(crate) use slice_copy::*; mod check_and_remove_from_set; mod delete_full_slice; mod repeated_append; +mod slice_copy; diff --git a/crates/ruff/src/rules/refurb/rules/repeated_append.rs b/crates/ruff/src/rules/refurb/rules/repeated_append.rs index 8557138f04..90737de739 100644 --- a/crates/ruff/src/rules/refurb/rules/repeated_append.rs +++ b/crates/ruff/src/rules/refurb/rules/repeated_append.rs @@ -21,6 +21,11 @@ use crate::registry::AsRule; /// a single `extend`. Each `append` resizes the list individually, whereas an /// `extend` can resize the list once for all elements. /// +/// ## Known problems +/// This rule is prone to false negatives due to type inference limitations, +/// as it will only detect lists that are instantiated as literals or annotated +/// with a type annotation. +/// /// ## Example /// ```python /// nums = [1, 2, 3] diff --git a/crates/ruff/src/rules/refurb/rules/slice_copy.rs b/crates/ruff/src/rules/refurb/rules/slice_copy.rs new file mode 100644 index 0000000000..996915822f --- /dev/null +++ b/crates/ruff/src/rules/refurb/rules/slice_copy.rs @@ -0,0 +1,109 @@ +use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; +use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_python_semantic::analyze::typing::is_list; +use ruff_python_semantic::{Binding, SemanticModel}; +use ruff_text_size::Ranged; + +use crate::checkers::ast::Checker; +use crate::registry::AsRule; +use crate::rules::refurb::helpers::generate_method_call; + +/// ## What it does +/// Checks for unbounded slice expressions to copy a list. +/// +/// ## Why is this bad? +/// The `list#copy` method is more readable and consistent with copying other +/// types. +/// +/// ## Known problems +/// This rule is prone to false negatives due to type inference limitations, +/// as it will only detect lists that are instantiated as literals or annotated +/// with a type annotation. +/// +/// ## Example +/// ```python +/// a = [1, 2, 3] +/// b = a[:] +/// ``` +/// +/// Use instead: +/// ```python +/// a = [1, 2, 3] +/// b = a.copy() +/// ``` +/// +/// ## References +/// - [Python documentation: Mutable Sequence Types](https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types) +#[violation] +pub struct SliceCopy; + +impl Violation for SliceCopy { + const AUTOFIX: AutofixKind = AutofixKind::Sometimes; + + #[derive_message_formats] + fn message(&self) -> String { + format!("Prefer `copy` method over slicing") + } + + fn autofix_title(&self) -> Option { + Some("Replace with `copy()`".to_string()) + } +} + +/// FURB145 +pub(crate) fn slice_copy(checker: &mut Checker, subscript: &ast::ExprSubscript) { + if subscript.ctx.is_store() || subscript.ctx.is_del() { + return; + } + + let Some(name) = match_list_full_slice(subscript, checker.semantic()) else { + return; + }; + let mut diagnostic = Diagnostic::new(SliceCopy, subscript.range()); + if checker.patch(diagnostic.kind.rule()) { + let replacement = generate_method_call(name, "copy", checker.generator()); + diagnostic.set_fix(Fix::suggested(Edit::replacement( + replacement, + subscript.start(), + subscript.end(), + ))); + } + checker.diagnostics.push(diagnostic); +} + +/// Matches `obj[:]` where `obj` is a list. +fn match_list_full_slice<'a>( + subscript: &'a ast::ExprSubscript, + semantic: &SemanticModel, +) -> Option<&'a str> { + // Check that it is `obj[:]`. + if !matches!( + subscript.slice.as_ref(), + Expr::Slice(ast::ExprSlice { + lower: None, + upper: None, + step: None, + range: _, + }) + ) { + return None; + } + + let ast::ExprName { id, .. } = subscript.value.as_name_expr()?; + + // Check that `obj` is a list. + let scope = semantic.current_scope(); + let bindings: Vec<&Binding> = scope + .get_all(id) + .map(|binding_id| semantic.binding(binding_id)) + .collect(); + let [binding] = bindings.as_slice() else { + return None; + }; + if !is_list(binding, semantic) { + return None; + } + + Some(id) +} diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB145_FURB145.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB145_FURB145.py.snap new file mode 100644 index 0000000000..6686c0f3af --- /dev/null +++ b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB145_FURB145.py.snap @@ -0,0 +1,128 @@ +--- +source: crates/ruff/src/rules/refurb/mod.rs +--- +FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing + | +3 | # Errors. +4 | a = l[:] + | ^^^^ FURB145 +5 | b, c = 1, l[:] +6 | d, e = l[:], 1 + | + = help: Replace with `copy()` + +ℹ Suggested fix +1 1 | l = [1, 2, 3, 4, 5] +2 2 | +3 3 | # Errors. +4 |-a = l[:] + 4 |+a = l.copy() +5 5 | b, c = 1, l[:] +6 6 | d, e = l[:], 1 +7 7 | m = l[::] + +FURB145.py:5:11: FURB145 [*] Prefer `copy` method over slicing + | +3 | # Errors. +4 | a = l[:] +5 | b, c = 1, l[:] + | ^^^^ FURB145 +6 | d, e = l[:], 1 +7 | m = l[::] + | + = help: Replace with `copy()` + +ℹ Suggested fix +2 2 | +3 3 | # Errors. +4 4 | a = l[:] +5 |-b, c = 1, l[:] + 5 |+b, c = 1, l.copy() +6 6 | d, e = l[:], 1 +7 7 | m = l[::] +8 8 | l[:] + +FURB145.py:6:8: FURB145 [*] Prefer `copy` method over slicing + | +4 | a = l[:] +5 | b, c = 1, l[:] +6 | d, e = l[:], 1 + | ^^^^ FURB145 +7 | m = l[::] +8 | l[:] + | + = help: Replace with `copy()` + +ℹ Suggested fix +3 3 | # Errors. +4 4 | a = l[:] +5 5 | b, c = 1, l[:] +6 |-d, e = l[:], 1 + 6 |+d, e = l.copy(), 1 +7 7 | m = l[::] +8 8 | l[:] +9 9 | print(l[:]) + +FURB145.py:7:5: FURB145 [*] Prefer `copy` method over slicing + | +5 | b, c = 1, l[:] +6 | d, e = l[:], 1 +7 | m = l[::] + | ^^^^^ FURB145 +8 | l[:] +9 | print(l[:]) + | + = help: Replace with `copy()` + +ℹ Suggested fix +4 4 | a = l[:] +5 5 | b, c = 1, l[:] +6 6 | d, e = l[:], 1 +7 |-m = l[::] + 7 |+m = l.copy() +8 8 | l[:] +9 9 | print(l[:]) +10 10 | + +FURB145.py:8:1: FURB145 [*] Prefer `copy` method over slicing + | +6 | d, e = l[:], 1 +7 | m = l[::] +8 | l[:] + | ^^^^ FURB145 +9 | print(l[:]) + | + = help: Replace with `copy()` + +ℹ Suggested fix +5 5 | b, c = 1, l[:] +6 6 | d, e = l[:], 1 +7 7 | m = l[::] +8 |-l[:] + 8 |+l.copy() +9 9 | print(l[:]) +10 10 | +11 11 | # False negatives. + +FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing + | + 7 | m = l[::] + 8 | l[:] + 9 | print(l[:]) + | ^^^^ FURB145 +10 | +11 | # False negatives. + | + = help: Replace with `copy()` + +ℹ Suggested fix +6 6 | d, e = l[:], 1 +7 7 | m = l[::] +8 8 | l[:] +9 |-print(l[:]) + 9 |+print(l.copy()) +10 10 | +11 11 | # False negatives. +12 12 | aa = a[:] # Type inference. + + diff --git a/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs b/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs index 0a95e4359c..50d600fe59 100644 --- a/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs +++ b/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs @@ -2,7 +2,7 @@ use std::fmt; use bitflags::bitflags; -use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, DiagnosticKind, Edit, Fix}; +use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_source_file::Locator; use ruff_text_size::{TextLen, TextRange, TextSize}; @@ -34,7 +34,7 @@ pub struct AmbiguousUnicodeCharacterString { representant: char, } -impl AlwaysAutofixableViolation for AmbiguousUnicodeCharacterString { +impl Violation for AmbiguousUnicodeCharacterString { #[derive_message_formats] fn message(&self) -> String { let AmbiguousUnicodeCharacterString { @@ -47,18 +47,6 @@ impl AlwaysAutofixableViolation for AmbiguousUnicodeCharacterString { NamedUnicode(*representant) ) } - - fn autofix_title(&self) -> String { - let AmbiguousUnicodeCharacterString { - confusable, - representant, - } = self; - format!( - "Replace {} with {}", - NamedUnicode(*confusable), - NamedUnicode(*representant) - ) - } } /// ## What it does @@ -83,7 +71,7 @@ pub struct AmbiguousUnicodeCharacterDocstring { representant: char, } -impl AlwaysAutofixableViolation for AmbiguousUnicodeCharacterDocstring { +impl Violation for AmbiguousUnicodeCharacterDocstring { #[derive_message_formats] fn message(&self) -> String { let AmbiguousUnicodeCharacterDocstring { @@ -96,18 +84,6 @@ impl AlwaysAutofixableViolation for AmbiguousUnicodeCharacterDocstring { NamedUnicode(*representant) ) } - - fn autofix_title(&self) -> String { - let AmbiguousUnicodeCharacterDocstring { - confusable, - representant, - } = self; - format!( - "Replace {} with {}", - NamedUnicode(*confusable), - NamedUnicode(*representant) - ) - } } /// ## What it does @@ -132,7 +108,7 @@ pub struct AmbiguousUnicodeCharacterComment { representant: char, } -impl AlwaysAutofixableViolation for AmbiguousUnicodeCharacterComment { +impl Violation for AmbiguousUnicodeCharacterComment { #[derive_message_formats] fn message(&self) -> String { let AmbiguousUnicodeCharacterComment { @@ -145,18 +121,6 @@ impl AlwaysAutofixableViolation for AmbiguousUnicodeCharacterComment { NamedUnicode(*representant) ) } - - fn autofix_title(&self) -> String { - let AmbiguousUnicodeCharacterComment { - confusable, - representant, - } = self; - format!( - "Replace {} with {}", - NamedUnicode(*confusable), - NamedUnicode(*representant) - ) - } } pub(crate) fn ambiguous_unicode_character( @@ -280,7 +244,7 @@ impl Candidate { fn into_diagnostic(self, context: Context, settings: &Settings) -> Option { if !settings.allowed_confusables.contains(&self.confusable) { let char_range = TextRange::at(self.offset, self.confusable.text_len()); - let mut diagnostic = Diagnostic::new::( + let diagnostic = Diagnostic::new::( match context { Context::String => AmbiguousUnicodeCharacterString { confusable: self.confusable, @@ -301,12 +265,6 @@ impl Candidate { char_range, ); if settings.rules.enabled(diagnostic.kind.rule()) { - if settings.rules.should_fix(diagnostic.kind.rule()) { - diagnostic.set_fix(Fix::manual(Edit::range_replacement( - self.representant.to_string(), - char_range, - ))); - } return Some(diagnostic); } } diff --git a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs b/crates/ruff/src/rules/ruff/rules/implicit_optional.rs index 1674a028a8..1a87b6471c 100644 --- a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs +++ b/crates/ruff/src/rules/ruff/rules/implicit_optional.rs @@ -129,7 +129,6 @@ fn generate_fix(checker: &Checker, conversion_type: ConversionType, expr: &Expr) op: Operator::BitOr, right: Box::new(Expr::Constant(ast::ExprConstant { value: Constant::None, - kind: None, range: TextRange::default(), })), range: TextRange::default(), @@ -188,7 +187,6 @@ pub(crate) fn implicit_optional(checker: &mut Checker, parameters: &Parameters) if let Expr::Constant(ast::ExprConstant { range, value: Constant::Str(string), - .. }) = annotation.as_ref() { // Quoted annotation. diff --git a/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs b/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs index 62f51692fe..1d85555132 100644 --- a/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs +++ b/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use itertools::Itertools; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; @@ -106,7 +107,7 @@ fn convert_to_reduce(iterable: &Expr, call: &ast::ExprCall, checker: &Checker) - format!("{reduce_binding}({iadd_binding}, {iterable}, [])"), call.range(), ), - [reduce_edit, iadd_edit], + [reduce_edit, iadd_edit].into_iter().dedup(), )) } diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap index b05d32ea23..4cda3a5c80 100644 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap +++ b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap @@ -131,4 +131,20 @@ RUF017.py:9:1: RUF017 [*] Avoid quadratic list summation 12 13 | # OK 13 14 | sum([x, y]) +RUF017.py:21:5: RUF017 [*] Avoid quadratic list summation + | +19 | import functools, operator +20 | +21 | sum([x, y], []) + | ^^^^^^^^^^^^^^^ RUF017 + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix +18 18 | def func(): +19 19 | import functools, operator +20 20 | +21 |- sum([x, y], []) + 21 |+ functools.reduce(operator.iadd, [x, y], []) + diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap index 23057ef9eb..e5df2e7ca5 100644 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap +++ b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap @@ -1,22 +1,14 @@ --- source: crates/ruff/src/rules/ruff/mod.rs --- -confusables.py:1:6: RUF001 [*] String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? | 1 | x = "𝐁ad string" | ^ RUF001 2 | y = "−" | - = help: Replace `𝐁` (MATHEMATICAL BOLD CAPITAL B) with `B` (LATIN CAPITAL LETTER B) -ℹ Possible fix -1 |-x = "𝐁ad string" - 1 |+x = "Bad string" -2 2 | y = "−" -3 3 | -4 4 | - -confusables.py:6:56: RUF002 [*] Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? +confusables.py:6:56: RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? | 5 | def f(): 6 | """Here's a docstring with an unusual parenthesis: )""" @@ -24,19 +16,8 @@ confusables.py:6:56: RUF002 [*] Docstring contains ambiguous `)` (FULLWIDTH RI 7 | # And here's a comment with an unusual punctuation mark: ᜵ 8 | ... | - = help: Replace `)` (FULLWIDTH RIGHT PARENTHESIS) with `)` (RIGHT PARENTHESIS) -ℹ Possible fix -3 3 | -4 4 | -5 5 | def f(): -6 |- """Here's a docstring with an unusual parenthesis: )""" - 6 |+ """Here's a docstring with an unusual parenthesis: )""" -7 7 | # And here's a comment with an unusual punctuation mark: ᜵ -8 8 | ... -9 9 | - -confusables.py:7:62: RUF003 [*] Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? +confusables.py:7:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? | 5 | def f(): 6 | """Here's a docstring with an unusual parenthesis: )""" @@ -44,37 +25,15 @@ confusables.py:7:62: RUF003 [*] Comment contains ambiguous `᜵` (PHILIPPINE SIN | ^ RUF003 8 | ... | - = help: Replace `᜵` (PHILIPPINE SINGLE PUNCTUATION) with `/` (SOLIDUS) -ℹ Possible fix -4 4 | -5 5 | def f(): -6 6 | """Here's a docstring with an unusual parenthesis: )""" -7 |- # And here's a comment with an unusual punctuation mark: ᜵ - 7 |+ # And here's a comment with an unusual punctuation mark: / -8 8 | ... -9 9 | -10 10 | - -confusables.py:17:6: RUF001 [*] String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +confusables.py:17:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? | 17 | x = "𝐁ad string" | ^ RUF001 18 | x = "−" | - = help: Replace `𝐁` (MATHEMATICAL BOLD CAPITAL B) with `B` (LATIN CAPITAL LETTER B) -ℹ Possible fix -14 14 | ... -15 15 | -16 16 | -17 |-x = "𝐁ad string" - 17 |+x = "Bad string" -18 18 | x = "−" -19 19 | -20 20 | # This should be ignored, since it contains an unambiguous unicode character, and no - -confusables.py:26:10: RUF001 [*] String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? +confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? | 24 | # The first word should be ignored, while the second should be included, since it 25 | # contains ASCII. @@ -83,48 +42,21 @@ confusables.py:26:10: RUF001 [*] String contains ambiguous `α` (GREEK SMALL LET 27 | 28 | # The two characters should be flagged here. The first character is a "word" | - = help: Replace `α` (GREEK SMALL LETTER ALPHA) with `a` (LATIN SMALL LETTER A) -ℹ Possible fix -23 23 | -24 24 | # The first word should be ignored, while the second should be included, since it -25 25 | # contains ASCII. -26 |-x = "βα Bαd" - 26 |+x = "βα Bad" -27 27 | -28 28 | # The two characters should be flagged here. The first character is a "word" -29 29 | # consisting of a single ambiguous character, while the second character is a "word - -confusables.py:31:6: RUF001 [*] String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? | 29 | # consisting of a single ambiguous character, while the second character is a "word 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" | ^ RUF001 | - = help: Replace `Р` (CYRILLIC CAPITAL LETTER ER) with `P` (LATIN CAPITAL LETTER P) -ℹ Possible fix -28 28 | # The two characters should be flagged here. The first character is a "word" -29 29 | # consisting of a single ambiguous character, while the second character is a "word -30 30 | # boundary" (whitespace) that it itself ambiguous. -31 |-x = "Р усский" - 31 |+x = "P усский" - -confusables.py:31:7: RUF001 [*] String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? | 29 | # consisting of a single ambiguous character, while the second character is a "word 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" | ^ RUF001 | - = help: Replace ` ` (EN QUAD) with ` ` (SPACE) - -ℹ Possible fix -28 28 | # The two characters should be flagged here. The first character is a "word" -29 29 | # consisting of a single ambiguous character, while the second character is a "word -30 30 | # boundary" (whitespace) that it itself ambiguous. -31 |-x = "Р усский" - 31 |+x = "Р усский" diff --git a/crates/ruff/src/rules/ruff/typing.rs b/crates/ruff/src/rules/ruff/typing.rs index f33d748375..54d510b8b3 100644 --- a/crates/ruff/src/rules/ruff/typing.rs +++ b/crates/ruff/src/rules/ruff/typing.rs @@ -114,7 +114,6 @@ impl<'a> TypingTarget<'a> { Expr::Constant(ast::ExprConstant { value: Constant::Str(string), range, - .. }) => parse_type_annotation(string, *range, locator.contents()) .map_or(None, |(expr, _)| Some(TypingTarget::ForwardReference(expr))), _ => semantic.resolve_call_path(expr).map_or( diff --git a/crates/ruff/src/settings/defaults.rs b/crates/ruff/src/settings/defaults.rs index a7ef3d3b88..1ed635e290 100644 --- a/crates/ruff/src/settings/defaults.rs +++ b/crates/ruff/src/settings/defaults.rs @@ -4,12 +4,12 @@ use regex::Regex; use rustc_hash::FxHashSet; use std::collections::HashSet; -use super::types::{FilePattern, PythonVersion}; +use super::types::{FilePattern, PreviewMode, PythonVersion}; use super::Settings; use crate::codes::{self, RuleCodePrefix}; use crate::line_width::{LineLength, TabSize}; use crate::registry::Linter; -use crate::rule_selector::{prefix_to_selector, RuleSelector}; +use crate::rule_selector::RuleSelector; use crate::rules::{ flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions, flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, @@ -20,7 +20,10 @@ use crate::rules::{ use crate::settings::types::FilePatternSet; pub const PREFIXES: &[RuleSelector] = &[ - prefix_to_selector(RuleCodePrefix::Pycodestyle(codes::Pycodestyle::E)), + RuleSelector::Prefix { + prefix: RuleCodePrefix::Pycodestyle(codes::Pycodestyle::E), + redirected_from: None, + }, RuleSelector::Linter(Linter::Pyflakes), ]; @@ -70,7 +73,10 @@ pub static INCLUDE: Lazy> = Lazy::new(|| { impl Default for Settings { fn default() -> Self { Self { - rules: PREFIXES.iter().flat_map(IntoIterator::into_iter).collect(), + rules: PREFIXES + .iter() + .flat_map(|selector| selector.rules(PreviewMode::default())) + .collect(), allowed_confusables: FxHashSet::from_iter([]), builtins: vec![], dummy_variable_rgx: DUMMY_VARIABLE_RGX.clone(), @@ -84,6 +90,7 @@ impl Default for Settings { line_length: LineLength::default(), logger_objects: vec![], namespace_packages: vec![], + preview: PreviewMode::default(), per_file_ignores: vec![], project_root: path_dedot::CWD.clone(), respect_gitignore: true, diff --git a/crates/ruff/src/settings/mod.rs b/crates/ruff/src/settings/mod.rs index edf5aaaebd..ea5d38aa98 100644 --- a/crates/ruff/src/settings/mod.rs +++ b/crates/ruff/src/settings/mod.rs @@ -24,6 +24,7 @@ use crate::settings::types::{FilePatternSet, PerFileIgnore, PythonVersion, Seria use super::line_width::{LineLength, TabSize}; use self::rule_table::RuleTable; +use self::types::PreviewMode; pub mod defaults; pub mod flags; @@ -55,6 +56,7 @@ pub struct Settings { pub per_file_ignores: Vec<(GlobMatcher, GlobMatcher, RuleSet)>, pub target_version: PythonVersion, + pub preview: PreviewMode, // Resolver settings pub exclude: FilePatternSet, diff --git a/crates/ruff/src/settings/types.rs b/crates/ruff/src/settings/types.rs index 8461604425..9d3cbe0a00 100644 --- a/crates/ruff/src/settings/types.rs +++ b/crates/ruff/src/settings/types.rs @@ -92,6 +92,23 @@ impl PythonVersion { } } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, CacheKey, is_macro::Is)] +pub enum PreviewMode { + #[default] + Disabled, + Enabled, +} + +impl From for PreviewMode { + fn from(version: bool) -> Self { + if version { + PreviewMode::Enabled + } else { + PreviewMode::Disabled + } + } +} + #[derive(Debug, Clone, CacheKey, PartialEq, PartialOrd, Eq, Ord)] pub enum FilePattern { Builtin(&'static str), @@ -177,7 +194,8 @@ pub struct PerFileIgnore { impl PerFileIgnore { pub fn new(pattern: String, prefixes: &[RuleSelector], project_root: Option<&Path>) -> Self { - let rules: RuleSet = prefixes.iter().flat_map(IntoIterator::into_iter).collect(); + // Rules in preview are included here even if preview mode is disabled; it's safe to ignore disabled rules + let rules: RuleSet = prefixes.iter().flat_map(RuleSelector::all_rules).collect(); let path = Path::new(&pattern); let absolute = match project_root { Some(project_root) => fs::normalize_path_to(path, project_root), diff --git a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__import_sorting.snap b/crates/ruff/src/snapshots/ruff__linter__tests__import_sorting.snap similarity index 97% rename from crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__import_sorting.snap rename to crates/ruff/src/snapshots/ruff__linter__tests__import_sorting.snap index e0ab3572a8..1bba6e1056 100644 --- a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__import_sorting.snap +++ b/crates/ruff/src/snapshots/ruff__linter__tests__import_sorting.snap @@ -1,5 +1,5 @@ --- -source: crates/ruff/src/jupyter/notebook.rs +source: crates/ruff/src/linter.rs --- isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted | diff --git a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__ipy_escape_command.snap b/crates/ruff/src/snapshots/ruff__linter__tests__ipy_escape_command.snap similarity index 87% rename from crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__ipy_escape_command.snap rename to crates/ruff/src/snapshots/ruff__linter__tests__ipy_escape_command.snap index 57f92d184e..c471bd56aa 100644 --- a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__ipy_escape_command.snap +++ b/crates/ruff/src/snapshots/ruff__linter__tests__ipy_escape_command.snap @@ -1,5 +1,5 @@ --- -source: crates/ruff/src/jupyter/notebook.rs +source: crates/ruff/src/linter.rs --- ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused | diff --git a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__unused_variable.snap b/crates/ruff/src/snapshots/ruff__linter__tests__unused_variable.snap similarity index 97% rename from crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__unused_variable.snap rename to crates/ruff/src/snapshots/ruff__linter__tests__unused_variable.snap index 689e20e25e..5557899715 100644 --- a/crates/ruff/src/jupyter/snapshots/ruff__jupyter__notebook__tests__unused_variable.snap +++ b/crates/ruff/src/snapshots/ruff__linter__tests__unused_variable.snap @@ -1,5 +1,5 @@ --- -source: crates/ruff/src/jupyter/notebook.rs +source: crates/ruff/src/linter.rs --- unused_variable.ipynb:cell 1:2:5: F841 [*] Local variable `foo1` is assigned to but never used | diff --git a/crates/ruff/src/source_kind.rs b/crates/ruff/src/source_kind.rs index ac2d650f37..501d417366 100644 --- a/crates/ruff/src/source_kind.rs +++ b/crates/ruff/src/source_kind.rs @@ -1,5 +1,5 @@ -use crate::autofix::source_map::SourceMap; -use crate::jupyter::Notebook; +use ruff_diagnostics::SourceMap; +use ruff_notebook::Notebook; #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum SourceKind { @@ -10,15 +10,6 @@ pub enum SourceKind { } impl SourceKind { - /// Return the [`Notebook`] if the source kind is [`SourceKind::IpyNotebook`]. - pub fn notebook(&self) -> Option<&Notebook> { - if let Self::IpyNotebook(notebook) = self { - Some(notebook) - } else { - None - } - } - #[must_use] pub(crate) fn updated(&self, new_source: String, source_map: &SourceMap) -> Self { match self { diff --git a/crates/ruff/src/test.rs b/crates/ruff/src/test.rs index b322d5b919..9edcc0e8e4 100644 --- a/crates/ruff/src/test.rs +++ b/crates/ruff/src/test.rs @@ -21,7 +21,6 @@ use ruff_text_size::Ranged; use crate::autofix::{fix_file, FixResult}; use crate::directives; -use crate::jupyter::Notebook; use crate::linter::{check_path, LinterResult}; use crate::message::{Emitter, EmitterContext, Message, TextEmitter}; use crate::packaging::detect_package_root; @@ -29,18 +28,7 @@ use crate::registry::AsRule; use crate::rules::pycodestyle::rules::syntax_error; use crate::settings::{flags, Settings}; use crate::source_kind::SourceKind; - -#[cfg(not(fuzzing))] -pub(crate) fn read_jupyter_notebook(path: &Path) -> Result { - let path = test_resource_path("fixtures/jupyter").join(path); - Notebook::from_path(&path).map_err(|err| { - anyhow::anyhow!( - "Failed to read notebook file `{}`: {:?}", - path.display(), - err - ) - }) -} +use ruff_notebook::{Notebook, NotebookError}; #[cfg(not(fuzzing))] pub(crate) fn test_resource_path(path: impl AsRef) -> std::path::PathBuf { @@ -67,12 +55,12 @@ pub(crate) fn test_notebook_path( path: impl AsRef, expected: impl AsRef, settings: &Settings, -) -> Result { - let source_notebook = read_jupyter_notebook(path.as_ref())?; +) -> Result { + let source_notebook = Notebook::from_path(path.as_ref())?; let source_kind = SourceKind::IpyNotebook(source_notebook); let (messages, transformed) = test_contents(&source_kind, path.as_ref(), settings); - let expected_notebook = read_jupyter_notebook(expected.as_ref())?; + let expected_notebook = Notebook::from_path(expected.as_ref())?; let linted_notebook = transformed.into_owned().expect_ipy_notebook(); assert_eq!( @@ -144,7 +132,7 @@ pub(crate) fn test_contents<'a>( &directives, settings, flags::Noqa::Enabled, - Some(source_kind), + source_kind, source_type, ); @@ -207,7 +195,7 @@ pub(crate) fn test_contents<'a>( &directives, settings, flags::Noqa::Enabled, - Some(source_kind), + source_kind, source_type, ); @@ -273,12 +261,8 @@ Source with applied fixes: (messages, transformed) } -fn print_diagnostics( - diagnostics: Vec, - file_path: &Path, - source: &SourceKind, -) -> String { - let filename = file_path.file_name().unwrap().to_string_lossy(); +fn print_diagnostics(diagnostics: Vec, path: &Path, source: &SourceKind) -> String { + let filename = path.file_name().unwrap().to_string_lossy(); let source_file = SourceFileBuilder::new(filename.as_ref(), source.source_code()).finish(); let messages: Vec<_> = diagnostics @@ -290,8 +274,8 @@ fn print_diagnostics( }) .collect(); - if let Some(notebook) = source.notebook() { - print_jupyter_messages(&messages, &filename, notebook) + if let Some(notebook) = source.as_ipy_notebook() { + print_jupyter_messages(&messages, path, notebook) } else { print_messages(&messages) } @@ -299,7 +283,7 @@ fn print_diagnostics( pub(crate) fn print_jupyter_messages( messages: &[Message], - filename: &str, + path: &Path, notebook: &Notebook, ) -> String { let mut output = Vec::new(); @@ -312,8 +296,8 @@ pub(crate) fn print_jupyter_messages( &mut output, messages, &EmitterContext::new(&FxHashMap::from_iter([( - filename.to_string(), - notebook.clone(), + path.file_name().unwrap().to_string_lossy().to_string(), + notebook.index().clone(), )])), ) .unwrap(); diff --git a/crates/ruff_benchmark/Cargo.toml b/crates/ruff_benchmark/Cargo.toml index 5753044d6c..9f0d30c973 100644 --- a/crates/ruff_benchmark/Cargo.toml +++ b/crates/ruff_benchmark/Cargo.toml @@ -18,6 +18,10 @@ bench = false name = "linter" harness = false +[[bench]] +name = "lexer" +harness = false + [[bench]] name = "parser" harness = false @@ -32,8 +36,8 @@ serde.workspace = true serde_json.workspace = true url = "2.3.1" ureq = "2.6.2" -criterion = { version = "0.5.1"} -codspeed-criterion-compat = { version="2.1.0", optional = true} +criterion = { version = "0.5.1", default-features = false } +codspeed-criterion-compat = { version="2.2.0", default-features = false, optional = true} [dev-dependencies] ruff.path = "../ruff" diff --git a/crates/ruff_benchmark/benches/formatter.rs b/crates/ruff_benchmark/benches/formatter.rs index cc52e167c0..603f13555c 100644 --- a/crates/ruff_benchmark/benches/formatter.rs +++ b/crates/ruff_benchmark/benches/formatter.rs @@ -1,10 +1,9 @@ use std::path::Path; -use std::time::Duration; use ruff_benchmark::criterion::{ criterion_group, criterion_main, BenchmarkId, Criterion, Throughput, }; -use ruff_benchmark::{TestCase, TestCaseSpeed, TestFile, TestFileDownloadError}; +use ruff_benchmark::{TestCase, TestFile, TestFileDownloadError}; use ruff_python_formatter::{format_node, PyFormatOptions}; use ruff_python_index::CommentRangesBuilder; use ruff_python_parser::lexer::lex; @@ -29,6 +28,7 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; fn create_test_cases() -> Result, TestFileDownloadError> { Ok(vec![ TestCase::fast(TestFile::try_download("numpy/globals.py", "https://raw.githubusercontent.com/numpy/numpy/89d64415e349ca75a25250f22b874aa16e5c0973/numpy/_globals.py")?), + TestCase::fast(TestFile::try_download("unicode/pypinyin.py", "https://raw.githubusercontent.com/mozillazg/python-pinyin/9521e47d96e3583a5477f5e43a2e82d513f27a3f/pypinyin/standard.py")?), TestCase::normal(TestFile::try_download( "pydantic/types.py", "https://raw.githubusercontent.com/pydantic/pydantic/83b3c49e99ceb4599d9286a3d793cea44ac36d4b/pydantic/types.py", @@ -48,12 +48,6 @@ fn benchmark_formatter(criterion: &mut Criterion) { for case in test_cases { group.throughput(Throughput::Bytes(case.code().len() as u64)); - group.measurement_time(match case.speed() { - TestCaseSpeed::Fast => Duration::from_secs(5), - TestCaseSpeed::Normal => Duration::from_secs(10), - TestCaseSpeed::Slow => Duration::from_secs(20), - }); - group.bench_with_input( BenchmarkId::from_parameter(case.name()), &case, diff --git a/crates/ruff_benchmark/benches/lexer.rs b/crates/ruff_benchmark/benches/lexer.rs new file mode 100644 index 0000000000..c31cb84b5e --- /dev/null +++ b/crates/ruff_benchmark/benches/lexer.rs @@ -0,0 +1,62 @@ +use ruff_benchmark::criterion::{ + criterion_group, criterion_main, measurement::WallTime, BenchmarkId, Criterion, Throughput, +}; +use ruff_benchmark::{TestCase, TestFile, TestFileDownloadError}; +use ruff_python_parser::{lexer, Mode}; + +#[cfg(target_os = "windows")] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + +#[cfg(all( + not(target_os = "windows"), + not(target_os = "openbsd"), + any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "powerpc64" + ) +))] +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + +fn create_test_cases() -> Result, TestFileDownloadError> { + Ok(vec![ + TestCase::fast(TestFile::try_download("numpy/globals.py", "https://raw.githubusercontent.com/numpy/numpy/89d64415e349ca75a25250f22b874aa16e5c0973/numpy/_globals.py")?), + TestCase::fast(TestFile::try_download("unicode/pypinyin.py", "https://raw.githubusercontent.com/mozillazg/python-pinyin/9521e47d96e3583a5477f5e43a2e82d513f27a3f/pypinyin/standard.py")?), + TestCase::normal(TestFile::try_download( + "pydantic/types.py", + "https://raw.githubusercontent.com/pydantic/pydantic/83b3c49e99ceb4599d9286a3d793cea44ac36d4b/pydantic/types.py", + )?), + TestCase::normal(TestFile::try_download("numpy/ctypeslib.py", "https://raw.githubusercontent.com/numpy/numpy/e42c9503a14d66adfd41356ef5640c6975c45218/numpy/ctypeslib.py")?), + TestCase::slow(TestFile::try_download( + "large/dataset.py", + "https://raw.githubusercontent.com/DHI/mikeio/b7d26418f4db2909b0aa965253dbe83194d7bb5b/tests/test_dataset.py", + )?), + ]) +} + +fn benchmark_lexer(criterion: &mut Criterion) { + let test_cases = create_test_cases().unwrap(); + let mut group = criterion.benchmark_group("lexer"); + + for case in test_cases { + group.throughput(Throughput::Bytes(case.code().len() as u64)); + group.bench_with_input( + BenchmarkId::from_parameter(case.name()), + &case, + |b, case| { + b.iter(|| { + let result = + lexer::lex(case.code(), Mode::Module).find(std::result::Result::is_err); + assert_eq!(result, None, "Input to be a valid Python program"); + }); + }, + ); + } + + group.finish(); +} + +criterion_group!(lexer, benchmark_lexer); +criterion_main!(lexer); diff --git a/crates/ruff_benchmark/benches/linter.rs b/crates/ruff_benchmark/benches/linter.rs index f48b55b7d7..91e77850e4 100644 --- a/crates/ruff_benchmark/benches/linter.rs +++ b/crates/ruff_benchmark/benches/linter.rs @@ -1,13 +1,12 @@ -use std::time::Duration; - use ruff::linter::lint_only; +use ruff::settings::rule_table::RuleTable; use ruff::settings::{flags, Settings}; use ruff::source_kind::SourceKind; -use ruff::RuleSelector; +use ruff::{registry::Rule, RuleSelector}; use ruff_benchmark::criterion::{ criterion_group, criterion_main, BenchmarkGroup, BenchmarkId, Criterion, Throughput, }; -use ruff_benchmark::{TestCase, TestCaseSpeed, TestFile, TestFileDownloadError}; +use ruff_benchmark::{TestCase, TestFile, TestFileDownloadError}; use ruff_python_ast::PySourceType; #[cfg(target_os = "windows")] @@ -29,6 +28,7 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; fn create_test_cases() -> Result, TestFileDownloadError> { Ok(vec![ TestCase::fast(TestFile::try_download("numpy/globals.py", "https://raw.githubusercontent.com/numpy/numpy/89d64415e349ca75a25250f22b874aa16e5c0973/numpy/_globals.py")?), + TestCase::fast(TestFile::try_download("unicode/pypinyin.py", "https://raw.githubusercontent.com/mozillazg/python-pinyin/9521e47d96e3583a5477f5e43a2e82d513f27a3f/pypinyin/standard.py")?), TestCase::normal(TestFile::try_download( "pydantic/types.py", "https://raw.githubusercontent.com/pydantic/pydantic/83b3c49e99ceb4599d9286a3d793cea44ac36d4b/pydantic/types.py", @@ -46,11 +46,6 @@ fn benchmark_linter(mut group: BenchmarkGroup, settings: &Settings) { for case in test_cases { group.throughput(Throughput::Bytes(case.code().len() as u64)); - group.measurement_time(match case.speed() { - TestCaseSpeed::Fast => Duration::from_secs(10), - TestCaseSpeed::Normal => Duration::from_secs(20), - TestCaseSpeed::Slow => Duration::from_secs(45), - }); group.bench_with_input( BenchmarkId::from_parameter(case.name()), @@ -84,8 +79,14 @@ fn benchmark_default_rules(criterion: &mut Criterion) { } fn benchmark_all_rules(criterion: &mut Criterion) { + let mut rules: RuleTable = RuleSelector::All.all_rules().collect(); + + // Disable IO based rules because it is a source of flakiness + rules.disable(Rule::ShebangMissingExecutableFile); + rules.disable(Rule::ShebangNotExecutable); + let settings = Settings { - rules: RuleSelector::All.into_iter().collect(), + rules, ..Settings::default() }; diff --git a/crates/ruff_benchmark/benches/parser.rs b/crates/ruff_benchmark/benches/parser.rs index 4efbb72f3c..6d208c78fd 100644 --- a/crates/ruff_benchmark/benches/parser.rs +++ b/crates/ruff_benchmark/benches/parser.rs @@ -1,9 +1,7 @@ -use std::time::Duration; - use ruff_benchmark::criterion::{ criterion_group, criterion_main, measurement::WallTime, BenchmarkId, Criterion, Throughput, }; -use ruff_benchmark::{TestCase, TestCaseSpeed, TestFile, TestFileDownloadError}; +use ruff_benchmark::{TestCase, TestFile, TestFileDownloadError}; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; use ruff_python_ast::Stmt; use ruff_python_parser::parse_suite; @@ -27,6 +25,7 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; fn create_test_cases() -> Result, TestFileDownloadError> { Ok(vec![ TestCase::fast(TestFile::try_download("numpy/globals.py", "https://raw.githubusercontent.com/numpy/numpy/89d64415e349ca75a25250f22b874aa16e5c0973/numpy/_globals.py")?), + TestCase::fast(TestFile::try_download("unicode/pypinyin.py", "https://raw.githubusercontent.com/mozillazg/python-pinyin/9521e47d96e3583a5477f5e43a2e82d513f27a3f/pypinyin/standard.py")?), TestCase::normal(TestFile::try_download( "pydantic/types.py", "https://raw.githubusercontent.com/pydantic/pydantic/83b3c49e99ceb4599d9286a3d793cea44ac36d4b/pydantic/types.py", @@ -56,12 +55,6 @@ fn benchmark_parser(criterion: &mut Criterion) { for case in test_cases { group.throughput(Throughput::Bytes(case.code().len() as u64)); - group.measurement_time(match case.speed() { - TestCaseSpeed::Fast => Duration::from_secs(10), - TestCaseSpeed::Normal => Duration::from_secs(20), - TestCaseSpeed::Slow => Duration::from_secs(45), - }); - group.bench_with_input( BenchmarkId::from_parameter(case.name()), &case, diff --git a/crates/ruff_cli/Cargo.toml b/crates/ruff_cli/Cargo.toml index 9f81c42389..9c6674c3e9 100644 --- a/crates/ruff_cli/Cargo.toml +++ b/crates/ruff_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruff_cli" -version = "0.0.286" +version = "0.0.289" publish = false authors = { workspace = true } edition = { workspace = true } @@ -25,6 +25,7 @@ ruff = { path = "../ruff", features = ["clap"] } ruff_cache = { path = "../ruff_cache" } ruff_diagnostics = { path = "../ruff_diagnostics" } ruff_formatter = { path = "../ruff_formatter" } +ruff_notebook = { path = "../ruff_notebook" } ruff_macros = { path = "../ruff_macros" } ruff_python_ast = { path = "../ruff_python_ast" } ruff_python_formatter = { path = "../ruff_python_formatter" } @@ -35,7 +36,7 @@ ruff_text_size = { path = "../ruff_text_size" } annotate-snippets = { version = "0.9.1", features = ["color"] } anyhow = { workspace = true } -argfile = { version = "0.1.5" } +argfile = { version = "0.1.6" } bincode = { version = "1.3.3" } bitflags = { workspace = true } cachedir = { version = "0.3.0" } @@ -63,14 +64,18 @@ shellexpand = { workspace = true } similar = { workspace = true } strum = { workspace = true, features = [] } thiserror = { workspace = true } -tracing = { workspace = true } +tracing = { workspace = true, features = ["log"] } walkdir = { version = "2.3.2" } wild = { version = "2" } [dev-dependencies] assert_cmd = { version = "2.0.8" } +# Avoid writing colored snapshots when running tests from the terminal +colored = { workspace = true, features = ["no-color"]} insta = { workspace = true, features = ["filters"] } +insta-cmd = { version = "0.4.0" } tempfile = "3.6.0" +test-case = { workspace = true } ureq = { version = "2.6.2", features = [] } [target.'cfg(target_os = "windows")'.dependencies] diff --git a/crates/ruff_cli/src/args.rs b/crates/ruff_cli/src/args.rs index 6971867dfc..18ce203ec0 100644 --- a/crates/ruff_cli/src/args.rs +++ b/crates/ruff_cli/src/args.rs @@ -9,7 +9,7 @@ use rustc_hash::FxHashMap; use ruff::logging::LogLevel; use ruff::registry::Rule; use ruff::settings::types::{ - FilePattern, PatternPrefixPair, PerFileIgnore, PythonVersion, SerializationFormat, + FilePattern, PatternPrefixPair, PerFileIgnore, PreviewMode, PythonVersion, SerializationFormat, }; use ruff::RuleSelector; use ruff_workspace::configuration::{Configuration, RuleSelection}; @@ -115,6 +115,11 @@ pub struct CheckCommand { /// The minimum Python version that should be supported. #[arg(long, value_enum)] pub target_version: Option, + /// Enable preview mode; checks will include unstable rules and fixes. + #[arg(long, overrides_with("no_preview"))] + preview: bool, + #[clap(long, overrides_with("preview"), hide = true)] + no_preview: bool, /// Path to the `pyproject.toml` or `ruff.toml` file to use for /// configuration. #[arg(long, conflicts_with = "isolated")] @@ -333,12 +338,6 @@ pub struct FormatCommand { /// files would have been modified, and zero otherwise. #[arg(long)] pub check: bool, - /// Specify file to write the formatter output to (default: stdout). - #[arg(short, long)] - pub output_file: Option, - /// The minimum Python version that should be supported. - #[arg(long, value_enum)] - pub target_version: Option, /// Path to the `pyproject.toml` or `ruff.toml` file to use for configuration. #[arg(long, conflicts_with = "isolated")] pub config: Option, @@ -369,6 +368,12 @@ pub struct FormatCommand { /// The name of the file when passing it through stdin. #[arg(long, help_heading = "Miscellaneous")] pub stdin_filename: Option, + + /// Enable preview mode; checks will include unstable rules and fixes. + #[arg(long, overrides_with("no_preview"), hide = true)] + preview: bool, + #[clap(long, overrides_with("preview"), hide = true)] + no_preview: bool, } #[derive(Debug, Clone, Copy, clap::ValueEnum)] @@ -389,7 +394,7 @@ pub struct LogLevelArgs { help_heading = "Log levels" )] pub verbose: bool, - /// Print lint violations, but nothing else. + /// Print diagnostics, but nothing else. #[arg( short, long, @@ -398,7 +403,7 @@ pub struct LogLevelArgs { help_heading = "Log levels" )] pub quiet: bool, - /// Disable all logging (but still exit with status code "1" upon detecting lint violations). + /// Disable all logging (but still exit with status code "1" upon detecting diagnostics). #[arg( short, long, @@ -458,6 +463,7 @@ impl CheckCommand { ignore: self.ignore, line_length: self.line_length, per_file_ignores: self.per_file_ignores, + preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from), respect_gitignore: resolve_bool_arg( self.respect_gitignore, self.no_respect_gitignore, @@ -488,7 +494,6 @@ impl FormatCommand { config: self.config, files: self.files, isolated: self.isolated, - output_file: self.output_file, stdin_filename: self.stdin_filename, }, Overrides { @@ -497,8 +502,8 @@ impl FormatCommand { self.respect_gitignore, self.no_respect_gitignore, ), + preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from), force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude), - target_version: self.target_version, // Unsupported on the formatter CLI, but required on `Overrides`. ..Overrides::default() }, @@ -550,7 +555,6 @@ pub struct FormatArguments { pub config: Option, pub files: Vec, pub isolated: bool, - pub output_file: Option, pub stdin_filename: Option, } @@ -569,6 +573,7 @@ pub struct Overrides { pub ignore: Option>, pub line_length: Option, pub per_file_ignores: Option>, + pub preview: Option, pub respect_gitignore: Option, pub select: Option>, pub show_source: Option, @@ -632,6 +637,9 @@ impl ConfigProcessor for Overrides { if let Some(line_length) = &self.line_length { config.line_length = Some(*line_length); } + if let Some(preview) = &self.preview { + config.preview = Some(*preview); + } if let Some(per_file_ignores) = &self.per_file_ignores { config.per_file_ignores = Some(collect_per_file_ignores(per_file_ignores.clone())); } diff --git a/crates/ruff_cli/src/cache.rs b/crates/ruff_cli/src/cache.rs index b00326953a..1c10a25618 100644 --- a/crates/ruff_cli/src/cache.rs +++ b/crates/ruff_cli/src/cache.rs @@ -8,6 +8,7 @@ use std::sync::Mutex; use std::time::{Duration, SystemTime}; use anyhow::{Context, Result}; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use ruff::message::Message; @@ -15,6 +16,7 @@ use ruff::settings::Settings; use ruff::warn_user; use ruff_cache::{CacheKey, CacheKeyHasher}; use ruff_diagnostics::{DiagnosticKind, Fix}; +use ruff_notebook::NotebookIndex; use ruff_python_ast::imports::ImportMap; use ruff_source_file::SourceFileBuilder; use ruff_text_size::{TextRange, TextSize}; @@ -193,6 +195,7 @@ impl Cache { key: T, messages: &[Message], imports: &ImportMap, + notebook_index: Option<&NotebookIndex>, ) { let source = if let Some(msg) = messages.first() { msg.file.source_text().to_owned() @@ -226,6 +229,7 @@ impl Cache { imports: imports.clone(), messages, source, + notebook_index: notebook_index.cloned(), }; self.new_files.lock().unwrap().insert(path, file); } @@ -263,6 +267,8 @@ pub(crate) struct FileCache { /// /// This will be empty if `messages` is empty. source: String, + /// Notebook index if this file is a Jupyter Notebook. + notebook_index: Option, } impl FileCache { @@ -283,7 +289,12 @@ impl FileCache { }) .collect() }; - Diagnostics::new(messages, self.imports.clone()) + let notebook_indexes = if let Some(notebook_index) = self.notebook_index.as_ref() { + FxHashMap::from_iter([(path.to_string_lossy().to_string(), notebook_index.clone())]) + } else { + FxHashMap::default() + }; + Diagnostics::new(messages, self.imports.clone(), notebook_indexes) } } @@ -350,16 +361,19 @@ mod tests { use anyhow::Result; use ruff_python_ast::imports::ImportMap; - #[test] - fn same_results() { + use test_case::test_case; + + #[test_case("../ruff/resources/test/fixtures", "ruff_tests/cache_same_results_ruff"; "ruff_fixtures")] + #[test_case("../ruff_notebook/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_notebook"; "ruff_notebook_fixtures")] + fn same_results(package_root: &str, cache_dir_path: &str) { let mut cache_dir = temp_dir(); - cache_dir.push("ruff_tests/cache_same_results"); + cache_dir.push(cache_dir_path); let _ = fs::remove_dir_all(&cache_dir); cache::init(&cache_dir).unwrap(); let settings = AllSettings::default(); - let package_root = fs::canonicalize("../ruff/resources/test/fixtures").unwrap(); + let package_root = fs::canonicalize(package_root).unwrap(); let cache = Cache::open(&cache_dir, package_root.clone(), &settings.lib); assert_eq!(cache.new_files.lock().unwrap().len(), 0); @@ -444,9 +458,6 @@ mod tests { .unwrap(); } - // Not stored in the cache. - expected_diagnostics.notebooks.clear(); - got_diagnostics.notebooks.clear(); assert_eq!(expected_diagnostics, got_diagnostics); } @@ -614,6 +625,7 @@ mod tests { imports: ImportMap::new(), messages: Vec::new(), source: String::new(), + notebook_index: None, }, ); diff --git a/crates/ruff_cli/src/commands/add_noqa.rs b/crates/ruff_cli/src/commands/add_noqa.rs index f7b219a56d..8c59c5df76 100644 --- a/crates/ruff_cli/src/commands/add_noqa.rs +++ b/crates/ruff_cli/src/commands/add_noqa.rs @@ -12,6 +12,7 @@ use ruff_python_ast::{PySourceType, SourceType}; use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig}; use crate::args::Overrides; +use crate::diagnostics::LintSource; /// Add `noqa` directives to a collection of files. pub(crate) fn add_noqa( @@ -56,7 +57,15 @@ pub(crate) fn add_noqa( .and_then(|parent| package_roots.get(parent)) .and_then(|package| *package); let settings = resolver.resolve(path, pyproject_config); - match add_noqa_to_path(path, package, source_type, settings) { + let LintSource(source_kind) = match LintSource::try_from_path(path, source_type) { + Ok(Some(source)) => source, + Ok(None) => return None, + Err(e) => { + error!("Failed to extract source from {}: {e}", path.display()); + return None; + } + }; + match add_noqa_to_path(path, package, &source_kind, source_type, settings) { Ok(count) => Some(count), Err(e) => { error!("Failed to add noqa to {}: {e}", path.display()); diff --git a/crates/ruff_cli/src/commands/check.rs b/crates/ruff_cli/src/commands/check.rs index 45549a7f99..f760a5fb58 100644 --- a/crates/ruff_cli/src/commands/check.rs +++ b/crates/ruff_cli/src/commands/check.rs @@ -11,6 +11,7 @@ use itertools::Itertools; use log::{debug, error, warn}; #[cfg(not(target_family = "wasm"))] use rayon::prelude::*; +use rustc_hash::FxHashMap; use ruff::message::Message; use ruff::registry::Rule; @@ -156,6 +157,7 @@ pub(crate) fn check( TextSize::default(), )], ImportMap::default(), + FxHashMap::default(), ) } else { warn!( diff --git a/crates/ruff_cli/src/commands/config.rs b/crates/ruff_cli/src/commands/config.rs index 0391dc5ed4..042ea066f9 100644 --- a/crates/ruff_cli/src/commands/config.rs +++ b/crates/ruff_cli/src/commands/config.rs @@ -1,19 +1,19 @@ -use crate::ExitStatus; +use anyhow::{anyhow, Result}; + use ruff_workspace::options::Options; #[allow(clippy::print_stdout)] -pub(crate) fn config(key: Option<&str>) -> ExitStatus { +pub(crate) fn config(key: Option<&str>) -> Result<()> { match key { None => print!("{}", Options::metadata()), Some(key) => match Options::metadata().get(key) { None => { - println!("Unknown option"); - return ExitStatus::Error; + return Err(anyhow!("Unknown option: {key}")); } Some(entry) => { print!("{entry}"); } }, } - ExitStatus::Success + Ok(()) } diff --git a/crates/ruff_cli/src/commands/format.rs b/crates/ruff_cli/src/commands/format.rs index 79d9ce23e9..e278f54edf 100644 --- a/crates/ruff_cli/src/commands/format.rs +++ b/crates/ruff_cli/src/commands/format.rs @@ -1,25 +1,24 @@ use std::fmt::{Display, Formatter}; -use std::fs::File; use std::io; -use std::io::{BufWriter, Write}; use std::num::NonZeroU16; use std::path::{Path, PathBuf}; use std::time::Instant; use anyhow::Result; use colored::Colorize; -use log::{debug, warn}; use rayon::iter::Either::{Left, Right}; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use thiserror::Error; -use tracing::{span, Level}; +use tracing::{debug, warn}; use ruff::fs; use ruff::logging::LogLevel; +use ruff::settings::types::PreviewMode; use ruff::warn_user_once; use ruff_formatter::LineWidth; use ruff_python_ast::{PySourceType, SourceType}; use ruff_python_formatter::{format_module, FormatModuleError, PyFormatOptions}; +use ruff_source_file::{find_newline, LineEnding}; use ruff_workspace::resolver::python_files_in_path; use crate::args::{FormatArguments, Overrides}; @@ -61,30 +60,46 @@ pub(crate) fn format( let start = Instant::now(); let (results, errors): (Vec<_>, Vec<_>) = paths .into_par_iter() - .filter_map(|entry| match entry { - Ok(entry) => { - let path = entry.path(); + .filter_map(|entry| { + match entry { + Ok(entry) => { + let path = entry.path(); - let SourceType::Python(source_type @ (PySourceType::Python | PySourceType::Stub)) = - SourceType::from(path) - else { - // Ignore any non-Python files. - return None; - }; + let SourceType::Python( + source_type @ (PySourceType::Python | PySourceType::Stub), + ) = SourceType::from(path) + else { + // Ignore any non-Python files. + return None; + }; - let line_length = resolver.resolve(path, &pyproject_config).line_length; - let options = PyFormatOptions::from_source_type(source_type) - .with_line_width(LineWidth::from(NonZeroU16::from(line_length))); - Some(format_path(path, options, mode)) + let resolved_settings = resolver.resolve(path, &pyproject_config); + + let preview = match resolved_settings.preview { + PreviewMode::Enabled => ruff_python_formatter::PreviewMode::Enabled, + PreviewMode::Disabled => ruff_python_formatter::PreviewMode::Disabled, + }; + let line_length = resolved_settings.line_length; + + let options = PyFormatOptions::from_source_type(source_type) + .with_line_width(LineWidth::from(NonZeroU16::from(line_length))) + .with_preview(preview); + debug!("Formatting {} with {:?}", path.display(), options); + Some(format_path(path, options, mode)) + } + Err(err) => Some(Err(FormatCommandError::Ignore(err))), } - Err(err) => Some(Err(FormatCommandError::Ignore(err))), }) .partition_map(|result| match result { Ok(diagnostic) => Left(diagnostic), Err(err) => Right(err), }); let duration = start.elapsed(); - debug!("Formatted files in: {:?}", duration); + debug!( + "Formatted {} files in {:.2?}", + results.len() + errors.len(), + duration + ); let summary = FormatResultSummary::new(results, mode); @@ -98,15 +113,10 @@ pub(crate) fn format( // Report on the formatting changes. if log_level >= LogLevel::Default { - let mut writer: Box = match &cli.output_file { - Some(path) => { - colored::control::set_override(false); - let file = File::create(path)?; - Box::new(BufWriter::new(file)) - } - _ => Box::new(BufWriter::new(io::stdout())), - }; - writeln!(writer, "{summary}")?; + #[allow(clippy::print_stdout)] + { + println!("{summary}"); + } } match mode { @@ -140,12 +150,18 @@ fn format_path( ) -> Result { let unformatted = std::fs::read_to_string(path) .map_err(|err| FormatCommandError::Read(Some(path.to_path_buf()), err))?; - let formatted = { - let span = span!(Level::TRACE, "format_path_without_io", path = %path.display()); - let _enter = span.enter(); - format_module(&unformatted, options) - .map_err(|err| FormatCommandError::FormatModule(Some(path.to_path_buf()), err))? + + let line_ending = match find_newline(&unformatted) { + Some((_, LineEnding::Lf)) | None => ruff_formatter::printer::LineEnding::LineFeed, + Some((_, LineEnding::Cr)) => ruff_formatter::printer::LineEnding::CarriageReturn, + Some((_, LineEnding::CrLf)) => ruff_formatter::printer::LineEnding::CarriageReturnLineFeed, }; + + let options = options.with_line_ending(line_ending); + + let formatted = format_module(&unformatted, options) + .map_err(|err| FormatCommandError::FormatModule(Some(path.to_path_buf()), err))?; + let formatted = formatted.as_code(); if formatted.len() == unformatted.len() && formatted == unformatted { Ok(FormatCommandResult::Unchanged) diff --git a/crates/ruff_cli/src/commands/format_stdin.rs b/crates/ruff_cli/src/commands/format_stdin.rs index c430fa6937..0f3b7ab4ea 100644 --- a/crates/ruff_cli/src/commands/format_stdin.rs +++ b/crates/ruff_cli/src/commands/format_stdin.rs @@ -1,8 +1,11 @@ use std::io::{stdout, Write}; +use std::num::NonZeroU16; use std::path::Path; use anyhow::Result; use log::warn; +use ruff::settings::types::PreviewMode; +use ruff_formatter::LineWidth; use ruff_python_formatter::{format_module, PyFormatOptions}; use ruff_workspace::resolver::python_file_at_path; @@ -35,9 +38,19 @@ pub(crate) fn format_stdin(cli: &FormatArguments, overrides: &Overrides) -> Resu // Format the file. let path = cli.stdin_filename.as_deref(); + + let preview = match pyproject_config.settings.lib.preview { + PreviewMode::Enabled => ruff_python_formatter::PreviewMode::Enabled, + PreviewMode::Disabled => ruff_python_formatter::PreviewMode::Disabled, + }; + let line_length = pyproject_config.settings.lib.line_length; + let options = path .map(PyFormatOptions::from_extension) - .unwrap_or_default(); + .unwrap_or_default() + .with_line_width(LineWidth::from(NonZeroU16::from(line_length))) + .with_preview(preview); + match format_source(path, options, mode) { Ok(result) => match mode { FormatMode::Write => Ok(ExitStatus::Success), diff --git a/crates/ruff_cli/src/commands/rule.rs b/crates/ruff_cli/src/commands/rule.rs index a16ec4622b..7593d2466e 100644 --- a/crates/ruff_cli/src/commands/rule.rs +++ b/crates/ruff_cli/src/commands/rule.rs @@ -19,7 +19,7 @@ struct Explanation<'a> { message_formats: &'a [&'a str], autofix: String, explanation: Option<&'a str>, - nursery: bool, + preview: bool, } impl<'a> Explanation<'a> { @@ -35,7 +35,7 @@ impl<'a> Explanation<'a> { message_formats: rule.message_formats(), autofix, explanation: rule.explanation(), - nursery: rule.is_nursery(), + preview: rule.is_preview(), } } } @@ -58,13 +58,10 @@ fn format_rule_text(rule: Rule) -> String { output.push('\n'); } - if rule.is_nursery() { - output.push_str(&format!( - r#"This rule is part of the **nursery**, a collection of newer lints that are -still under development. As such, it must be enabled by explicitly selecting -{}."#, - rule.noqa_code() - )); + if rule.is_preview() { + output.push_str( + r#"This rule is in preview and is not stable. The `--preview` flag is required for use."#, + ); output.push('\n'); output.push('\n'); } diff --git a/crates/ruff_cli/src/diagnostics.rs b/crates/ruff_cli/src/diagnostics.rs index bca7763a24..42c69ba58a 100644 --- a/crates/ruff_cli/src/diagnostics.rs +++ b/crates/ruff_cli/src/diagnostics.rs @@ -1,8 +1,8 @@ #![cfg_attr(target_family = "wasm", allow(dead_code))] -use std::fs::write; +use std::fs::{write, File}; use std::io; -use std::io::Write; +use std::io::{BufWriter, Write}; use std::ops::AddAssign; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; @@ -14,18 +14,19 @@ use filetime::FileTime; use log::{debug, error, warn}; use rustc_hash::FxHashMap; use similar::TextDiff; +use thiserror::Error; -use ruff::jupyter::{Cell, Notebook}; use ruff::linter::{lint_fix, lint_only, FixTable, FixerResult, LinterResult}; use ruff::logging::DisplayParseError; use ruff::message::Message; use ruff::pyproject_toml::lint_pyproject_toml; -use ruff::registry::Rule; +use ruff::registry::AsRule; use ruff::settings::{flags, AllSettings, Settings}; use ruff::source_kind::SourceKind; -use ruff::{fs, IOError}; +use ruff::{fs, IOError, SyntaxError}; use ruff_diagnostics::Diagnostic; use ruff_macros::CacheKey; +use ruff_notebook::{Cell, Notebook, NotebookError, NotebookIndex}; use ruff_python_ast::imports::ImportMap; use ruff_python_ast::{PySourceType, SourceType, TomlSourceType}; use ruff_source_file::{LineIndex, SourceCode, SourceFileBuilder}; @@ -63,40 +64,57 @@ pub(crate) struct Diagnostics { pub(crate) messages: Vec, pub(crate) fixed: FxHashMap, pub(crate) imports: ImportMap, - pub(crate) notebooks: FxHashMap, + pub(crate) notebook_indexes: FxHashMap, } impl Diagnostics { - pub(crate) fn new(messages: Vec, imports: ImportMap) -> Self { + pub(crate) fn new( + messages: Vec, + imports: ImportMap, + notebook_indexes: FxHashMap, + ) -> Self { Self { messages, fixed: FxHashMap::default(), imports, - notebooks: FxHashMap::default(), + notebook_indexes, } } - /// Generate [`Diagnostics`] based on an [`io::Error`]. - pub(crate) fn from_io_error(err: &io::Error, path: &Path, settings: &Settings) -> Self { - if settings.rules.enabled(Rule::IOError) { - let io_err = Diagnostic::new( - IOError { - message: err.to_string(), - }, - TextRange::default(), - ); - let dummy = SourceFileBuilder::new(path.to_string_lossy().as_ref(), "").finish(); + /// Generate [`Diagnostics`] based on a [`SourceExtractionError`]. + pub(crate) fn from_source_error( + err: &SourceExtractionError, + path: Option<&Path>, + settings: &Settings, + ) -> Self { + let diagnostic = Diagnostic::from(err); + if settings.rules.enabled(diagnostic.kind.rule()) { + let name = path.map_or_else(|| "-".into(), std::path::Path::to_string_lossy); + let dummy = SourceFileBuilder::new(name, "").finish(); Self::new( - vec![Message::from_diagnostic(io_err, dummy, TextSize::default())], + vec![Message::from_diagnostic( + diagnostic, + dummy, + TextSize::default(), + )], ImportMap::default(), + FxHashMap::default(), ) } else { - warn!( - "{}{}{} {err}", - "Failed to lint ".bold(), - fs::relativize_path(path).bold(), - ":".bold() - ); + match path { + Some(path) => { + warn!( + "{}{}{} {err}", + "Failed to lint ".bold(), + fs::relativize_path(path).bold(), + ":".bold() + ); + } + None => { + warn!("{}{} {err}", "Failed to lint".bold(), ":".bold()); + } + } + Self::default() } } @@ -117,80 +135,10 @@ impl AddAssign for Diagnostics { } } } - self.notebooks.extend(other.notebooks); + self.notebook_indexes.extend(other.notebook_indexes); } } -/// Read a Jupyter Notebook from disk. -/// -/// Returns either an indexed Python Jupyter Notebook or a diagnostic (which is empty if we skip). -fn notebook_from_path(path: &Path) -> Result> { - let notebook = match Notebook::from_path(path) { - Ok(notebook) => { - if !notebook.is_python_notebook() { - // Not a python notebook, this could e.g. be an R notebook which we want to just skip. - debug!( - "Skipping {} because it's not a Python notebook", - path.display() - ); - return Err(Box::default()); - } - notebook - } - Err(diagnostic) => { - // Failed to read the jupyter notebook - return Err(Box::new(Diagnostics { - messages: vec![Message::from_diagnostic( - *diagnostic, - SourceFileBuilder::new(path.to_string_lossy().as_ref(), "").finish(), - TextSize::default(), - )], - ..Diagnostics::default() - })); - } - }; - - Ok(notebook) -} - -/// Parse a Jupyter Notebook from a JSON string. -/// -/// Returns either an indexed Python Jupyter Notebook or a diagnostic (which is empty if we skip). -fn notebook_from_source_code( - source_code: &str, - path: Option<&Path>, -) -> Result> { - let notebook = match Notebook::from_source_code(source_code) { - Ok(notebook) => { - if !notebook.is_python_notebook() { - // Not a python notebook, this could e.g. be an R notebook which we want to just skip. - if let Some(path) = path { - debug!( - "Skipping {} because it's not a Python notebook", - path.display() - ); - } - return Err(Box::default()); - } - notebook - } - Err(diagnostic) => { - // Failed to read the jupyter notebook - return Err(Box::new(Diagnostics { - messages: vec![Message::from_diagnostic( - *diagnostic, - SourceFileBuilder::new(path.map(Path::to_string_lossy).unwrap_or_default(), "") - .finish(), - TextSize::default(), - )], - ..Diagnostics::default() - })); - } - }; - - Ok(notebook) -} - /// Lint the source code at the given `Path`. pub(crate) fn lint_path( path: &Path, @@ -235,12 +183,17 @@ pub(crate) fn lint_path( .iter_enabled() .any(|rule_code| rule_code.lint_source().is_pyproject_toml()) { - let contents = match std::fs::read_to_string(path) { - Ok(contents) => contents, - Err(err) => { - return Ok(Diagnostics::from_io_error(&err, path, &settings.lib)); - } - }; + let contents = + match std::fs::read_to_string(path).map_err(SourceExtractionError::Io) { + Ok(contents) => contents, + Err(err) => { + return Ok(Diagnostics::from_source_error( + &err, + Some(path), + &settings.lib, + )); + } + }; let source_file = SourceFileBuilder::new(path.to_string_lossy(), contents).finish(); lint_pyproject_toml(source_file, &settings.lib) } else { @@ -257,12 +210,14 @@ pub(crate) fn lint_path( // Extract the sources from the file. let LintSource(source_kind) = match LintSource::try_from_path(path, source_type) { - Ok(sources) => sources, - Err(SourceExtractionError::Io(err)) => { - return Ok(Diagnostics::from_io_error(&err, path, &settings.lib)); - } - Err(SourceExtractionError::Diagnostics(diagnostics)) => { - return Ok(*diagnostics); + Ok(Some(sources)) => sources, + Ok(None) => return Ok(Diagnostics::default()), + Err(err) => { + return Ok(Diagnostics::from_source_error( + &err, + Some(path), + &settings.lib, + )); } }; @@ -293,7 +248,8 @@ pub(crate) fn lint_path( write(path, transformed.as_bytes())?; } SourceKind::IpyNotebook(notebook) => { - notebook.write(path)?; + let mut writer = BufWriter::new(File::create(path)?); + notebook.write(&mut writer)?; } }, flags::FixMode::Diff => { @@ -390,7 +346,13 @@ pub(crate) fn lint_path( if let Some((cache, relative_path, key)) = caching { // We don't cache parsing errors. if parse_error.is_none() { - cache.update(relative_path.to_owned(), key, &messages, &imports); + cache.update( + relative_path.to_owned(), + key, + &messages, + &imports, + source_kind.as_ipy_notebook().map(Notebook::index), + ); } } @@ -403,17 +365,18 @@ pub(crate) fn lint_path( source_kind.source_code(), &LineIndex::from_source_text(source_kind.source_code()) ), - Some(&source_kind), + &source_kind, ) ); } - let notebooks = if let SourceKind::IpyNotebook(notebook) = source_kind { + let notebook_indexes = if let SourceKind::IpyNotebook(notebook) = source_kind { FxHashMap::from_iter([( path.to_str() .ok_or_else(|| anyhow!("Unable to parse filename: {:?}", path))? .to_string(), - notebook, + // Index needs to be computed always to store in cache. + notebook.index().clone(), )]) } else { FxHashMap::default() @@ -423,7 +386,7 @@ pub(crate) fn lint_path( messages, fixed: FxHashMap::from_iter([(fs::relativize_path(path), fixed)]), imports, - notebooks, + notebook_indexes, }) } @@ -443,17 +406,13 @@ pub(crate) fn lint_stdin( }; // Extract the sources from the file. - let LintSource(source_kind) = - match LintSource::try_from_source_code(contents, path, source_type) { - Ok(sources) => sources, - Err(SourceExtractionError::Io(err)) => { - // SAFETY: An `io::Error` can only occur if we're reading from a path. - return Ok(Diagnostics::from_io_error(&err, path.unwrap(), settings)); - } - Err(SourceExtractionError::Diagnostics(diagnostics)) => { - return Ok(*diagnostics); - } - }; + let LintSource(source_kind) = match LintSource::try_from_source_code(contents, source_type) { + Ok(Some(sources)) => sources, + Ok(None) => return Ok(Diagnostics::default()), + Err(err) => { + return Ok(Diagnostics::from_source_error(&err, path, settings)); + } + }; // Lint the inputs. let ( @@ -551,77 +510,83 @@ pub(crate) fn lint_stdin( fixed, )]), imports, - notebooks: FxHashMap::default(), + notebook_indexes: FxHashMap::default(), }) } #[derive(Debug)] -struct LintSource(SourceKind); +pub(crate) struct LintSource(pub(crate) SourceKind); impl LintSource { /// Extract the lint [`LintSource`] from the given file path. - fn try_from_path( + pub(crate) fn try_from_path( path: &Path, source_type: PySourceType, - ) -> Result { + ) -> Result, SourceExtractionError> { if source_type.is_ipynb() { - let notebook = notebook_from_path(path).map_err(SourceExtractionError::Diagnostics)?; - let source_kind = SourceKind::IpyNotebook(notebook); - Ok(LintSource(source_kind)) + let notebook = Notebook::from_path(path)?; + Ok(notebook + .is_python_notebook() + .then_some(LintSource(SourceKind::IpyNotebook(notebook)))) } else { // This is tested by ruff_cli integration test `unreadable_file` - let contents = std::fs::read_to_string(path).map_err(SourceExtractionError::Io)?; - Ok(LintSource(SourceKind::Python(contents))) + let contents = std::fs::read_to_string(path)?; + Ok(Some(LintSource(SourceKind::Python(contents)))) } } /// Extract the lint [`LintSource`] from the raw string contents, optionally accompanied by a /// file path indicating the path to the file from which the contents were read. If provided, /// the file path should be used for diagnostics, but not for reading the file from disk. - fn try_from_source_code( + pub(crate) fn try_from_source_code( source_code: String, - path: Option<&Path>, source_type: PySourceType, - ) -> Result { + ) -> Result, SourceExtractionError> { if source_type.is_ipynb() { - let notebook = notebook_from_source_code(&source_code, path) - .map_err(SourceExtractionError::Diagnostics)?; - let source_kind = SourceKind::IpyNotebook(notebook); - Ok(LintSource(source_kind)) + let notebook = Notebook::from_source_code(&source_code)?; + Ok(notebook + .is_python_notebook() + .then_some(LintSource(SourceKind::IpyNotebook(notebook)))) } else { - Ok(LintSource(SourceKind::Python(source_code))) + Ok(Some(LintSource(SourceKind::Python(source_code)))) } } } -#[derive(Debug)] -enum SourceExtractionError { +#[derive(Error, Debug)] +pub(crate) enum SourceExtractionError { /// The extraction failed due to an [`io::Error`]. - Io(io::Error), - /// The extraction failed, and generated [`Diagnostics`] to report. - Diagnostics(Box), + #[error(transparent)] + Io(#[from] io::Error), + /// The extraction failed due to a [`NotebookError`]. + #[error(transparent)] + Notebook(#[from] NotebookError), } -#[cfg(test)] -mod tests { - use std::path::Path; - - use crate::diagnostics::{notebook_from_path, notebook_from_source_code, Diagnostics}; - - #[test] - fn test_r() { - let path = Path::new("../ruff/resources/test/fixtures/jupyter/R.ipynb"); - // No diagnostics is used as skip signal. - assert_eq!( - notebook_from_path(path).unwrap_err(), - Box::::default() - ); - - let contents = std::fs::read_to_string(path).unwrap(); - // No diagnostics is used as skip signal. - assert_eq!( - notebook_from_source_code(&contents, Some(path)).unwrap_err(), - Box::::default() - ); +impl From<&SourceExtractionError> for Diagnostic { + fn from(err: &SourceExtractionError) -> Self { + match err { + // IO errors. + SourceExtractionError::Io(_) + | SourceExtractionError::Notebook(NotebookError::Io(_) | NotebookError::Json(_)) => { + Diagnostic::new( + IOError { + message: err.to_string(), + }, + TextRange::default(), + ) + } + // Syntax errors. + SourceExtractionError::Notebook( + NotebookError::InvalidJson(_) + | NotebookError::InvalidSchema(_) + | NotebookError::InvalidFormat(_), + ) => Diagnostic::new( + SyntaxError { + message: err.to_string(), + }, + TextRange::default(), + ), + } } } diff --git a/crates/ruff_cli/src/lib.rs b/crates/ruff_cli/src/lib.rs index 130631f0e9..08057794b1 100644 --- a/crates/ruff_cli/src/lib.rs +++ b/crates/ruff_cli/src/lib.rs @@ -139,18 +139,27 @@ quoting the executed command, along with the relevant file contents and `pyproje if let Some(rule) = rule { commands::rule::rule(rule, format)?; } + Ok(ExitStatus::Success) + } + Command::Config { option } => { + commands::config::config(option.as_deref())?; + Ok(ExitStatus::Success) + } + Command::Linter { format } => { + commands::linter::linter(format)?; + Ok(ExitStatus::Success) + } + Command::Clean => { + commands::clean::clean(log_level)?; + Ok(ExitStatus::Success) } - Command::Config { option } => return Ok(commands::config::config(option.as_deref())), - Command::Linter { format } => commands::linter::linter(format)?, - Command::Clean => commands::clean::clean(log_level)?, Command::GenerateShellCompletion { shell } => { shell.generate(&mut Args::command(), &mut stdout()); + Ok(ExitStatus::Success) } - Command::Check(args) => return check(args, log_level), - Command::Format(args) => return format(args, log_level), + Command::Check(args) => check(args, log_level), + Command::Format(args) => format(args, log_level), } - - Ok(ExitStatus::Success) } fn format(args: FormatCommand, log_level: LogLevel) -> Result { diff --git a/crates/ruff_cli/src/printer.rs b/crates/ruff_cli/src/printer.rs index ba42b7d98f..ea6c50d7cc 100644 --- a/crates/ruff_cli/src/printer.rs +++ b/crates/ruff_cli/src/printer.rs @@ -177,7 +177,7 @@ impl Printer { return Ok(()); } - let context = EmitterContext::new(&diagnostics.notebooks); + let context = EmitterContext::new(&diagnostics.notebook_indexes); match self.format { SerializationFormat::Json => { @@ -364,7 +364,7 @@ impl Printer { writeln!(writer)?; } - let context = EmitterContext::new(&diagnostics.notebooks); + let context = EmitterContext::new(&diagnostics.notebook_indexes); TextEmitter::default() .with_show_fix_status(show_fix_status(self.autofix_level)) .with_show_source(self.flags.intersects(Flags::SHOW_SOURCE)) diff --git a/crates/ruff_cli/tests/black_compatibility_test.rs b/crates/ruff_cli/tests/black_compatibility_test.rs index a09cb6185a..fb66e2e6dd 100644 --- a/crates/ruff_cli/tests/black_compatibility_test.rs +++ b/crates/ruff_cli/tests/black_compatibility_test.rs @@ -1,15 +1,15 @@ #![cfg(not(target_family = "wasm"))] -use std::io::{ErrorKind, Read}; +use std::io::{ErrorKind, Read, Write}; use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener, TcpStream}; use std::path::{Path, PathBuf}; -use std::process::Stdio; +use std::process::{Command, Stdio}; use std::thread::sleep; use std::time::Duration; use std::{fs, process, str}; -use anyhow::{anyhow, Context, Result}; -use assert_cmd::Command; +use anyhow::{anyhow, bail, Context, Result}; +use insta_cmd::get_cargo_bin; use log::info; use walkdir::WalkDir; @@ -29,13 +29,14 @@ impl Blackd { // Get free TCP port to run on let address = TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0))?.local_addr()?; - let server = process::Command::new("blackd") - .args([ - "--bind-host", - &address.ip().to_string(), - "--bind-port", - &address.port().to_string(), - ]) + let args = [ + "--bind-host", + &address.ip().to_string(), + "--bind-port", + &address.port().to_string(), + ]; + let server = Command::new("blackd") + .args(args) .stdout(Stdio::null()) .stderr(Stdio::null()) .spawn() @@ -51,16 +52,16 @@ impl Blackd { Err(e) => return Err(e.into()), Ok(_) => { info!("`blackd` ready"); - break; + return Ok(Self { + address, + server, + client: ureq::agent(), + }); } } } - Ok(Self { - address, - server, - client: ureq::agent(), - }) + bail!("blackd {:?} failed to start", args) } /// Format given code with blackd. @@ -104,34 +105,42 @@ fn run_test(path: &Path, blackd: &Blackd, ruff_args: &[&str]) -> Result<()> { let input = fs::read(path)?; // Step 1: Run `ruff` on the input. - let step_1 = &Command::cargo_bin(BIN_NAME)? + let mut step_1 = Command::new(get_cargo_bin(BIN_NAME)) .args(ruff_args) - .write_stdin(input) - .assert() - .append_context("step", "running input through ruff"); - if !step_1.get_output().status.success() { + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn()?; + if let Some(mut stdin) = step_1.stdin.take() { + stdin.write_all(input.as_ref())?; + } + let step_1_output = step_1.wait_with_output()?; + if !step_1_output.status.success() { return Err(anyhow!( "Running input through ruff failed:\n{}", - str::from_utf8(&step_1.get_output().stderr)? + str::from_utf8(&step_1_output.stderr)? )); } - let step_1_output = step_1.get_output().stdout.clone(); // Step 2: Run `blackd` on the input. - let step_2_output = blackd.check(&step_1_output)?; + let step_2_output = blackd.check(&step_1_output.stdout.clone())?; // Step 3: Re-run `ruff` on the input. - let step_3 = &Command::cargo_bin(BIN_NAME)? + let mut step_3 = Command::new(get_cargo_bin(BIN_NAME)) .args(ruff_args) - .write_stdin(step_2_output.clone()) - .assert(); - if !step_3.get_output().status.success() { + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn()?; + if let Some(mut stdin) = step_3.stdin.take() { + stdin.write_all(step_2_output.as_ref())?; + } + let step_3_output = step_3.wait_with_output()?; + if !step_3_output.status.success() { return Err(anyhow!( "Running input through ruff after black failed:\n{}", - str::from_utf8(&step_3.get_output().stderr)? + str::from_utf8(&step_3_output.stderr)? )); } - let step_3_output = step_3.get_output().stdout.clone(); + let step_3_output = step_3_output.stdout.clone(); assert_eq!( str::from_utf8(&step_2_output), @@ -177,11 +186,13 @@ fn test_ruff_black_compatibility() -> Result<()> { "--fix", "--line-length", "88", - "--select ALL", + "--select", + "ALL", // Exclude ruff codes, specifically RUF100, because it causes differences that are not a // problem. Ruff would add a `# noqa: W292` after the first run, black introduces a // newline, and ruff removes the `# noqa: W292` again. - "--ignore RUF", + "--ignore", + "RUF", ]; for entry in paths { diff --git a/crates/ruff_cli/tests/integration_test.rs b/crates/ruff_cli/tests/integration_test.rs index bbb88ad0ec..4425a057a8 100644 --- a/crates/ruff_cli/tests/integration_test.rs +++ b/crates/ruff_cli/tests/integration_test.rs @@ -8,14 +8,15 @@ use std::fs::Permissions; use std::os::unix::fs::{OpenOptionsExt, PermissionsExt}; #[cfg(unix)] use std::path::Path; +use std::process::Command; use std::str; #[cfg(unix)] use anyhow::Context; use anyhow::Result; -use assert_cmd::Command; #[cfg(unix)] use clap::Parser; +use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; #[cfg(unix)] use path_absolutize::path_dedot; #[cfg(unix)] @@ -27,315 +28,469 @@ use ruff_cli::args::Args; use ruff_cli::run; const BIN_NAME: &str = "ruff"; +const STDIN_BASE_OPTIONS: &[&str] = &["--isolated", "--no-cache", "-", "--format", "text"]; #[test] -fn stdin_success() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - cmd.args(["-", "--format", "text", "--isolated"]) - .write_stdin("") - .assert() - .success(); - Ok(()) +fn stdin_success() { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .pass_stdin(""), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + "###); } #[test] -fn stdin_error() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args(["-", "--format", "text", "--isolated"]) - .write_stdin("import os\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - r#"-:1:8: F401 [*] `os` imported but unused -Found 1 error. -[*] 1 potentially fixable with the --fix option. -"# - ); - Ok(()) +fn stdin_error() { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .pass_stdin("import os\n"), @r#" + success: false + exit_code: 1 + ----- stdout ----- + -:1:8: F401 [*] `os` imported but unused + Found 1 error. + [*] 1 potentially fixable with the --fix option. + + ----- stderr ----- + "#); } #[test] -fn stdin_filename() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args([ - "-", - "--format", - "text", - "--stdin-filename", - "F401.py", - "--isolated", - ]) - .write_stdin("import os\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - r#"F401.py:1:8: F401 [*] `os` imported but unused -Found 1 error. -[*] 1 potentially fixable with the --fix option. -"# - ); - Ok(()) +fn stdin_filename() { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(["--stdin-filename", "F401.py"]) + .pass_stdin("import os\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + F401.py:1:8: F401 [*] `os` imported but unused + Found 1 error. + [*] 1 potentially fixable with the --fix option. + + ----- stderr ----- + "###); } #[test] -fn stdin_source_type() -> Result<()> { - // Raise `TCH` errors in `.py` files. - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args([ - "-", - "--format", - "text", - "--stdin-filename", - "TCH.py", - "--isolated", - ]) - .write_stdin("import os\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - r#"TCH.py:1:8: F401 [*] `os` imported but unused -Found 1 error. -[*] 1 potentially fixable with the --fix option. -"# - ); +/// Raise `TCH` errors in `.py` files ... +fn stdin_source_type_py() { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(["--stdin-filename", "TCH.py"]) + .pass_stdin("import os\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + TCH.py:1:8: F401 [*] `os` imported but unused + Found 1 error. + [*] 1 potentially fixable with the --fix option. - // But not in `.pyi` files. - let mut cmd = Command::cargo_bin(BIN_NAME)?; - cmd.args([ - "-", - "--format", - "text", - "--stdin-filename", - "TCH.pyi", - "--isolated", - "--select", - "TCH", - ]) - .write_stdin("import os\n") - .assert() - .success(); - Ok(()) + ----- stderr ----- + "###); +} + +/// ... but not in `.pyi` files. +#[test] +fn stdin_source_type_pyi() { + let args = ["--stdin-filename", "TCH.pyi", "--select", "TCH"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("import os\n"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + "###); } #[cfg(unix)] #[test] -fn stdin_json() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args([ - "-", - "--format", - "json", - "--stdin-filename", - "F401.py", - "--isolated", - ]) - .write_stdin("import os\n") - .assert() - .failure(); +fn stdin_json() { + let args = [ + "-", + "--isolated", + "--no-cache", + "--format", + "json", + "--stdin-filename", + "F401.py", + ]; let directory = path_dedot::CWD.to_str().unwrap(); let binding = Path::new(directory).join("F401.py"); let file_path = binding.display(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - format!( - r#"[ - {{ - "code": "F401", - "end_location": {{ - "column": 10, - "row": 1 - }}, - "filename": "{file_path}", - "fix": {{ - "applicability": "Automatic", - "edits": [ - {{ - "content": "", - "end_location": {{ - "column": 1, - "row": 2 - }}, - "location": {{ - "column": 1, - "row": 1 - }} - }} - ], - "message": "Remove unused import: `os`" - }}, - "location": {{ - "column": 8, - "row": 1 - }}, - "message": "`os` imported but unused", - "noqa_row": 1, - "url": "https://beta.ruff.rs/docs/rules/unused-import" - }} -]"# - ) - ); - Ok(()) + insta::with_settings!({filters => vec![ + (file_path.to_string().as_str(), "/path/to/F401.py"), + ]}, { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(args) + .pass_stdin("import os\n")); + }); } #[test] -fn stdin_autofix() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args(["-", "--format", "text", "--fix", "--isolated"]) - .write_stdin("import os\nimport sys\n\nprint(sys.version)\n") - .assert() - .success(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - "import sys\n\nprint(sys.version)\n" - ); - Ok(()) +fn stdin_autofix() { + let args = ["--fix"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("import os\nimport sys\n\nprint(sys.version)\n"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + import sys + + print(sys.version) + + ----- stderr ----- + "###); } #[test] -fn stdin_autofix_when_not_fixable_should_still_print_contents() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args(["-", "--format", "text", "--fix", "--isolated"]) - .write_stdin("import os\nimport sys\n\nif (1, 2):\n print(sys.version)\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - "import sys\n\nif (1, 2):\n print(sys.version)\n" - ); - Ok(()) +fn stdin_autofix_when_not_fixable_should_still_print_contents() { + let args = ["--fix"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("import os\nimport sys\n\nif (1, 2):\n print(sys.version)\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + import sys + + if (1, 2): + print(sys.version) + + ----- stderr ----- + "###); } #[test] -fn stdin_autofix_when_no_issues_should_still_print_contents() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args(["-", "--format", "text", "--fix", "--isolated"]) - .write_stdin("import sys\n\nprint(sys.version)\n") - .assert() - .success(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - "import sys\n\nprint(sys.version)\n" - ); - Ok(()) +fn stdin_autofix_when_no_issues_should_still_print_contents() { + let args = ["--fix"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("import sys\n\nprint(sys.version)\n"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + import sys + + print(sys.version) + + ----- stderr ----- + "###); } #[test] -fn show_source() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args(["-", "--format", "text", "--show-source", "--isolated"]) - .write_stdin("l = 1") - .assert() - .failure(); - assert!(str::from_utf8(&output.get_output().stdout)?.contains("l = 1")); - Ok(()) +fn show_source() { + let args = ["--show-source"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("l = 1"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: E741 Ambiguous variable name: `l` + | + 1 | l = 1 + | ^ E741 + | + + Found 1 error. + + ----- stderr ----- + "###); } #[test] -fn explain_status_codes() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - cmd.args(["--explain", "F401"]).assert().success(); - let mut cmd = Command::cargo_bin(BIN_NAME)?; - cmd.args(["--explain", "RUF404"]).assert().failure(); - Ok(()) +fn explain_status_codes_f401() { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)).args(["--explain", "F401"])); +} +#[test] +fn explain_status_codes_ruf404() { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)).args(["--explain", "RUF404"]), @r###" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: invalid value 'RUF404' for '[RULE]': unknown rule code + + For more information, try '--help'. + "###); } #[test] -fn show_statistics() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd - .args([ - "-", - "--format", - "text", - "--select", - "F401", - "--statistics", - "--isolated", - ]) - .write_stdin("import sys\nimport os\n\nprint(os.getuid())\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)? - .lines() - .last() - .unwrap(), - "1\tF401\t[*] `sys` imported but unused" - ); - Ok(()) +fn show_statistics() { + let args = ["--select", "F401", "--statistics"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("import sys\nimport os\n\nprint(os.getuid())\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + 1 F401 [*] `sys` imported but unused + + ----- stderr ----- + "###); } #[test] -fn nursery_prefix() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - +fn nursery_prefix() { // `--select E` should detect E741, but not E225, which is in the nursery. - let output = cmd - .args(["-", "--format", "text", "--isolated", "--select", "E"]) - .write_stdin("I=42\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - r#"-:1:1: E741 Ambiguous variable name: `I` -Found 1 error. -"# - ); + let args = ["--select", "E"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: E741 Ambiguous variable name: `I` + Found 1 error. - Ok(()) + ----- stderr ----- + "###); } #[test] -fn nursery_all() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - +fn nursery_all() { // `--select ALL` should detect E741, but not E225, which is in the nursery. - let output = cmd - .args(["-", "--format", "text", "--isolated", "--select", "E"]) - .write_stdin("I=42\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - r#"-:1:1: E741 Ambiguous variable name: `I` -Found 1 error. -"# - ); + let args = ["--select", "ALL"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: E741 Ambiguous variable name: `I` + -:1:1: D100 Missing docstring in public module + Found 2 errors. - Ok(()) + ----- stderr ----- + warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. Ignoring `one-blank-line-before-class`. + warning: `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible. Ignoring `multi-line-summary-second-line`. + "###); } #[test] -fn nursery_direct() -> Result<()> { - let mut cmd = Command::cargo_bin(BIN_NAME)?; - +fn nursery_direct() { // `--select E225` should detect E225. - let output = cmd - .args(["-", "--format", "text", "--isolated", "--select", "E225"]) - .write_stdin("I=42\n") - .assert() - .failure(); - assert_eq!( - str::from_utf8(&output.get_output().stdout)?, - r#"-:1:2: E225 Missing whitespace around operator -Found 1 error. -"# - ); + let args = ["--select", "E225"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:2: E225 Missing whitespace around operator + Found 1 error. - Ok(()) + ----- stderr ----- + warning: Selection of nursery rule `E225` without the `--preview` flag is deprecated. + "###); +} + +#[test] +fn nursery_group_selector() { + // Only nursery rules should be detected e.g. E225 and a warning should be displayed + let args = ["--select", "NURSERY"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: CPY001 Missing copyright notice at top of file + -:1:2: E225 Missing whitespace around operator + Found 2 errors. + + ----- stderr ----- + warning: The `NURSERY` selector has been deprecated. Use the `--preview` flag instead. + "###); +} + +#[test] +fn nursery_group_selector_preview_enabled() { + // Only nursery rules should be detected e.g. E225 and a warning should be displayed + let args = ["--select", "NURSERY", "--preview"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: CPY001 Missing copyright notice at top of file + -:1:2: E225 Missing whitespace around operator + Found 2 errors. + + ----- stderr ----- + warning: The `NURSERY` selector has been deprecated. Use the `PREVIEW` selector instead. + "###); +} + +#[test] +fn preview_enabled_prefix() { + // E741 and E225 (preview) should both be detected + let args = ["--select", "E", "--preview"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: E741 Ambiguous variable name: `I` + -:1:2: E225 Missing whitespace around operator + Found 2 errors. + + ----- stderr ----- + "###); +} + +#[test] +fn preview_enabled_all() { + let args = ["--select", "ALL", "--preview"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: E741 Ambiguous variable name: `I` + -:1:1: D100 Missing docstring in public module + -:1:1: CPY001 Missing copyright notice at top of file + -:1:2: E225 Missing whitespace around operator + Found 4 errors. + + ----- stderr ----- + warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. Ignoring `one-blank-line-before-class`. + warning: `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible. Ignoring `multi-line-summary-second-line`. + "###); +} + +#[test] +fn preview_enabled_direct() { + // E225 should be detected without warning + let args = ["--select", "E225", "--preview"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:2: E225 Missing whitespace around operator + Found 1 error. + + ----- stderr ----- + "###); +} + +#[test] +fn preview_disabled_direct() { + // FURB145 is preview not nursery so selecting should be empty + let args = ["--select", "FURB145"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("a = l[:]\n"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + warning: Selection `FURB145` has no effect because the `--preview` flag was not included. + "###); +} + +#[test] +fn preview_disabled_prefix_empty() { + // Warns that the selection is empty since all of the CPY rules are in preview + let args = ["--select", "CPY"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + warning: Selection `CPY` has no effect because the `--preview` flag was not included. + "###); +} + +#[test] +fn preview_disabled_group_selector() { + // `--select PREVIEW` should warn without the `--preview` flag + let args = ["--select", "PREVIEW"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + warning: Selection `PREVIEW` has no effect because the `--preview` flag was not included. + "###); +} + +#[test] +fn preview_enabled_group_selector() { + // `--select PREVIEW` is okay with the `--preview` flag and shouldn't warn + let args = ["--select", "PREVIEW", "--preview"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: CPY001 Missing copyright notice at top of file + -:1:2: E225 Missing whitespace around operator + Found 2 errors. + + ----- stderr ----- + "###); +} + +#[test] +fn preview_enabled_group_ignore() { + // `--select E --ignore PREVIEW` should detect E741 and E225, which is in preview but "E" is more specific. + let args = ["--select", "E", "--ignore", "PREVIEW", "--preview"]; + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(STDIN_BASE_OPTIONS) + .args(args) + .pass_stdin("I=42\n"), @r###" + success: false + exit_code: 1 + ----- stdout ----- + -:1:1: E741 Ambiguous variable name: `I` + -:1:2: E225 Missing whitespace around operator + Found 2 errors. + + ----- stderr ----- + "###); } /// An unreadable pyproject.toml in non-isolated mode causes ruff to hard-error trying to build up @@ -376,16 +531,62 @@ fn unreadable_dir() -> Result<()> { // We (currently?) have to use a subcommand to check exit status (currently wrong) and logging // output - let mut cmd = Command::cargo_bin(BIN_NAME)?; - let output = cmd + // TODO(konstin): This should be a failure, but we currently can't track that + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) .args(["--no-cache", "--isolated"]) - .arg(&unreadable_dir) - .assert() - // TODO(konstin): This should be a failure, but we currently can't track that - .success(); - assert_eq!( - str::from_utf8(&output.get_output().stderr)?, - "warning: Encountered error: Permission denied (os error 13)\n" - ); + .arg(&unreadable_dir), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + warning: Encountered error: Permission denied (os error 13) + "###); + Ok(()) +} + +/// Check that reading arguments from an argfile works +#[cfg(unix)] +#[test] +fn check_input_from_argfile() -> Result<()> { + let tempdir = TempDir::new()?; + + // Create python files + let file_a_path = tempdir.path().join("a.py"); + let file_b_path = tempdir.path().join("b.py"); + fs::write(&file_a_path, b"import os")?; + fs::write(&file_b_path, b"print('hello, world!')")?; + + // Create a the input file for argfile to expand + let input_file_path = tempdir.path().join("file_paths.txt"); + fs::write( + &input_file_path, + format!("{}\n{}", file_a_path.display(), file_b_path.display()), + )?; + + // Generate the args with the argfile notation + let args = vec![ + "check".to_string(), + "--no-cache".to_string(), + format!("@{}", &input_file_path.display()), + ]; + + insta::with_settings!({filters => vec![ + (file_a_path.display().to_string().as_str(), "/path/to/a.py"), + ]}, { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(args) + .pass_stdin(""), @r###" + success: false + exit_code: 1 + ----- stdout ----- + /path/to/a.py:1:8: F401 [*] `os` imported but unused + Found 1 error. + [*] 1 potentially fixable with the --fix option. + + ----- stderr ----- + "###); + }); + Ok(()) } diff --git a/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap b/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap new file mode 100644 index 0000000000..17615bf570 --- /dev/null +++ b/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap @@ -0,0 +1,61 @@ +--- +source: crates/ruff_cli/tests/integration_test.rs +info: + program: ruff + args: + - "--explain" + - F401 +--- +success: true +exit_code: 0 +----- stdout ----- +# unused-import (F401) + +Derived from the **Pyflakes** linter. + +Autofix is sometimes available. + +## What it does +Checks for unused imports. + +## Why is this bad? +Unused imports add a performance overhead at runtime, and risk creating +import cycles. They also increase the cognitive load of reading the code. + +If an import statement is used to check for the availability or existence +of a module, consider using `importlib.util.find_spec` instead. + +## Example +```python +import numpy as np # unused import + + +def area(radius): + return 3.14 * radius**2 +``` + +Use instead: +```python +def area(radius): + return 3.14 * radius**2 +``` + +To check the availability of a module, use `importlib.util.find_spec`: +```python +from importlib.util import find_spec + +if find_spec("numpy") is not None: + print("numpy is installed") +else: + print("numpy is not installed") +``` + +## Options +- `pyflakes.extend-generics` + +## References +- [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement) +- [Python documentation: `importlib.util.find_spec`](https://docs.python.org/3/library/importlib.html#importlib.util.find_spec) + +----- stderr ----- + diff --git a/crates/ruff_cli/tests/snapshots/integration_test__stdin_json.snap b/crates/ruff_cli/tests/snapshots/integration_test__stdin_json.snap new file mode 100644 index 0000000000..f127d39ad7 --- /dev/null +++ b/crates/ruff_cli/tests/snapshots/integration_test__stdin_json.snap @@ -0,0 +1,53 @@ +--- +source: crates/ruff_cli/tests/integration_test.rs +info: + program: ruff + args: + - "-" + - "--isolated" + - "--no-cache" + - "--format" + - json + - "--stdin-filename" + - F401.py + stdin: "import os\n" +--- +success: false +exit_code: 1 +----- stdout ----- +[ + { + "code": "F401", + "end_location": { + "column": 10, + "row": 1 + }, + "filename": "/path/to/F401.py", + "fix": { + "applicability": "Automatic", + "edits": [ + { + "content": "", + "end_location": { + "column": 1, + "row": 2 + }, + "location": { + "column": 1, + "row": 1 + } + } + ], + "message": "Remove unused import: `os`" + }, + "location": { + "column": 8, + "row": 1 + }, + "message": "`os` imported but unused", + "noqa_row": 1, + "url": "https://beta.ruff.rs/docs/rules/unused-import" + } +] +----- stderr ----- + diff --git a/crates/ruff_dev/Cargo.toml b/crates/ruff_dev/Cargo.toml index 901b0c1de9..4460e7cfb7 100644 --- a/crates/ruff_dev/Cargo.toml +++ b/crates/ruff_dev/Cargo.toml @@ -18,6 +18,7 @@ ruff_formatter = { path = "../ruff_formatter" } ruff_python_ast = { path = "../ruff_python_ast" } ruff_python_codegen = { path = "../ruff_python_codegen" } ruff_python_formatter = { path = "../ruff_python_formatter" } +ruff_notebook = { path = "../ruff_notebook" } ruff_python_literal = { path = "../ruff_python_literal" } ruff_python_parser = { path = "../ruff_python_parser" } ruff_python_stdlib = { path = "../ruff_python_stdlib" } diff --git a/crates/ruff_dev/src/format_dev.rs b/crates/ruff_dev/src/format_dev.rs index 604327fc78..fa80101326 100644 --- a/crates/ruff_dev/src/format_dev.rs +++ b/crates/ruff_dev/src/format_dev.rs @@ -18,6 +18,7 @@ use imara_diff::{diff, Algorithm}; use indicatif::ProgressStyle; #[cfg_attr(feature = "singlethreaded", allow(unused_imports))] use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use ruff::line_width::LineLength; use serde::Deserialize; use similar::{ChangeTag, TextDiff}; use tempfile::NamedTempFile; @@ -36,10 +37,17 @@ use ruff_formatter::{FormatError, LineWidth, PrintError}; use ruff_python_formatter::{ format_module, FormatModuleError, MagicTrailingComma, PyFormatOptions, }; -use ruff_workspace::resolver::python_files_in_path; +use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig, Resolver}; /// Find files that ruff would check so we can format them. Adapted from `ruff_cli`. -fn ruff_check_paths(dirs: &[PathBuf]) -> anyhow::Result>> { +#[allow(clippy::type_complexity)] +fn ruff_check_paths( + dirs: &[PathBuf], +) -> anyhow::Result<( + Vec>, + Resolver, + PyprojectConfig, +)> { let args_matches = FormatCommand::command() .no_binary_name(true) .get_matches_from(dirs); @@ -57,11 +65,11 @@ fn ruff_check_paths(dirs: &[PathBuf]) -> anyhow::Result90% diffing instead of formatting) @@ -117,6 +128,7 @@ impl Statistics { black_input: changes.removals, ruff_output: changes.insertions, intersection: u32::try_from(input.before.len()).unwrap() - changes.removals, + files_with_differences: 1, } } } @@ -141,6 +153,7 @@ impl Add for Statistics { black_input: self.black_input + rhs.black_input, ruff_output: self.ruff_output + rhs.ruff_output, intersection: self.intersection + rhs.intersection, + files_with_differences: self.files_with_differences + rhs.files_with_differences, } } } @@ -231,10 +244,11 @@ pub(crate) fn main(args: &Args) -> anyhow::Result { } info!( parent: None, - "Done: {} stability errors, {} files, similarity index {:.5}), took {:.2}s, {} input files contained syntax errors ", + "Done: {} stability errors, {} files, similarity index {:.5}), files with differences: {} took {:.2}s, {} input files contained syntax errors ", error_count, result.file_count, result.statistics.similarity_index(), + result.statistics.files_with_differences, result.duration.as_secs_f32(), result.syntax_error_in_input, ); @@ -336,11 +350,12 @@ fn format_dev_multi_project( info!( parent: None, - "Finished {}: {} stability errors, {} files, similarity index {:.5}), took {:.2}s, {} input files contained syntax errors ", + "Finished {}: {} stability errors, {} files, similarity index {:.5}), files with differences {}, took {:.2}s, {} input files contained syntax errors ", project_path.display(), result.error_count(), result.file_count, result.statistics.similarity_index(), + result.statistics.files_with_differences, result.duration.as_secs_f32(), result.syntax_error_in_input, ); @@ -387,20 +402,22 @@ fn format_dev_multi_project( let mut stats_file = BufWriter::new(File::create(stats_file)?); writeln!( stats_file, - "| {: anyhow::Result<(Result, PathBuf), Error> { let dir_entry = match dir_entry.context("Iterating the files in the repository failed") { Ok(dir_entry) => dir_entry, @@ -519,10 +545,17 @@ fn format_dir_entry( return Ok((Ok(Statistics::default()), file)); } - let file = dir_entry.path().to_path_buf(); - let options = options.to_py_format_options(&file); + let path = dir_entry.path().to_path_buf(); + let mut options = options.to_py_format_options(&path); + + let settings = resolver.resolve(&path, pyproject_config); + // That's a bad way of doing this but it's not worth doing something better for format_dev + if settings.line_length != LineLength::default() { + options = options.with_line_width(LineWidth::from(NonZeroU16::from(settings.line_length))); + } + // Handle panics (mostly in `debug_assert!`) - let result = match catch_unwind(|| format_dev_file(&file, stability_check, write, options)) { + let result = match catch_unwind(|| format_dev_file(&path, stability_check, write, options)) { Ok(result) => result, Err(panic) => { if let Some(message) = panic.downcast_ref::() { @@ -541,7 +574,7 @@ fn format_dir_entry( } } }; - Ok((result, file)) + Ok((result, path)) } /// A compact diff that only shows a header and changes, but nothing unchanged. This makes viewing diff --git a/crates/ruff_dev/src/generate_docs.rs b/crates/ruff_dev/src/generate_docs.rs index 108a02c264..f406b12bab 100644 --- a/crates/ruff_dev/src/generate_docs.rs +++ b/crates/ruff_dev/src/generate_docs.rs @@ -43,13 +43,10 @@ pub(crate) fn main(args: &Args) -> Result<()> { output.push('\n'); } - if rule.is_nursery() { - output.push_str(&format!( - r#"This rule is part of the **nursery**, a collection of newer lints that are -still under development. As such, it must be enabled by explicitly selecting -{}."#, - rule.noqa_code() - )); + if rule.is_preview() { + output.push_str( + r#"This rule is in preview and is not stable. The `--preview` flag is required for use."#, + ); output.push('\n'); output.push('\n'); } diff --git a/crates/ruff_dev/src/generate_rules_table.rs b/crates/ruff_dev/src/generate_rules_table.rs index 44389ec89b..4c9b1922c9 100644 --- a/crates/ruff_dev/src/generate_rules_table.rs +++ b/crates/ruff_dev/src/generate_rules_table.rs @@ -10,8 +10,8 @@ use ruff::upstream_categories::UpstreamCategoryAndPrefix; use ruff_diagnostics::AutofixKind; use ruff_workspace::options::Options; -const FIX_SYMBOL: &str = "🛠"; -const NURSERY_SYMBOL: &str = "🌅"; +const FIX_SYMBOL: &str = "🛠️"; +const PREVIEW_SYMBOL: &str = "🧪"; fn generate_table(table_out: &mut String, rules: impl IntoIterator, linter: &Linter) { table_out.push_str("| Code | Name | Message | |"); @@ -25,12 +25,12 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator, } AutofixKind::None => format!("{FIX_SYMBOL}"), }; - let nursery_token = if rule.is_nursery() { - format!("{NURSERY_SYMBOL}") + let preview_token = if rule.is_preview() || rule.is_nursery() { + format!("{PREVIEW_SYMBOL}") } else { - format!("{NURSERY_SYMBOL}") + format!("{PREVIEW_SYMBOL}") }; - let status_token = format!("{fix_token} {nursery_token}"); + let status_token = format!("{fix_token} {preview_token}"); let rule_name = rule.as_ref(); @@ -61,7 +61,7 @@ pub(crate) fn generate() -> String { table_out.push('\n'); table_out.push_str(&format!( - "The {NURSERY_SYMBOL} emoji indicates that a rule is part of the [\"nursery\"](../faq/#what-is-the-nursery)." + "The {PREVIEW_SYMBOL} emoji indicates that a rule in [\"preview\"](../faq/#what-is-preview)." )); table_out.push('\n'); table_out.push('\n'); diff --git a/crates/ruff_dev/src/print_ast.rs b/crates/ruff_dev/src/print_ast.rs index 14aa14bfac..eddf8f9d05 100644 --- a/crates/ruff_dev/src/print_ast.rs +++ b/crates/ruff_dev/src/print_ast.rs @@ -20,7 +20,7 @@ pub(crate) struct Args { pub(crate) fn main(args: &Args) -> Result<()> { let contents = fs::read_to_string(&args.file)?; let mode = if args.jupyter { - Mode::Jupyter + Mode::Ipython } else { Mode::Module }; diff --git a/crates/ruff_dev/src/print_tokens.rs b/crates/ruff_dev/src/print_tokens.rs index c3e17904bc..1498ee81a5 100644 --- a/crates/ruff_dev/src/print_tokens.rs +++ b/crates/ruff_dev/src/print_tokens.rs @@ -20,7 +20,7 @@ pub(crate) struct Args { pub(crate) fn main(args: &Args) -> Result<()> { let contents = fs::read_to_string(&args.file)?; let mode = if args.jupyter { - Mode::Jupyter + Mode::Ipython } else { Mode::Module }; diff --git a/crates/ruff_dev/src/round_trip.rs b/crates/ruff_dev/src/round_trip.rs index a85d57e8cb..d99430ea31 100644 --- a/crates/ruff_dev/src/round_trip.rs +++ b/crates/ruff_dev/src/round_trip.rs @@ -6,7 +6,6 @@ use std::path::PathBuf; use anyhow::Result; -use ruff::jupyter; use ruff_python_codegen::round_trip; use ruff_python_stdlib::path::is_jupyter_notebook; @@ -20,7 +19,7 @@ pub(crate) struct Args { pub(crate) fn main(args: &Args) -> Result<()> { let path = args.file.as_path(); if is_jupyter_notebook(path) { - println!("{}", jupyter::round_trip(path)?); + println!("{}", ruff_notebook::round_trip(path)?); } else { let contents = fs::read_to_string(&args.file)?; println!("{}", round_trip(&contents, &args.file.to_string_lossy())?); diff --git a/crates/ruff_diagnostics/src/lib.rs b/crates/ruff_diagnostics/src/lib.rs index c166e8dbd8..f093861de7 100644 --- a/crates/ruff_diagnostics/src/lib.rs +++ b/crates/ruff_diagnostics/src/lib.rs @@ -1,9 +1,11 @@ pub use diagnostic::{Diagnostic, DiagnosticKind}; pub use edit::Edit; pub use fix::{Applicability, Fix, IsolationLevel}; +pub use source_map::{SourceMap, SourceMarker}; pub use violation::{AlwaysAutofixableViolation, AutofixKind, Violation}; mod diagnostic; mod edit; mod fix; +mod source_map; mod violation; diff --git a/crates/ruff/src/autofix/source_map.rs b/crates/ruff_diagnostics/src/source_map.rs similarity index 71% rename from crates/ruff/src/autofix/source_map.rs rename to crates/ruff_diagnostics/src/source_map.rs index 7871e51d9c..161496eadc 100644 --- a/crates/ruff/src/autofix/source_map.rs +++ b/crates/ruff_diagnostics/src/source_map.rs @@ -1,15 +1,29 @@ use ruff_text_size::{Ranged, TextSize}; -use ruff_diagnostics::Edit; +use crate::Edit; /// Lightweight sourcemap marker representing the source and destination /// position for an [`Edit`]. #[derive(Debug, PartialEq, Eq)] -pub(crate) struct SourceMarker { +pub struct SourceMarker { /// Position of the marker in the original source. - pub(crate) source: TextSize, + source: TextSize, /// Position of the marker in the transformed code. - pub(crate) dest: TextSize, + dest: TextSize, +} + +impl SourceMarker { + pub fn new(source: TextSize, dest: TextSize) -> Self { + Self { source, dest } + } + + pub const fn source(&self) -> TextSize { + self.source + } + + pub const fn dest(&self) -> TextSize { + self.dest + } } /// A collection of [`SourceMarker`]. @@ -18,12 +32,12 @@ pub(crate) struct SourceMarker { /// the transformed code. Here, only the boundaries of edits are tracked instead /// of every single character. #[derive(Default, PartialEq, Eq)] -pub(crate) struct SourceMap(Vec); +pub struct SourceMap(Vec); impl SourceMap { /// Returns a slice of all the markers in the sourcemap in the order they /// were added. - pub(crate) fn markers(&self) -> &[SourceMarker] { + pub fn markers(&self) -> &[SourceMarker] { &self.0 } @@ -31,7 +45,7 @@ impl SourceMap { /// /// The `output_length` is the length of the transformed string before the /// edit is applied. - pub(crate) fn push_start_marker(&mut self, edit: &Edit, output_length: TextSize) { + pub fn push_start_marker(&mut self, edit: &Edit, output_length: TextSize) { self.0.push(SourceMarker { source: edit.start(), dest: output_length, @@ -42,7 +56,7 @@ impl SourceMap { /// /// The `output_length` is the length of the transformed string after the /// edit has been applied. - pub(crate) fn push_end_marker(&mut self, edit: &Edit, output_length: TextSize) { + pub fn push_end_marker(&mut self, edit: &Edit, output_length: TextSize) { if edit.is_insertion() { self.0.push(SourceMarker { source: edit.start(), diff --git a/crates/ruff_formatter/Cargo.toml b/crates/ruff_formatter/Cargo.toml index a4cf178196..88f5bbf892 100644 --- a/crates/ruff_formatter/Cargo.toml +++ b/crates/ruff_formatter/Cargo.toml @@ -17,7 +17,7 @@ drop_bomb = { version = "0.1.5" } rustc-hash = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true } -static_assertions = "1.1.0" +static_assertions = { workspace = true } tracing = { version = "0.1.37", default-features = false, features = ["std"] } unicode-width = { workspace = true } diff --git a/crates/ruff_formatter/src/arguments.rs b/crates/ruff_formatter/src/arguments.rs index 850a734f04..8fa70d73db 100644 --- a/crates/ruff_formatter/src/arguments.rs +++ b/crates/ruff_formatter/src/arguments.rs @@ -70,7 +70,7 @@ impl<'fmt, Context> Argument<'fmt, Context> { /// /// # fn main() -> FormatResult<()> { /// let formatted = format!(SimpleFormatContext::default(), [ -/// format_args!(text("a"), space(), text("b")) +/// format_args!(token("a"), space(), token("b")) /// ])?; /// /// assert_eq!("a b", formatted.print()?.as_code()); @@ -129,17 +129,17 @@ mod tests { #[test] fn test_nesting() { - let mut context = FormatState::new(()); + let mut context = FormatState::new(SimpleFormatContext::default()); let mut buffer = VecBuffer::new(&mut context); write!( &mut buffer, [ - text("function"), + token("function"), space(), - text("a"), + token("a"), space(), - group(&format_args!(text("("), text(")"))) + group(&format_args!(token("("), token(")"))) ] ) .unwrap(); @@ -147,14 +147,14 @@ mod tests { assert_eq!( buffer.into_vec(), vec![ - FormatElement::StaticText { text: "function" }, + FormatElement::Token { text: "function" }, FormatElement::Space, - FormatElement::StaticText { text: "a" }, + FormatElement::Token { text: "a" }, FormatElement::Space, // Group FormatElement::Tag(Tag::StartGroup(tag::Group::new())), - FormatElement::StaticText { text: "(" }, - FormatElement::StaticText { text: ")" }, + FormatElement::Token { text: "(" }, + FormatElement::Token { text: ")" }, FormatElement::Tag(Tag::EndGroup) ] ); diff --git a/crates/ruff_formatter/src/buffer.rs b/crates/ruff_formatter/src/buffer.rs index d2eec095fb..80ba8f15e7 100644 --- a/crates/ruff_formatter/src/buffer.rs +++ b/crates/ruff_formatter/src/buffer.rs @@ -25,9 +25,9 @@ pub trait Buffer { /// let mut state = FormatState::new(SimpleFormatContext::default()); /// let mut buffer = VecBuffer::new(&mut state); /// - /// buffer.write_element(FormatElement::StaticText { text: "test"}); + /// buffer.write_element(FormatElement::Token { text: "test"}); /// - /// assert_eq!(buffer.into_vec(), vec![FormatElement::StaticText { text: "test" }]); + /// assert_eq!(buffer.into_vec(), vec![FormatElement::Token { text: "test" }]); /// ``` fn write_element(&mut self, element: FormatElement); @@ -50,9 +50,9 @@ pub trait Buffer { /// let mut state = FormatState::new(SimpleFormatContext::default()); /// let mut buffer = VecBuffer::new(&mut state); /// - /// buffer.write_fmt(format_args!(text("Hello World"))).unwrap(); + /// buffer.write_fmt(format_args!(token("Hello World"))).unwrap(); /// - /// assert_eq!(buffer.into_vec(), vec![FormatElement::StaticText{ text: "Hello World" }]); + /// assert_eq!(buffer.into_vec(), vec![FormatElement::Token{ text: "Hello World" }]); /// ``` fn write_fmt(mut self: &mut Self, arguments: Arguments) -> FormatResult<()> { write(&mut self, arguments) @@ -316,11 +316,11 @@ where /// write!( /// buffer, /// [ -/// text("The next soft line or space gets replaced by a space"), +/// token("The next soft line or space gets replaced by a space"), /// soft_line_break_or_space(), -/// text("and the line here"), +/// token("and the line here"), /// soft_line_break(), -/// text("is removed entirely.") +/// token("is removed entirely.") /// ] /// ) /// })] @@ -329,10 +329,10 @@ where /// assert_eq!( /// formatted.document().as_ref(), /// &[ -/// FormatElement::StaticText { text: "The next soft line or space gets replaced by a space" }, +/// FormatElement::Token { text: "The next soft line or space gets replaced by a space" }, /// FormatElement::Space, -/// FormatElement::StaticText { text: "and the line here" }, -/// FormatElement::StaticText { text: "is removed entirely." } +/// FormatElement::Token { text: "and the line here" }, +/// FormatElement::Token { text: "is removed entirely." } /// ] /// ); /// @@ -488,19 +488,19 @@ pub trait BufferExtensions: Buffer + Sized { /// let formatted = format!(SimpleFormatContext::default(), [format_with(|f| { /// let mut recording = f.start_recording(); /// - /// write!(recording, [text("A")])?; - /// write!(recording, [text("B")])?; + /// write!(recording, [token("A")])?; + /// write!(recording, [token("B")])?; /// - /// write!(recording, [format_with(|f| write!(f, [text("C"), text("D")]))])?; + /// write!(recording, [format_with(|f| write!(f, [token("C"), token("D")]))])?; /// /// let recorded = recording.stop(); /// assert_eq!( /// recorded.deref(), /// &[ - /// FormatElement::StaticText{ text: "A" }, - /// FormatElement::StaticText{ text: "B" }, - /// FormatElement::StaticText{ text: "C" }, - /// FormatElement::StaticText{ text: "D" } + /// FormatElement::Token{ text: "A" }, + /// FormatElement::Token{ text: "B" }, + /// FormatElement::Token{ text: "C" }, + /// FormatElement::Token{ text: "D" } /// ] /// ); /// diff --git a/crates/ruff_formatter/src/builders.rs b/crates/ruff_formatter/src/builders.rs index 05fce999fb..ba5acf913d 100644 --- a/crates/ruff_formatter/src/builders.rs +++ b/crates/ruff_formatter/src/builders.rs @@ -9,7 +9,9 @@ use Tag::*; use crate::format_element::tag::{Condition, Tag}; use crate::prelude::tag::{DedentMode, GroupMode, LabelId}; use crate::prelude::*; -use crate::{format_element, write, Argument, Arguments, FormatContext, GroupId, TextSize}; +use crate::{ + format_element, write, Argument, Arguments, FormatContext, FormatOptions, GroupId, TextSize, +}; use crate::{Buffer, VecBuffer}; /// A line break that only gets printed if the enclosing `Group` doesn't fit on a single line. @@ -26,7 +28,7 @@ use crate::{Buffer, VecBuffer}; /// /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ -/// group(&format_args![text("a,"), soft_line_break(), text("b")]) +/// group(&format_args![token("a,"), soft_line_break(), token("b")]) /// ])?; /// /// assert_eq!( @@ -52,9 +54,9 @@ use crate::{Buffer, VecBuffer}; /// /// let elements = format!(context, [ /// group(&format_args![ -/// text("a long word,"), +/// token("a long word,"), /// soft_line_break(), -/// text("so that the group doesn't fit on a single line"), +/// token("so that the group doesn't fit on a single line"), /// ]) /// ])?; /// @@ -83,9 +85,9 @@ pub const fn soft_line_break() -> Line { /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("a,"), +/// token("a,"), /// hard_line_break(), -/// text("b"), +/// token("b"), /// hard_line_break() /// ]) /// ])?; @@ -115,9 +117,9 @@ pub const fn hard_line_break() -> Line { /// let elements = format!( /// SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("a,"), +/// token("a,"), /// empty_line(), -/// text("b"), +/// token("b"), /// empty_line() /// ]) /// ])?; @@ -146,9 +148,9 @@ pub const fn empty_line() -> Line { /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("a,"), +/// token("a,"), /// soft_line_break_or_space(), -/// text("b"), +/// token("b"), /// ]) /// ])?; /// @@ -173,9 +175,9 @@ pub const fn empty_line() -> Line { /// /// let elements = format!(context, [ /// group(&format_args![ -/// text("a long word,"), +/// token("a long word,"), /// soft_line_break_or_space(), -/// text("so that the group doesn't fit on a single line"), +/// token("so that the group doesn't fit on a single line"), /// ]) /// ])?; /// @@ -215,12 +217,8 @@ impl std::fmt::Debug for Line { } } -/// Creates a token that gets written as is to the output. Make sure to properly escape the text if -/// it's user generated (e.g. a string and not a language keyword). -/// -/// # Line feeds -/// Tokens may contain line breaks but they must use the line feeds (`\n`). -/// The [`crate::Printer`] converts the line feed characters to the character specified in the [`crate::PrinterOptions`]. +/// Creates a token that gets written as is to the output. A token must be ASCII only and is not allowed +/// to contain any line breaks or tab characters. /// /// # Examples /// @@ -229,7 +227,7 @@ impl std::fmt::Debug for Line { /// use ruff_formatter::prelude::*; /// /// # fn main() -> FormatResult<()> { -/// let elements = format!(SimpleFormatContext::default(), [text("Hello World")])?; +/// let elements = format!(SimpleFormatContext::default(), [token("Hello World")])?; /// /// assert_eq!( /// "Hello World", @@ -248,34 +246,38 @@ impl std::fmt::Debug for Line { /// /// # fn main() -> FormatResult<()> { /// // the tab must be encoded as \\t to not literally print a tab character ("Hello{tab}World" vs "Hello\tWorld") -/// let elements = format!(SimpleFormatContext::default(), [text("\"Hello\\tWorld\"")])?; +/// let elements = format!(SimpleFormatContext::default(), [token("\"Hello\\tWorld\"")])?; /// /// assert_eq!(r#""Hello\tWorld""#, elements.print()?.as_code()); /// # Ok(()) /// # } /// ``` #[inline] -pub fn text(text: &'static str) -> StaticText { - debug_assert_no_newlines(text); +pub fn token(text: &'static str) -> Token { + debug_assert!(text.is_ascii(), "Token must be ASCII text only"); + debug_assert!( + !text.contains(['\n', '\r', '\t']), + "A token should not contain any newlines or tab characters" + ); - StaticText { text } + Token { text } } #[derive(Clone, Copy, Eq, PartialEq)] -pub struct StaticText { +pub struct Token { text: &'static str, } -impl Format for StaticText { +impl Format for Token { fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { - f.write_element(FormatElement::StaticText { text: self.text }); + f.write_element(FormatElement::Token { text: self.text }); Ok(()) } } -impl std::fmt::Debug for StaticText { +impl std::fmt::Debug for Token { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::write!(f, "StaticToken({})", self.text) + std::write!(f, "Token({})", self.text) } } @@ -295,11 +297,11 @@ impl std::fmt::Debug for StaticText { /// /// let elements = format!(SimpleFormatContext::default(), [ /// source_position(TextSize::new(0)), -/// text("\"Hello "), +/// token("\"Hello "), /// source_position(TextSize::new(8)), -/// text("'Ruff'"), +/// token("'Ruff'"), /// source_position(TextSize::new(14)), -/// text("\""), +/// token("\""), /// source_position(TextSize::new(20)) /// ])?; /// @@ -336,64 +338,50 @@ impl Format for SourcePosition { /// Creates a text from a dynamic string with its optional start-position in the source document. /// This is done by allocating a new string internally. -pub fn dynamic_text(text: &str, position: Option) -> DynamicText { +pub fn text(text: &str, position: Option) -> Text { debug_assert_no_newlines(text); - DynamicText { text, position } + Text { text, position } } #[derive(Eq, PartialEq)] -pub struct DynamicText<'a> { +pub struct Text<'a> { text: &'a str, position: Option, } -impl Format for DynamicText<'_> { +impl Format for Text<'_> +where + Context: FormatContext, +{ fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { if let Some(source_position) = self.position { f.write_element(FormatElement::SourcePosition(source_position)); } - f.write_element(FormatElement::DynamicText { + f.write_element(FormatElement::Text { text: self.text.to_string().into_boxed_str(), + text_width: TextWidth::from_text(self.text, f.options().indent_width()), }); Ok(()) } } -impl std::fmt::Debug for DynamicText<'_> { +impl std::fmt::Debug for Text<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::write!(f, "DynamicToken({})", self.text) + std::write!(f, "Text({})", self.text) } } /// Emits a text as it is written in the source document. Optimized to avoid allocations. -pub const fn source_text_slice( - range: TextRange, - newlines: ContainsNewlines, -) -> SourceTextSliceBuilder { - SourceTextSliceBuilder { - range, - new_lines: newlines, - } -} - -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -pub enum ContainsNewlines { - /// The string contains newline characters - Yes, - /// The string contains no newline characters - No, - - /// The string may contain newline characters, search the string to determine if there are any newlines. - Detect, +pub const fn source_text_slice(range: TextRange) -> SourceTextSliceBuilder { + SourceTextSliceBuilder { range } } #[derive(Eq, PartialEq, Debug)] pub struct SourceTextSliceBuilder { range: TextRange, - new_lines: ContainsNewlines, } impl Format for SourceTextSliceBuilder @@ -405,28 +393,12 @@ where let slice = source_code.slice(self.range); debug_assert_no_newlines(slice.text(source_code)); - let contains_newlines = match self.new_lines { - ContainsNewlines::Yes => { - debug_assert!( - slice.text(source_code).contains('\n'), - "Text contains no new line characters but the caller specified that it does." - ); - true - } - ContainsNewlines::No => { - debug_assert!( - !slice.text(source_code).contains('\n'), - "Text contains new line characters but the caller specified that it does not." - ); - false - } - ContainsNewlines::Detect => slice.text(source_code).contains('\n'), - }; + let text_width = TextWidth::from_text( + slice.text(source_code), + f.context().options().indent_width(), + ); - f.write_element(FormatElement::SourceCodeSlice { - slice, - contains_newlines, - }); + f.write_element(FormatElement::SourceCodeSlice { slice, text_width }); Ok(()) } @@ -446,9 +418,9 @@ fn debug_assert_no_newlines(text: &str) { /// /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ -/// text("a"), -/// line_suffix(&text("c"), 0), -/// text("b") +/// token("a"), +/// line_suffix(&token("c"), 0), +/// token("b") /// ])?; /// /// assert_eq!("abc", elements.print()?.as_code()); @@ -470,16 +442,16 @@ fn debug_assert_no_newlines(text: &str) { /// let elements = format!(context, [ /// // Breaks /// group(&format_args![ -/// if_group_breaks(&text("(")), -/// soft_block_indent(&format_args![text("a"), line_suffix(&text(" // a comment"), 13)]), -/// if_group_breaks(&text(")")) +/// if_group_breaks(&token("(")), +/// soft_block_indent(&format_args![token("a"), line_suffix(&token(" // a comment"), 13)]), +/// if_group_breaks(&token(")")) /// ]), /// /// // Fits /// group(&format_args![ -/// if_group_breaks(&text("(")), -/// soft_block_indent(&format_args![text("a"), line_suffix(&text(" // a comment"), 0)]), -/// if_group_breaks(&text(")")) +/// if_group_breaks(&token("(")), +/// soft_block_indent(&format_args![token("a"), line_suffix(&token(" // a comment"), 0)]), +/// if_group_breaks(&token(")")) /// ]), /// ])?; /// # assert_eq!("(\n\ta // a comment\n)a // a comment", elements.print()?.as_code()); @@ -533,11 +505,11 @@ impl std::fmt::Debug for LineSuffix<'_, Context> { /// /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ -/// text("a"), -/// line_suffix(&text("c"), 0), -/// text("b"), +/// token("a"), +/// line_suffix(&token("c"), 0), +/// token("b"), /// line_suffix_boundary(), -/// text("d") +/// token("d") /// ])?; /// /// assert_eq!( @@ -599,7 +571,7 @@ impl Format for LineSuffixBoundary { /// write!(recording, [ /// labelled( /// LabelId::of(MyLabels::Main), -/// &text("'I have a label'") +/// &token("'I have a label'") /// ) /// ])?; /// @@ -608,9 +580,9 @@ impl Format for LineSuffixBoundary { /// let is_labelled = recorded.first().is_some_and( |element| element.has_label(LabelId::of(MyLabels::Main))); /// /// if is_labelled { -/// write!(f, [text(" has label `Main`")]) +/// write!(f, [token(" has label `Main`")]) /// } else { -/// write!(f, [text(" doesn't have label `Main`")]) +/// write!(f, [token(" doesn't have label `Main`")]) /// } /// })] /// )?; @@ -670,7 +642,7 @@ impl std::fmt::Debug for FormatLabelled<'_, Context> { /// /// # fn main() -> FormatResult<()> { /// // the tab must be encoded as \\t to not literally print a tab character ("Hello{tab}World" vs "Hello\tWorld") -/// let elements = format!(SimpleFormatContext::default(), [text("a"), space(), text("b")])?; +/// let elements = format!(SimpleFormatContext::default(), [token("a"), space(), token("b")])?; /// /// assert_eq!("a b", elements.print()?.as_code()); /// # Ok(()) @@ -708,16 +680,16 @@ impl Format for Space { /// /// # fn main() -> FormatResult<()> { /// let block = format!(SimpleFormatContext::default(), [ -/// text("switch {"), +/// token("switch {"), /// block_indent(&format_args![ -/// text("default:"), +/// token("default:"), /// indent(&format_args![ /// // this is where we want to use a /// hard_line_break(), -/// text("break;"), +/// token("break;"), /// ]) /// ]), -/// text("}"), +/// token("}"), /// ])?; /// /// assert_eq!( @@ -772,22 +744,22 @@ impl std::fmt::Debug for Indent<'_, Context> { /// /// # fn main() -> FormatResult<()> { /// let block = format!(SimpleFormatContext::default(), [ -/// text("root"), +/// token("root"), /// align(2, &format_args![ /// hard_line_break(), -/// text("aligned"), +/// token("aligned"), /// dedent(&format_args![ /// hard_line_break(), -/// text("not aligned"), +/// token("not aligned"), /// ]), /// dedent(&indent(&format_args![ /// hard_line_break(), -/// text("Indented, not aligned") +/// token("Indented, not aligned") /// ])) /// ]), /// dedent(&format_args![ /// hard_line_break(), -/// text("Dedent on root level is a no-op.") +/// token("Dedent on root level is a no-op.") /// ]) /// ])?; /// @@ -841,23 +813,23 @@ impl std::fmt::Debug for Dedent<'_, Context> { /// /// # fn main() -> FormatResult<()> { /// let block = format!(SimpleFormatContext::default(), [ -/// text("root"), +/// token("root"), /// indent(&format_args![ /// hard_line_break(), -/// text("indent level 1"), +/// token("indent level 1"), /// indent(&format_args![ /// hard_line_break(), -/// text("indent level 2"), +/// token("indent level 2"), /// align(2, &format_args![ /// hard_line_break(), -/// text("two space align"), +/// token("two space align"), /// dedent_to_root(&format_args![ /// hard_line_break(), -/// text("starts at the beginning of the line") +/// token("starts at the beginning of the line") /// ]), /// ]), /// hard_line_break(), -/// text("end indent level 2"), +/// token("end indent level 2"), /// ]) /// ]), /// ])?; @@ -903,24 +875,24 @@ where /// /// # fn main() -> FormatResult<()> { /// let block = format!(SimpleFormatContext::default(), [ -/// text("a"), +/// token("a"), /// hard_line_break(), -/// text("?"), +/// token("?"), /// space(), /// align(2, &format_args![ -/// text("function () {"), +/// token("function () {"), /// hard_line_break(), -/// text("}"), +/// token("}"), /// ]), /// hard_line_break(), -/// text(":"), +/// token(":"), /// space(), /// align(2, &format_args![ -/// text("function () {"), -/// block_indent(&text("console.log('test');")), -/// text("}"), +/// token("function () {"), +/// block_indent(&token("console.log('test');")), +/// token("}"), /// ]), -/// text(";") +/// token(";") /// ])?; /// /// assert_eq!( @@ -947,30 +919,32 @@ where /// use ruff_formatter::prelude::*; /// /// # fn main() -> FormatResult<()> { +/// use ruff_formatter::IndentWidth; /// let context = SimpleFormatContext::new(SimpleFormatOptions { -/// indent_style: IndentStyle::Space(4), +/// indent_style: IndentStyle::Space, +/// indent_width: IndentWidth::try_from(4).unwrap(), /// ..SimpleFormatOptions::default() /// }); /// /// let block = format!(context, [ -/// text("a"), +/// token("a"), /// hard_line_break(), -/// text("?"), +/// token("?"), /// space(), /// align(2, &format_args![ -/// text("function () {"), +/// token("function () {"), /// hard_line_break(), -/// text("}"), +/// token("}"), /// ]), /// hard_line_break(), -/// text(":"), +/// token(":"), /// space(), /// align(2, &format_args![ -/// text("function () {"), -/// block_indent(&text("console.log('test');")), -/// text("}"), +/// token("function () {"), +/// block_indent(&token("console.log('test');")), +/// token("}"), /// ]), -/// text(";") +/// token(";") /// ])?; /// /// assert_eq!( @@ -1038,13 +1012,13 @@ impl std::fmt::Debug for Align<'_, Context> { /// let block = format![ /// SimpleFormatContext::default(), /// [ -/// text("{"), +/// token("{"), /// block_indent(&format_args![ -/// text("let a = 10;"), +/// token("let a = 10;"), /// hard_line_break(), -/// text("let c = a + 5;"), +/// token("let c = a + 5;"), /// ]), -/// text("}"), +/// token("}"), /// ] /// ]?; /// @@ -1083,13 +1057,13 @@ pub fn block_indent(content: &impl Format) -> BlockIndent(content: &impl Format) -> BlockIndent FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("5,"), +/// token("5,"), /// soft_line_break_or_space(), -/// text("10"), +/// token("10"), /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1157,15 +1131,15 @@ pub fn soft_block_indent(content: &impl Format) -> BlockIndent /// /// let elements = format!(context, [ /// group(&format_args![ -/// text("name"), +/// token("name"), /// space(), -/// text("="), +/// token("="), /// soft_line_indent_or_space(&format_args![ -/// text("firstName"), +/// token("firstName"), /// space(), -/// text("+"), +/// token("+"), /// space(), -/// text("lastName"), +/// token("lastName"), /// ]), /// ]) /// ])?; @@ -1186,10 +1160,10 @@ pub fn soft_block_indent(content: &impl Format) -> BlockIndent /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("a"), +/// token("a"), /// space(), -/// text("="), -/// soft_line_indent_or_space(&text("10")), +/// token("="), +/// soft_line_indent_or_space(&token("10")), /// ]) /// ])?; /// @@ -1289,14 +1263,14 @@ impl std::fmt::Debug for BlockIndent<'_, Context> { /// /// let elements = format!(context, [ /// group(&format_args![ -/// text("{"), +/// token("{"), /// soft_space_or_block_indent(&format_args![ -/// text("aPropertyThatExceeds"), -/// text(":"), +/// token("aPropertyThatExceeds"), +/// token(":"), /// space(), -/// text("'line width'"), +/// token("'line width'"), /// ]), -/// text("}") +/// token("}") /// ]) /// ])?; /// @@ -1316,14 +1290,14 @@ impl std::fmt::Debug for BlockIndent<'_, Context> { /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("{"), +/// token("{"), /// soft_space_or_block_indent(&format_args![ -/// text("a"), -/// text(":"), +/// token("a"), +/// token(":"), /// space(), -/// text("5"), +/// token("5"), /// ]), -/// text("}") +/// token("}") /// ]) /// ])?; /// @@ -1361,15 +1335,15 @@ pub fn soft_space_or_block_indent(content: &impl Format) -> Bl /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), +/// token("3"), /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1394,15 +1368,15 @@ pub fn soft_space_or_block_indent(content: &impl Format) -> Bl /// /// let elements = format!(context, [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("'Good morning! How are you today?',"), +/// token("'Good morning! How are you today?',"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), +/// token("3"), /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1495,37 +1469,37 @@ impl std::fmt::Debug for Group<'_, Context> { /// let content = format_with(|f| { /// let parentheses_id = f.group_id("parentheses"); /// group(&format_args![ -/// if_group_breaks(&text("(")), +/// if_group_breaks(&token("(")), /// indent_if_group_breaks(&format_args![ /// soft_line_break(), /// conditional_group(&format_args![ -/// text("'aaaaaaa'"), +/// token("'aaaaaaa'"), /// soft_line_break_or_space(), -/// text("+"), +/// token("+"), /// space(), /// fits_expanded(&conditional_group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("'Good morning!',"), +/// token("'Good morning!',"), /// soft_line_break_or_space(), -/// text("'How are you?'"), +/// token("'How are you?'"), /// ]), -/// text("]"), +/// token("]"), /// ], tag::Condition::if_group_fits_on_line(parentheses_id))), /// soft_line_break_or_space(), -/// text("+"), +/// token("+"), /// space(), /// conditional_group(&format_args![ -/// text("'bbbb'"), +/// token("'bbbb'"), /// soft_line_break_or_space(), -/// text("and"), +/// token("and"), /// space(), -/// text("'c'") +/// token("'c'") /// ], tag::Condition::if_group_fits_on_line(parentheses_id)) /// ], tag::Condition::if_breaks()), /// ], parentheses_id), /// soft_line_break(), -/// if_group_breaks(&text(")")) +/// if_group_breaks(&token(")")) /// ]) /// .with_group_id(Some(parentheses_id)) /// .fmt(f) @@ -1623,16 +1597,16 @@ impl std::fmt::Debug for ConditionalGroup<'_, Context> { /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("'Good morning! How are you today?',"), +/// token("'Good morning! How are you today?',"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// expand_parent(), // Forces the parent to expand /// soft_line_break_or_space(), -/// text("3"), +/// token("3"), /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1679,16 +1653,16 @@ impl Format for ExpandParent { /// # fn main() -> FormatResult<()> { /// let elements = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), -/// if_group_breaks(&text(",")) +/// token("3"), +/// if_group_breaks(&token(",")) /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1713,16 +1687,16 @@ impl Format for ExpandParent { /// /// let elements = format!(context, [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("'A somewhat longer string to force a line break',"), +/// token("'A somewhat longer string to force a line break',"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), -/// if_group_breaks(&text(",")) +/// token("3"), +/// if_group_breaks(&token(",")) /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1760,16 +1734,16 @@ where /// # fn main() -> FormatResult<()> { /// let formatted = format!(SimpleFormatContext::default(), [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), -/// if_group_fits_on_line(&text(",")) +/// token("3"), +/// if_group_fits_on_line(&token(",")) /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1794,16 +1768,16 @@ where /// /// let formatted = format!(context, [ /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("'A somewhat longer string to force a line break',"), +/// token("'A somewhat longer string to force a line break',"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), -/// if_group_fits_on_line(&text(",")) +/// token("3"), +/// if_group_fits_on_line(&token(",")) /// ]), -/// text("]"), +/// token("]"), /// ]) /// ])?; /// @@ -1860,21 +1834,21 @@ impl IfGroupBreaks<'_, Context> { /// write!(f, [ /// group( /// &format_args![ - /// text("["), + /// token("["), /// soft_block_indent(&format_with(|f| { /// f.fill() - /// .entry(&soft_line_break_or_space(), &text("1,")) - /// .entry(&soft_line_break_or_space(), &text("234568789,")) - /// .entry(&soft_line_break_or_space(), &text("3456789,")) + /// .entry(&soft_line_break_or_space(), &token("1,")) + /// .entry(&soft_line_break_or_space(), &token("234568789,")) + /// .entry(&soft_line_break_or_space(), &token("3456789,")) /// .entry(&soft_line_break_or_space(), &format_args!( - /// text("["), - /// soft_block_indent(&text("4")), - /// text("]"), - /// if_group_breaks(&text(",")).with_group_id(Some(group_id)) + /// token("["), + /// soft_block_indent(&token("4")), + /// token("]"), + /// if_group_breaks(&token(",")).with_group_id(Some(group_id)) /// )) /// .finish() /// })), - /// text("]") + /// token("]") /// ], /// ).with_group_id(Some(group_id)) /// ]) @@ -1931,9 +1905,9 @@ impl std::fmt::Debug for IfGroupBreaks<'_, Context> { /// let id = f.group_id("head"); /// /// write!(f, [ -/// group(&text("Head")).with_group_id(Some(id)), -/// if_group_breaks(&indent(&text("indented"))).with_group_id(Some(id)), -/// if_group_fits_on_line(&text("indented")).with_group_id(Some(id)) +/// group(&token("Head")).with_group_id(Some(id)), +/// if_group_breaks(&indent(&token("indented"))).with_group_id(Some(id)), +/// if_group_fits_on_line(&token("indented")).with_group_id(Some(id)) /// ]) /// /// # }); @@ -1956,8 +1930,8 @@ impl std::fmt::Debug for IfGroupBreaks<'_, Context> { /// let group_id = f.group_id("header"); /// /// write!(f, [ -/// group(&text("(aLongHeaderThatBreaksForSomeReason) =>")).with_group_id(Some(group_id)), -/// indent_if_group_breaks(&format_args![hard_line_break(), text("a => b")], group_id) +/// group(&token("(aLongHeaderThatBreaksForSomeReason) =>")).with_group_id(Some(group_id)), +/// indent_if_group_breaks(&format_args![hard_line_break(), token("a => b")], group_id) /// ]) /// }); /// @@ -1986,8 +1960,8 @@ impl std::fmt::Debug for IfGroupBreaks<'_, Context> { /// let group_id = f.group_id("header"); /// /// write!(f, [ -/// group(&text("(aLongHeaderThatBreaksForSomeReason) =>")).with_group_id(Some(group_id)), -/// indent_if_group_breaks(&format_args![hard_line_break(), text("a => b")], group_id) +/// group(&token("(aLongHeaderThatBreaksForSomeReason) =>")).with_group_id(Some(group_id)), +/// indent_if_group_breaks(&format_args![hard_line_break(), token("a => b")], group_id) /// ]) /// }); /// @@ -2059,17 +2033,17 @@ impl std::fmt::Debug for IndentIfGroupBreaks<'_, Context> { /// /// write!(f, [ /// group(&format_args![ -/// text("a"), +/// token("a"), /// soft_line_break_or_space(), -/// text("+"), +/// token("+"), /// space(), /// fits_expanded(&group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("a,"), space(), text("# comment"), expand_parent(), soft_line_break_or_space(), -/// text("b") +/// token("a,"), space(), token("# comment"), expand_parent(), soft_line_break_or_space(), +/// token("b") /// ]), -/// text("]") +/// token("]") /// ])) /// ]), /// ]) @@ -2161,17 +2135,17 @@ impl std::fmt::Debug for FormatWith { /// impl Format for MyFormat { /// fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { /// write!(f, [ -/// text("("), +/// token("("), /// block_indent(&format_with(|f| { /// let separator = space(); /// let mut join = f.join_with(&separator); /// /// for item in &self.items { -/// join.entry(&format_with(|f| write!(f, [dynamic_text(item, None)]))); +/// join.entry(&format_with(|f| write!(f, [text(item, None)]))); /// } /// join.finish() /// })), -/// text(")") +/// token(")") /// ]) /// } /// } @@ -2212,8 +2186,8 @@ where /// /// struct MyFormat; /// -/// fn generate_values() -> impl Iterator { -/// vec![text("1"), text("2"), text("3"), text("4")].into_iter() +/// fn generate_values() -> impl Iterator { +/// vec![token("1"), token("2"), token("3"), token("4")].into_iter() /// } /// /// impl Format for MyFormat { @@ -2244,7 +2218,7 @@ where /// /// Formatting the same value twice results in a panic. /// -/// ```panics +/// ```should_panic /// use ruff_formatter::prelude::*; /// use ruff_formatter::{SimpleFormatContext, format, write, Buffer}; /// use ruff_text_size::TextSize; @@ -2252,7 +2226,7 @@ where /// let mut count = 0; /// /// let value = format_once(|f| { -/// write!(f, [dynamic_token(&std::format!("Formatted {count}."), TextSize::default())]) +/// write!(f, [text(&std::format!("Formatted {count}."), None)]) /// }); /// /// format!(SimpleFormatContext::default(), [value]).expect("Formatting once works fine"); @@ -2476,54 +2450,54 @@ impl<'a, Context> BestFitting<'a, Context> { /// // Everything fits on a single line /// format_args!( /// group(&format_args![ - /// text("["), + /// token("["), /// soft_block_indent(&format_args![ - /// text("1,"), + /// token("1,"), /// soft_line_break_or_space(), - /// text("2,"), + /// token("2,"), /// soft_line_break_or_space(), - /// text("3"), + /// token("3"), /// ]), - /// text("]") + /// token("]") /// ]), /// space(), - /// text("+"), + /// token("+"), /// space(), - /// text("aVeryLongIdentifier") + /// token("aVeryLongIdentifier") /// ), /// /// // Breaks after `[` and prints each elements on a single line /// // The group is necessary because the variant, by default is printed in flat mode and a /// // hard line break indicates that the content doesn't fit. /// format_args!( - /// text("["), - /// group(&block_indent(&format_args![text("1,"), hard_line_break(), text("2,"), hard_line_break(), text("3")])).should_expand(true), - /// text("]"), + /// token("["), + /// group(&block_indent(&format_args![token("1,"), hard_line_break(), token("2,"), hard_line_break(), token("3")])).should_expand(true), + /// token("]"), /// space(), - /// text("+"), + /// token("+"), /// space(), - /// text("aVeryLongIdentifier") + /// token("aVeryLongIdentifier") /// ), /// /// // Adds parentheses and indents the body, breaks after the operator /// format_args!( - /// text("("), + /// token("("), /// block_indent(&format_args![ - /// text("["), + /// token("["), /// block_indent(&format_args![ - /// text("1,"), + /// token("1,"), /// hard_line_break(), - /// text("2,"), + /// token("2,"), /// hard_line_break(), - /// text("3"), + /// token("3"), /// ]), - /// text("]"), + /// token("]"), /// hard_line_break(), - /// text("+"), + /// token("+"), /// space(), - /// text("aVeryLongIdentifier") + /// token("aVeryLongIdentifier") /// ]), - /// text(")") + /// token(")") /// ) /// ).with_mode(BestFittingMode::AllLines) /// ] diff --git a/crates/ruff_formatter/src/format_element.rs b/crates/ruff_formatter/src/format_element.rs index 14a15cfaf2..48bd7157ca 100644 --- a/crates/ruff_formatter/src/format_element.rs +++ b/crates/ruff_formatter/src/format_element.rs @@ -3,12 +3,14 @@ pub mod tag; use std::borrow::Cow; use std::hash::{Hash, Hasher}; +use std::num::NonZeroU32; use std::ops::Deref; use std::rc::Rc; +use unicode_width::UnicodeWidthChar; use crate::format_element::tag::{GroupMode, LabelId, Tag}; use crate::source_code::SourceCodeSlice; -use crate::TagKind; +use crate::{IndentWidth, TagKind}; use ruff_text_size::TextSize; /// Language agnostic IR for formatting source code. @@ -30,21 +32,20 @@ pub enum FormatElement { /// formatted position. SourcePosition(TextSize), - /// Token constructed by the formatter from a static string - StaticText { text: &'static str }, + /// A ASCII only Token that contains no line breaks or tab characters. + Token { text: &'static str }, - /// Token constructed from the input source as a dynamic - /// string. - DynamicText { + /// An arbitrary text that can contain tabs, newlines, and unicode characters. + Text { /// There's no need for the text to be mutable, using `Box` safes 8 bytes over `String`. text: Box, + text_width: TextWidth, }, /// Text that gets emitted as it is in the source code. Optimized to avoid any allocations. SourceCodeSlice { slice: SourceCodeSlice, - /// Whether the string contains any new line characters - contains_newlines: bool, + text_width: TextWidth, }, /// Prevents that line suffixes move past this boundary. Forces the printer to print any pending @@ -72,19 +73,12 @@ impl std::fmt::Debug for FormatElement { FormatElement::Space => write!(fmt, "Space"), FormatElement::Line(mode) => fmt.debug_tuple("Line").field(mode).finish(), FormatElement::ExpandParent => write!(fmt, "ExpandParent"), - FormatElement::StaticText { text } => { - fmt.debug_tuple("StaticText").field(text).finish() - } - FormatElement::DynamicText { text, .. } => { - fmt.debug_tuple("DynamicText").field(text).finish() - } - FormatElement::SourceCodeSlice { - slice, - contains_newlines, - } => fmt + FormatElement::Token { text } => fmt.debug_tuple("Token").field(text).finish(), + FormatElement::Text { text, .. } => fmt.debug_tuple("DynamicText").field(text).finish(), + FormatElement::SourceCodeSlice { slice, text_width } => fmt .debug_tuple("Text") .field(slice) - .field(contains_newlines) + .field(text_width) .finish(), FormatElement::LineSuffixBoundary => write!(fmt, "LineSuffixBoundary"), FormatElement::BestFitting { variants, mode } => fmt @@ -244,8 +238,8 @@ impl FormatElement { matches!( self, FormatElement::SourceCodeSlice { .. } - | FormatElement::DynamicText { .. } - | FormatElement::StaticText { .. } + | FormatElement::Text { .. } + | FormatElement::Token { .. } ) } @@ -260,11 +254,8 @@ impl FormatElements for FormatElement { FormatElement::ExpandParent => true, FormatElement::Tag(Tag::StartGroup(group)) => !group.mode().is_flat(), FormatElement::Line(line_mode) => matches!(line_mode, LineMode::Hard | LineMode::Empty), - FormatElement::StaticText { text } => text.contains('\n'), - FormatElement::DynamicText { text, .. } => text.contains('\n'), - FormatElement::SourceCodeSlice { - contains_newlines, .. - } => *contains_newlines, + FormatElement::Text { text_width, .. } => text_width.is_multiline(), + FormatElement::SourceCodeSlice { text_width, .. } => text_width.is_multiline(), FormatElement::Interned(interned) => interned.will_break(), // Traverse into the most flat version because the content is guaranteed to expand when even // the most flat version contains some content that forces a break. @@ -275,6 +266,7 @@ impl FormatElements for FormatElement { FormatElement::LineSuffixBoundary | FormatElement::Space | FormatElement::Tag(_) + | FormatElement::Token { .. } | FormatElement::SourcePosition(_) => false, } } @@ -407,6 +399,67 @@ pub trait FormatElements { fn end_tag(&self, kind: TagKind) -> Option<&Tag>; } +/// New-type wrapper for a single-line text unicode width. +/// Mainly to prevent access to the inner value. +/// +/// ## Representation +/// +/// Represents the width by adding 1 to the actual width so that the width can be represented by a [`NonZeroU32`], +/// allowing [`TextWidth`] or [`Option`] fit in 4 bytes rather than 8. +/// +/// This means that 2^32 can not be precisely represented and instead has the same value as 2^32-1. +/// This imprecision shouldn't matter in practice because either text are longer than any configured line width +/// and thus, the text should break. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub struct Width(NonZeroU32); + +impl Width { + pub(crate) const fn new(width: u32) -> Self { + Width(NonZeroU32::MIN.saturating_add(width)) + } + + pub const fn value(self) -> u32 { + self.0.get() - 1 + } +} + +/// The pre-computed unicode width of a text if it is a single-line text or a marker +/// that it is a multiline text if it contains a line feed. +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum TextWidth { + Width(Width), + Multiline, +} + +impl TextWidth { + pub fn from_text(text: &str, indent_width: IndentWidth) -> TextWidth { + let mut width = 0u32; + + for c in text.chars() { + let char_width = match c { + '\t' => indent_width.value(), + '\n' => return TextWidth::Multiline, + #[allow(clippy::cast_possible_truncation)] + c => c.width().unwrap_or(0) as u32, + }; + width += char_width; + } + + Self::Width(Width::new(width)) + } + + pub const fn width(self) -> Option { + match self { + TextWidth::Width(width) => Some(width), + TextWidth::Multiline => None, + } + } + + pub(crate) const fn is_multiline(self) -> bool { + matches!(self, TextWidth::Multiline) + } +} + #[cfg(test)] mod tests { @@ -434,19 +487,21 @@ mod sizes { // be recomputed at a later point in time? // You reduced the size of a format element? Excellent work! + use super::{BestFittingVariants, Interned, TextWidth}; use static_assertions::assert_eq_size; assert_eq_size!(ruff_text_size::TextRange, [u8; 8]); - assert_eq_size!(crate::prelude::tag::VerbatimKind, [u8; 8]); - assert_eq_size!(crate::prelude::Interned, [u8; 16]); - assert_eq_size!(crate::format_element::BestFittingVariants, [u8; 16]); + assert_eq_size!(TextWidth, [u8; 4]); + assert_eq_size!(super::tag::VerbatimKind, [u8; 8]); + assert_eq_size!(Interned, [u8; 16]); + assert_eq_size!(BestFittingVariants, [u8; 16]); #[cfg(not(debug_assertions))] assert_eq_size!(crate::SourceCodeSlice, [u8; 8]); #[cfg(not(debug_assertions))] - assert_eq_size!(crate::format_element::Tag, [u8; 16]); + assert_eq_size!(super::Tag, [u8; 16]); #[cfg(not(debug_assertions))] - assert_eq_size!(crate::FormatElement, [u8; 24]); + assert_eq_size!(super::FormatElement, [u8; 24]); } diff --git a/crates/ruff_formatter/src/format_element/document.rs b/crates/ruff_formatter/src/format_element/document.rs index 46ca5a7104..9321d7a97c 100644 --- a/crates/ruff_formatter/src/format_element/document.rs +++ b/crates/ruff_formatter/src/format_element/document.rs @@ -9,7 +9,7 @@ use crate::prelude::*; use crate::source_code::SourceCode; use crate::{ format, write, BufferExtensions, Format, FormatContext, FormatElement, FormatOptions, - FormatResult, Formatter, IndentStyle, LineWidth, PrinterOptions, TabWidth, + FormatResult, Formatter, IndentStyle, IndentWidth, LineWidth, PrinterOptions, }; use super::tag::Tag; @@ -104,11 +104,11 @@ impl Document { expands = false; continue; } - FormatElement::StaticText { text } => text.contains('\n'), - FormatElement::DynamicText { text, .. } => text.contains('\n'), - FormatElement::SourceCodeSlice { - contains_newlines, .. - } => *contains_newlines, + FormatElement::Text { + text: _, + text_width, + } => text_width.is_multiline(), + FormatElement::SourceCodeSlice { text_width, .. } => text_width.is_multiline(), FormatElement::ExpandParent | FormatElement::Line(LineMode::Hard | LineMode::Empty) => true, _ => false, @@ -213,11 +213,11 @@ struct IrFormatOptions; impl FormatOptions for IrFormatOptions { fn indent_style(&self) -> IndentStyle { - IndentStyle::Space(2) + IndentStyle::Space } - fn tab_width(&self) -> TabWidth { - TabWidth::default() + fn indent_width(&self) -> IndentWidth { + IndentWidth::default() } fn line_width(&self) -> LineWidth { @@ -227,7 +227,7 @@ impl FormatOptions for IrFormatOptions { fn as_print_options(&self) -> PrinterOptions { PrinterOptions { line_width: self.line_width(), - indent_style: IndentStyle::Space(2), + indent_style: IndentStyle::Space, ..PrinterOptions::default() } } @@ -249,29 +249,35 @@ impl Format> for &[FormatElement] { while let Some(element) = iter.next() { if !first_element && !in_text && !element.is_end_tag() { // Write a separator between every two elements - write!(f, [text(","), soft_line_break_or_space()])?; + write!(f, [token(","), soft_line_break_or_space()])?; } first_element = false; match element { element @ (FormatElement::Space - | FormatElement::StaticText { .. } - | FormatElement::DynamicText { .. } + | FormatElement::Token { .. } + | FormatElement::Text { .. } | FormatElement::SourceCodeSlice { .. }) => { fn write_escaped(element: &FormatElement, f: &mut Formatter) { - let text = match element { - FormatElement::StaticText { text } => text, - FormatElement::DynamicText { text } => text.as_ref(), - FormatElement::SourceCodeSlice { slice, .. } => { - slice.text(f.context().source_code()) + let (text, text_width) = match element { + #[allow(clippy::cast_possible_truncation)] + FormatElement::Token { text } => { + (*text, TextWidth::Width(Width::new(text.len() as u32))) + } + FormatElement::Text { text, text_width } => { + (text.as_ref(), *text_width) + } + FormatElement::SourceCodeSlice { slice, text_width } => { + (slice.text(f.context().source_code()), *text_width) } _ => unreachable!(), }; if text.contains('"') { - f.write_element(FormatElement::DynamicText { + f.write_element(FormatElement::Text { text: text.replace('"', r#"\""#).into(), + text_width, }); } else { f.write_element(element.clone()); @@ -279,14 +285,14 @@ impl Format> for &[FormatElement] { } if !in_text { - write!(f, [text("\"")])?; + write!(f, [token("\"")])?; } in_text = true; match element { FormatElement::Space => { - write!(f, [text(" ")])?; + write!(f, [token(" ")])?; } element if element.is_text() => { write_escaped(element, f); @@ -297,45 +303,42 @@ impl Format> for &[FormatElement] { let is_next_text = iter.peek().is_some_and(|e| e.is_text() || e.is_space()); if !is_next_text { - write!(f, [text("\"")])?; + write!(f, [token("\"")])?; in_text = false; } } FormatElement::Line(mode) => match mode { LineMode::SoftOrSpace => { - write!(f, [text("soft_line_break_or_space")])?; + write!(f, [token("soft_line_break_or_space")])?; } LineMode::Soft => { - write!(f, [text("soft_line_break")])?; + write!(f, [token("soft_line_break")])?; } LineMode::Hard => { - write!(f, [text("hard_line_break")])?; + write!(f, [token("hard_line_break")])?; } LineMode::Empty => { - write!(f, [text("empty_line")])?; + write!(f, [token("empty_line")])?; } }, FormatElement::ExpandParent => { - write!(f, [text("expand_parent")])?; + write!(f, [token("expand_parent")])?; } FormatElement::SourcePosition(position) => { write!( f, - [dynamic_text( - &std::format!("source_position({position:?})"), - None - )] + [text(&std::format!("source_position({position:?})"), None)] )?; } FormatElement::LineSuffixBoundary => { - write!(f, [text("line_suffix_boundary")])?; + write!(f, [token("line_suffix_boundary")])?; } FormatElement::BestFitting { variants, mode } => { - write!(f, [text("best_fitting([")])?; + write!(f, [token("best_fitting([")])?; f.write_elements([ FormatElement::Tag(StartIndent), FormatElement::Line(LineMode::Hard), @@ -350,13 +353,13 @@ impl Format> for &[FormatElement] { FormatElement::Line(LineMode::Hard), ]); - write!(f, [text("]")])?; + write!(f, [token("]")])?; if *mode != BestFittingMode::FirstLine { - write!(f, [dynamic_text(&std::format!(", mode: {mode:?}"), None),])?; + write!(f, [text(&std::format!(", mode: {mode:?}"), None),])?; } - write!(f, [text(")")])?; + write!(f, [token(")")])?; } FormatElement::Interned(interned) => { @@ -370,7 +373,7 @@ impl Format> for &[FormatElement] { write!( f, [ - dynamic_text(&std::format!(""), None), + text(&std::format!(""), None), space(), &&**interned, ] @@ -379,10 +382,7 @@ impl Format> for &[FormatElement] { Some(reference) => { write!( f, - [dynamic_text( - &std::format!(""), - None - )] + [text(&std::format!(""), None)] )?; } } @@ -401,9 +401,9 @@ impl Format> for &[FormatElement] { write!( f, [ - text(">"), + token(">"), ] )?; first_element = false; @@ -414,13 +414,13 @@ impl Format> for &[FormatElement] { f, [ ContentArrayEnd, - text(")"), + token(")"), soft_line_break_or_space(), - text("ERROR>") + token("ERROR>") ] )?; first_element = false; @@ -434,7 +434,7 @@ impl Format> for &[FormatElement] { match tag { StartIndent => { - write!(f, [text("indent(")])?; + write!(f, [token("indent(")])?; } StartDedent(mode) => { @@ -443,16 +443,16 @@ impl Format> for &[FormatElement] { DedentMode::Root => "dedentRoot", }; - write!(f, [text(label), text("(")])?; + write!(f, [token(label), token("(")])?; } StartAlign(tag::Align(count)) => { write!( f, [ - text("align("), - dynamic_text(&count.to_string(), None), - text(","), + token("align("), + text(&count.to_string(), None), + token(","), space(), ] )?; @@ -462,27 +462,27 @@ impl Format> for &[FormatElement] { write!( f, [ - text("line_suffix("), - dynamic_text(&std::format!("{reserved_width:?}"), None), - text(","), + token("line_suffix("), + text(&std::format!("{reserved_width:?}"), None), + token(","), space(), ] )?; } StartVerbatim(_) => { - write!(f, [text("verbatim(")])?; + write!(f, [token("verbatim(")])?; } StartGroup(group) => { - write!(f, [text("group(")])?; + write!(f, [token("group(")])?; if let Some(group_id) = group.id() { write!( f, [ - dynamic_text(&std::format!("\"{group_id:?}\""), None), - text(","), + text(&std::format!("\"{group_id:?}\""), None), + token(","), space(), ] )?; @@ -491,10 +491,10 @@ impl Format> for &[FormatElement] { match group.mode() { GroupMode::Flat => {} GroupMode::Expand => { - write!(f, [text("expand: true,"), space()])?; + write!(f, [token("expand: true,"), space()])?; } GroupMode::Propagated => { - write!(f, [text("expand: propagated,"), space()])?; + write!(f, [token("expand: propagated,"), space()])?; } } } @@ -503,10 +503,10 @@ impl Format> for &[FormatElement] { write!( f, [ - text("conditional_group(condition:"), + token("conditional_group(condition:"), space(), group.condition(), - text(","), + token(","), space() ] )?; @@ -514,10 +514,10 @@ impl Format> for &[FormatElement] { match group.mode() { GroupMode::Flat => {} GroupMode::Expand => { - write!(f, [text("expand: true,"), space()])?; + write!(f, [token("expand: true,"), space()])?; } GroupMode::Propagated => { - write!(f, [text("expand: propagated,"), space()])?; + write!(f, [token("expand: propagated,"), space()])?; } } } @@ -526,9 +526,9 @@ impl Format> for &[FormatElement] { write!( f, [ - text("indent_if_group_breaks("), - dynamic_text(&std::format!("\"{id:?}\""), None), - text(","), + token("indent_if_group_breaks("), + text(&std::format!("\"{id:?}\""), None), + token(","), space(), ] )?; @@ -537,10 +537,10 @@ impl Format> for &[FormatElement] { StartConditionalContent(condition) => { match condition.mode { PrintMode::Flat => { - write!(f, [text("if_group_fits_on_line(")])?; + write!(f, [token("if_group_fits_on_line(")])?; } PrintMode::Expanded => { - write!(f, [text("if_group_breaks(")])?; + write!(f, [token("if_group_breaks(")])?; } } @@ -548,8 +548,8 @@ impl Format> for &[FormatElement] { write!( f, [ - dynamic_text(&std::format!("\"{group_id:?}\""), None), - text(","), + text(&std::format!("\"{group_id:?}\""), None), + token(","), space(), ] )?; @@ -560,36 +560,36 @@ impl Format> for &[FormatElement] { write!( f, [ - text("label("), - dynamic_text(&std::format!("\"{label_id:?}\""), None), - text(","), + token("label("), + text(&std::format!("\"{label_id:?}\""), None), + token(","), space(), ] )?; } StartFill => { - write!(f, [text("fill(")])?; + write!(f, [token("fill(")])?; } StartFitsExpanded(tag::FitsExpanded { condition, propagate_expand, }) => { - write!(f, [text("fits_expanded(propagate_expand:"), space()])?; + write!(f, [token("fits_expanded(propagate_expand:"), space()])?; if propagate_expand.get() { - write!(f, [text("true")])?; + write!(f, [token("true")])?; } else { - write!(f, [text("false")])?; + write!(f, [token("false")])?; } - write!(f, [text(","), space()])?; + write!(f, [token(","), space()])?; if let Some(condition) = condition { write!( f, - [text("condition:"), space(), condition, text(","), space()] + [token("condition:"), space(), condition, token(","), space()] )?; } } @@ -611,7 +611,7 @@ impl Format> for &[FormatElement] { | EndDedent | EndFitsExpanded | EndVerbatim => { - write!(f, [ContentArrayEnd, text(")")])?; + write!(f, [ContentArrayEnd, token(")")])?; } }; @@ -627,9 +627,9 @@ impl Format> for &[FormatElement] { f, [ ContentArrayEnd, - text(")"), + token(")"), soft_line_break_or_space(), - dynamic_text(&std::format!(">"), None), + text(&std::format!(">"), None), ] )?; } @@ -644,7 +644,7 @@ impl Format> for ContentArrayStart { fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { use Tag::{StartGroup, StartIndent}; - write!(f, [text("[")])?; + write!(f, [token("[")])?; f.write_elements([ FormatElement::Tag(StartGroup(tag::Group::new())), @@ -667,7 +667,7 @@ impl Format> for ContentArrayEnd { FormatElement::Tag(EndGroup), ]); - write!(f, [text("]")]) + write!(f, [token("]")]) } } @@ -767,22 +767,22 @@ impl FormatElements for [FormatElement] { impl Format> for Condition { fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { match (self.mode, self.group_id) { - (PrintMode::Flat, None) => write!(f, [text("if_fits_on_line")]), + (PrintMode::Flat, None) => write!(f, [token("if_fits_on_line")]), (PrintMode::Flat, Some(id)) => write!( f, [ - text("if_group_fits_on_line("), - dynamic_text(&std::format!("\"{id:?}\""), None), - text(")") + token("if_group_fits_on_line("), + text(&std::format!("\"{id:?}\""), None), + token(")") ] ), - (PrintMode::Expanded, None) => write!(f, [text("if_breaks")]), + (PrintMode::Expanded, None) => write!(f, [token("if_breaks")]), (PrintMode::Expanded, Some(id)) => write!( f, [ - text("if_group_breaks("), - dynamic_text(&std::format!("\"{id:?}\""), None), - text(")") + token("if_group_breaks("), + text(&std::format!("\"{id:?}\""), None), + token(")") ] ), } @@ -805,11 +805,11 @@ mod tests { write!( f, [group(&format_args![ - text("("), + token("("), soft_block_indent(&format_args![ - text("Some longer content"), + token("Some longer content"), space(), - text("That should ultimately break"), + token("That should ultimately break"), ]) ])] ) @@ -838,7 +838,7 @@ mod tests { fn escapes_quotes() { let formatted = format!( SimpleFormatContext::default(), - [text(r#""""Python docstring""""#)] + [token(r#""""Python docstring""""#)] ) .unwrap(); @@ -859,17 +859,11 @@ mod tests { write!( f, [group(&format_args![ - text("("), + token("("), soft_block_indent(&format_args![ - source_text_slice( - TextRange::at(TextSize::new(0), TextSize::new(19)), - ContainsNewlines::No - ), + source_text_slice(TextRange::at(TextSize::new(0), TextSize::new(19)),), space(), - source_text_slice( - TextRange::at(TextSize::new(20), TextSize::new(28)), - ContainsNewlines::No - ), + source_text_slice(TextRange::at(TextSize::new(20), TextSize::new(28)),), ]) ])] ) @@ -899,16 +893,16 @@ mod tests { use Tag::*; let document = Document::from(vec![ - FormatElement::StaticText { text: "[" }, + FormatElement::Token { text: "[" }, FormatElement::Tag(StartGroup(tag::Group::new())), FormatElement::Tag(StartIndent), FormatElement::Line(LineMode::Soft), - FormatElement::StaticText { text: "a" }, + FormatElement::Token { text: "a" }, // Close group instead of indent FormatElement::Tag(EndGroup), FormatElement::Line(LineMode::Soft), FormatElement::Tag(EndIndent), - FormatElement::StaticText { text: "]" }, + FormatElement::Token { text: "]" }, // End tag without start FormatElement::Tag(EndIndent), // Start tag without an end diff --git a/crates/ruff_formatter/src/format_extensions.rs b/crates/ruff_formatter/src/format_extensions.rs index 1964ad246b..6c2aa85e19 100644 --- a/crates/ruff_formatter/src/format_extensions.rs +++ b/crates/ruff_formatter/src/format_extensions.rs @@ -34,7 +34,7 @@ pub trait MemoizeFormat { /// let value = self.value.get(); /// self.value.set(value + 1); /// - /// write!(f, [dynamic_text(&std::format!("Formatted {value} times."), None)]) + /// write!(f, [text(&std::format!("Formatted {value} times."), None)]) /// } /// } /// @@ -110,9 +110,9 @@ where /// let current = self.value.get(); /// /// write!(f, [ - /// text("Count:"), + /// token("Count:"), /// space(), - /// dynamic_text(&std::format!("{current}"), None), + /// text(&std::format!("{current}"), None), /// hard_line_break() /// ])?; /// @@ -127,9 +127,9 @@ where /// let counter_content = counter.inspect(f)?; /// /// if counter_content.will_break() { - /// write!(f, [text("Counter:"), block_indent(&counter)]) + /// write!(f, [token("Counter:"), block_indent(&counter)]) /// } else { - /// write!(f, [text("Counter:"), counter]) + /// write!(f, [token("Counter:"), counter]) /// }?; /// /// write!(f, [counter]) diff --git a/crates/ruff_formatter/src/formatter.rs b/crates/ruff_formatter/src/formatter.rs index 9a43635807..8274485bc5 100644 --- a/crates/ruff_formatter/src/formatter.rs +++ b/crates/ruff_formatter/src/formatter.rs @@ -52,11 +52,11 @@ impl<'buf, Context> Formatter<'buf, Context> { /// # fn main() -> FormatResult<()> { /// let formatted = format!(SimpleFormatContext::default(), [format_with(|f| { /// f.join() - /// .entry(&text("a")) + /// .entry(&token("a")) /// .entry(&space()) - /// .entry(&text("+")) + /// .entry(&token("+")) /// .entry(&space()) - /// .entry(&text("b")) + /// .entry(&token("b")) /// .finish() /// })])?; /// @@ -83,11 +83,11 @@ impl<'buf, Context> Formatter<'buf, Context> { /// /// # fn main() -> FormatResult<()> { /// let formatted = format!(SimpleFormatContext::default(), [format_with(|f| { - /// f.join_with(&format_args!(text(","), space())) - /// .entry(&text("1")) - /// .entry(&text("2")) - /// .entry(&text("3")) - /// .entry(&text("4")) + /// f.join_with(&format_args!(token(","), space())) + /// .entry(&token("1")) + /// .entry(&token("2")) + /// .entry(&token("3")) + /// .entry(&token("4")) /// .finish() /// })])?; /// @@ -121,10 +121,10 @@ impl<'buf, Context> Formatter<'buf, Context> { /// # fn main() -> FormatResult<()> { /// let formatted = format!(SimpleFormatContext::default(), [format_with(|f| { /// f.fill() - /// .entry(&soft_line_break_or_space(), &text("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) - /// .entry(&soft_line_break_or_space(), &text("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) - /// .entry(&soft_line_break_or_space(), &text("cccccccccccccccccccccccccccccc")) - /// .entry(&soft_line_break_or_space(), &text("dddddddddddddddddddddddddddddd")) + /// .entry(&soft_line_break_or_space(), &token("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) + /// .entry(&soft_line_break_or_space(), &token("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) + /// .entry(&soft_line_break_or_space(), &token("cccccccccccccccccccccccccccccc")) + /// .entry(&soft_line_break_or_space(), &token("dddddddddddddddddddddddddddddd")) /// .finish() /// })])?; /// @@ -142,10 +142,10 @@ impl<'buf, Context> Formatter<'buf, Context> { /// /// # fn main() -> FormatResult<()> { /// let entries = vec![ - /// text("Important: "), - /// text("Please do not commit memory bugs such as segfaults, buffer overflows, etc. otherwise you "), - /// text("will"), - /// text(" be reprimanded") + /// token("Important: "), + /// token("Please do not commit memory bugs such as segfaults, buffer overflows, etc. otherwise you "), + /// token("will"), + /// token(" be reprimanded") /// ]; /// /// let formatted = format!(SimpleFormatContext::default(), [format_with(|f| { diff --git a/crates/ruff_formatter/src/lib.rs b/crates/ruff_formatter/src/lib.rs index 41a3b43f1e..11fee92fab 100644 --- a/crates/ruff_formatter/src/lib.rs +++ b/crates/ruff_formatter/src/lib.rs @@ -52,23 +52,20 @@ pub use crate::diagnostics::{ActualStart, FormatError, InvalidDocumentError, Pri pub use format_element::{normalize_newlines, FormatElement, LINE_TERMINATORS}; pub use group_id::GroupId; use ruff_text_size::{TextRange, TextSize}; -use std::str::FromStr; #[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[derive(Default)] pub enum IndentStyle { - /// Tab + /// Use tabs to indent code. #[default] Tab, - /// Space, with its quantity - Space(u8), + /// Use [`IndentWidth`] spaces to indent code. + Space, } impl IndentStyle { - pub const DEFAULT_SPACES: u8 = 2; - /// Returns `true` if this is an [`IndentStyle::Tab`]. pub const fn is_tab(&self) -> bool { matches!(self, IndentStyle::Tab) @@ -76,58 +73,42 @@ impl IndentStyle { /// Returns `true` if this is an [`IndentStyle::Space`]. pub const fn is_space(&self) -> bool { - matches!(self, IndentStyle::Space(_)) - } -} - -impl FromStr for IndentStyle { - type Err = &'static str; - - fn from_str(s: &str) -> Result { - match s { - "tab" | "Tabs" => Ok(Self::Tab), - "space" | "Spaces" => Ok(Self::Space(IndentStyle::DEFAULT_SPACES)), - // TODO: replace this error with a diagnostic - v => { - let v = v.strip_prefix("Spaces, size: ").unwrap_or(v); - - u8::from_str(v) - .map(Self::Space) - .map_err(|_| "Value not supported for IndentStyle") - } - } + matches!(self, IndentStyle::Space) } } impl std::fmt::Display for IndentStyle { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - IndentStyle::Tab => std::write!(f, "Tab"), - IndentStyle::Space(size) => std::write!(f, "Spaces, size: {size}"), + IndentStyle::Tab => std::write!(f, "tab"), + IndentStyle::Space => std::write!(f, "space"), } } } -/// The visual width of a `\t` character. +/// The visual width of a indentation. +/// +/// Determines the visual width of a tab character (`\t`) and the number of +/// spaces per indent when using [`IndentStyle::Space`]. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub struct TabWidth(NonZeroU8); +pub struct IndentWidth(NonZeroU8); -impl TabWidth { +impl IndentWidth { /// Return the numeric value for this [`LineWidth`] pub const fn value(&self) -> u32 { self.0.get() as u32 } } -impl Default for TabWidth { +impl Default for IndentWidth { fn default() -> Self { Self(NonZeroU8::new(2).unwrap()) } } -impl TryFrom for TabWidth { +impl TryFrom for IndentWidth { type Error = TryFromIntError; fn try_from(value: u8) -> Result { @@ -196,16 +177,8 @@ pub trait FormatOptions { /// The indent style. fn indent_style(&self) -> IndentStyle; - /// The visual width of a tab character. - fn tab_width(&self) -> TabWidth; - /// The visual width of an indent - fn indent_width(&self) -> u32 { - match self.indent_style() { - IndentStyle::Tab => self.tab_width().value(), - IndentStyle::Space(spaces) => u32::from(spaces), - } - } + fn indent_width(&self) -> IndentWidth; /// What's the max width of a line. Defaults to 80. fn line_width(&self) -> LineWidth; @@ -250,6 +223,7 @@ impl FormatContext for SimpleFormatContext { #[derive(Debug, Default, Eq, PartialEq, Clone)] pub struct SimpleFormatOptions { pub indent_style: IndentStyle, + pub indent_width: IndentWidth, pub line_width: LineWidth, } @@ -258,8 +232,8 @@ impl FormatOptions for SimpleFormatOptions { self.indent_style } - fn tab_width(&self) -> TabWidth { - TabWidth::default() + fn indent_width(&self) -> IndentWidth { + self.indent_width } fn line_width(&self) -> LineWidth { @@ -270,6 +244,7 @@ impl FormatOptions for SimpleFormatOptions { PrinterOptions { line_width: self.line_width, indent_style: self.indent_style, + indent_width: self.indent_width, source_map_generation: SourceMapGeneration::Enabled, ..PrinterOptions::default() } @@ -455,7 +430,7 @@ pub type FormatResult = Result; /// fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { /// write!(f, [ /// hard_line_break(), -/// dynamic_text(&self.0, None), +/// text(&self.0, None), /// hard_line_break(), /// ]) /// } @@ -704,7 +679,7 @@ where /// let mut state = FormatState::new(SimpleFormatContext::default()); /// let mut buffer = VecBuffer::new(&mut state); /// -/// write!(&mut buffer, [format_args!(text("Hello World"))])?; +/// write!(&mut buffer, [format_args!(token("Hello World"))])?; /// /// let formatted = Formatted::new(Document::from(buffer.into_vec()), SimpleFormatContext::default()); /// @@ -723,7 +698,7 @@ where /// let mut state = FormatState::new(SimpleFormatContext::default()); /// let mut buffer = VecBuffer::new(&mut state); /// -/// write!(&mut buffer, [text("Hello World")])?; +/// write!(&mut buffer, [token("Hello World")])?; /// /// let formatted = Formatted::new(Document::from(buffer.into_vec()), SimpleFormatContext::default()); /// @@ -754,7 +729,7 @@ pub fn write( /// use ruff_formatter::{format, format_args}; /// /// # fn main() -> FormatResult<()> { -/// let formatted = format!(SimpleFormatContext::default(), [&format_args!(text("test"))])?; +/// let formatted = format!(SimpleFormatContext::default(), [&format_args!(token("test"))])?; /// assert_eq!("test", formatted.print()?.as_code()); /// # Ok(()) /// # } @@ -767,7 +742,7 @@ pub fn write( /// use ruff_formatter::{format}; /// /// # fn main() -> FormatResult<()> { -/// let formatted = format!(SimpleFormatContext::default(), [text("test")])?; +/// let formatted = format!(SimpleFormatContext::default(), [token("test")])?; /// assert_eq!("test", formatted.print()?.as_code()); /// # Ok(()) /// # } diff --git a/crates/ruff_formatter/src/macros.rs b/crates/ruff_formatter/src/macros.rs index 2e6b28bf23..97a4cc6961 100644 --- a/crates/ruff_formatter/src/macros.rs +++ b/crates/ruff_formatter/src/macros.rs @@ -16,7 +16,7 @@ /// /// # fn main() -> FormatResult<()> { /// let formatted = format!(SimpleFormatContext::default(), [ -/// format_args!(text("Hello World")) +/// format_args!(token("Hello World")) /// ])?; /// /// assert_eq!("Hello World", formatted.print()?.as_code()); @@ -52,15 +52,15 @@ macro_rules! format_args { /// # fn main() -> FormatResult<()> { /// let mut state = FormatState::new(SimpleFormatContext::default()); /// let mut buffer = VecBuffer::new(&mut state); -/// write!(&mut buffer, [text("Hello"), space()])?; -/// write!(&mut buffer, [text("World")])?; +/// write!(&mut buffer, [token("Hello"), space()])?; +/// write!(&mut buffer, [token("World")])?; /// /// assert_eq!( /// buffer.into_vec(), /// vec![ -/// FormatElement::StaticText { text: "Hello" }, +/// FormatElement::Token { text: "Hello" }, /// FormatElement::Space, -/// FormatElement::StaticText { text: "World" }, +/// FormatElement::Token { text: "World" }, /// ] /// ); /// # Ok(()) @@ -86,10 +86,10 @@ macro_rules! write { /// let mut state = FormatState::new(SimpleFormatContext::default()); /// let mut buffer = VecBuffer::new(&mut state); /// -/// dbg_write!(buffer, [text("Hello")])?; +/// dbg_write!(buffer, [token("Hello")])?; /// // ^-- prints: [src/main.rs:7][0] = StaticToken("Hello") /// -/// assert_eq!(buffer.into_vec(), vec![FormatElement::StaticText { text: "Hello" }]); +/// assert_eq!(buffer.into_vec(), vec![FormatElement::Token { text: "Hello" }]); /// # Ok(()) /// # } /// ``` @@ -126,14 +126,14 @@ macro_rules! dbg_write { /// use ruff_formatter::prelude::*; /// use ruff_formatter::format; /// -/// let formatted = format!(SimpleFormatContext::default(), [text("("), text("a"), text(")")]).unwrap(); +/// let formatted = format!(SimpleFormatContext::default(), [token("("), token("a"), token(")")]).unwrap(); /// /// assert_eq!( /// formatted.into_document(), /// Document::from(vec![ -/// FormatElement::StaticText { text: "(" }, -/// FormatElement::StaticText { text: "a" }, -/// FormatElement::StaticText { text: ")" }, +/// FormatElement::Token { text: "(" }, +/// FormatElement::Token { text: "a" }, +/// FormatElement::Token { text: ")" }, /// ]) /// ); /// ``` @@ -160,49 +160,49 @@ macro_rules! format { /// let formatted = format!( /// SimpleFormatContext::default(), /// [ -/// text("aVeryLongIdentifier"), +/// token("aVeryLongIdentifier"), /// best_fitting!( /// // Everything fits on a single line /// format_args!( -/// text("("), +/// token("("), /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), +/// token("3"), /// ]), -/// text("]") +/// token("]") /// ]), -/// text(")") +/// token(")") /// ), /// /// // Breaks after `[`, but prints all elements on a single line /// format_args!( -/// text("("), -/// text("["), -/// block_indent(&text("1, 2, 3")), -/// text("]"), -/// text(")"), +/// token("("), +/// token("["), +/// block_indent(&token("1, 2, 3")), +/// token("]"), +/// token(")"), /// ), /// /// // Breaks after `[` and prints each element on a single line /// format_args!( -/// text("("), +/// token("("), /// block_indent(&format_args![ -/// text("["), +/// token("["), /// block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// hard_line_break(), -/// text("2,"), +/// token("2,"), /// hard_line_break(), -/// text("3"), +/// token("3"), /// ]), -/// text("]"), +/// token("]"), /// ]), -/// text(")") +/// token(")") /// ) /// ) /// ] @@ -251,38 +251,38 @@ macro_rules! format { /// best_fitting!( /// // Prints the method call on the line but breaks the array. /// format_args!( -/// text("expect(a).toMatch("), +/// token("expect(a).toMatch("), /// group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), +/// token("3"), /// ]), -/// text("]") +/// token("]") /// ]).should_expand(true), -/// text(")") +/// token(")") /// ), /// /// // Breaks after `(` /// format_args!( -/// text("expect(a).toMatch("), +/// token("expect(a).toMatch("), /// group(&soft_block_indent( /// &group(&format_args![ -/// text("["), +/// token("["), /// soft_block_indent(&format_args![ -/// text("1,"), +/// token("1,"), /// soft_line_break_or_space(), -/// text("2,"), +/// token("2,"), /// soft_line_break_or_space(), -/// text("3"), +/// token("3"), /// ]), -/// text("]") +/// token("]") /// ]).should_expand(true), /// )).should_expand(true), -/// text(")") +/// token(")") /// ), /// ) /// ] @@ -343,44 +343,44 @@ mod tests { struct TestFormat; - impl Format<()> for TestFormat { - fn fmt(&self, f: &mut Formatter<()>) -> FormatResult<()> { - write!(f, [text("test")]) + impl Format for TestFormat { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + write!(f, [token("test")]) } } #[test] fn test_single_element() { - let mut state = FormatState::new(()); + let mut state = FormatState::new(SimpleFormatContext::default()); let mut buffer = VecBuffer::new(&mut state); write![&mut buffer, [TestFormat]].unwrap(); assert_eq!( buffer.into_vec(), - vec![FormatElement::StaticText { text: "test" }] + vec![FormatElement::Token { text: "test" }] ); } #[test] fn test_multiple_elements() { - let mut state = FormatState::new(()); + let mut state = FormatState::new(SimpleFormatContext::default()); let mut buffer = VecBuffer::new(&mut state); write![ &mut buffer, - [text("a"), space(), text("simple"), space(), TestFormat] + [token("a"), space(), token("simple"), space(), TestFormat] ] .unwrap(); assert_eq!( buffer.into_vec(), vec![ - FormatElement::StaticText { text: "a" }, + FormatElement::Token { text: "a" }, FormatElement::Space, - FormatElement::StaticText { text: "simple" }, + FormatElement::Token { text: "simple" }, FormatElement::Space, - FormatElement::StaticText { text: "test" } + FormatElement::Token { text: "test" } ] ); } @@ -394,41 +394,41 @@ mod tests { let formatted_best_fitting = format!( SimpleFormatContext::default(), [ - text("aVeryLongIdentifier"), + token("aVeryLongIdentifier"), soft_line_break_or_space(), best_fitting![ - format_args![text( + format_args![token( "Something that will not fit on a line with 30 character print width." )], format_args![group(&format_args![ - text("Start"), + token("Start"), soft_line_break(), group(&soft_block_indent(&format_args![ - text("1,"), + token("1,"), soft_line_break_or_space(), - text("2,"), + token("2,"), soft_line_break_or_space(), - text("3"), + token("3"), ])), soft_line_break_or_space(), soft_block_indent(&format_args![ - text("1,"), + token("1,"), soft_line_break_or_space(), - text("2,"), + token("2,"), soft_line_break_or_space(), group(&format_args!( - text("A,"), + token("A,"), soft_line_break_or_space(), - text("B") + token("B") )), soft_line_break_or_space(), - text("3") + token("3") ]), soft_line_break_or_space(), - text("End") + token("End") ]) .should_expand(true)], - format_args!(text("Most"), hard_line_break(), text("Expanded")) + format_args!(token("Most"), hard_line_break(), token("Expanded")) ] ] ) @@ -439,34 +439,34 @@ mod tests { let formatted_normal_list = format!( SimpleFormatContext::default(), [ - text("aVeryLongIdentifier"), + token("aVeryLongIdentifier"), soft_line_break_or_space(), format_args![ - text("Start"), + token("Start"), soft_line_break(), &group(&soft_block_indent(&format_args![ - text("1,"), + token("1,"), soft_line_break_or_space(), - text("2,"), + token("2,"), soft_line_break_or_space(), - text("3"), + token("3"), ])), soft_line_break_or_space(), &soft_block_indent(&format_args![ - text("1,"), + token("1,"), soft_line_break_or_space(), - text("2,"), + token("2,"), soft_line_break_or_space(), group(&format_args!( - text("A,"), + token("A,"), soft_line_break_or_space(), - text("B") + token("B") )), soft_line_break_or_space(), - text("3") + token("3") ]), soft_line_break_or_space(), - text("End") + token("End") ], ] ) diff --git a/crates/ruff_formatter/src/printer/mod.rs b/crates/ruff_formatter/src/printer/mod.rs index f1cbe097c3..3d8d58be62 100644 --- a/crates/ruff_formatter/src/printer/mod.rs +++ b/crates/ruff_formatter/src/printer/mod.rs @@ -9,8 +9,8 @@ use ruff_text_size::{Ranged, TextLen, TextSize}; use crate::format_element::document::Document; use crate::format_element::tag::{Condition, GroupMode}; use crate::format_element::{BestFittingMode, BestFittingVariants, LineMode, PrintMode}; -use crate::prelude::tag; use crate::prelude::tag::{DedentMode, Tag, TagKind, VerbatimKind}; +use crate::prelude::{tag, TextWidth}; use crate::printer::call_stack::{ CallStack, FitsCallStack, PrintCallStack, PrintElementArgs, StackFrame, }; @@ -54,32 +54,31 @@ impl<'a> Printer<'a> { /// Prints the passed in element as well as all its content, /// starting at the specified indentation level + #[tracing::instrument(name = "Printer::print", skip_all)] pub fn print_with_indent( mut self, document: &'a Document, indent: u16, ) -> PrintResult { - tracing::debug_span!("Printer::print").in_scope(move || { - let mut stack = PrintCallStack::new(PrintElementArgs::new(Indention::Level(indent))); - let mut queue: PrintQueue<'a> = PrintQueue::new(document.as_ref()); + let mut stack = PrintCallStack::new(PrintElementArgs::new(Indention::Level(indent))); + let mut queue: PrintQueue<'a> = PrintQueue::new(document.as_ref()); - loop { - if let Some(element) = queue.pop() { - self.print_element(&mut stack, &mut queue, element)?; - } else { - if !self.flush_line_suffixes(&mut queue, &mut stack, None) { - break; - } + loop { + if let Some(element) = queue.pop() { + self.print_element(&mut stack, &mut queue, element)?; + } else { + if !self.flush_line_suffixes(&mut queue, &mut stack, None) { + break; } } + } - Ok(Printed::new( - self.state.buffer, - None, - self.state.source_markers, - self.state.verbatim_markers, - )) - }) + Ok(Printed::new( + self.state.buffer, + None, + self.state.source_markers, + self.state.verbatim_markers, + )) } /// Prints a single element and push the following elements to queue @@ -95,31 +94,43 @@ impl<'a> Printer<'a> { let args = stack.top(); match element { - FormatElement::Space => self.print_text(" ", None), - FormatElement::StaticText { text } => self.print_text(text, None), - FormatElement::DynamicText { text } => self.print_text(text, None), - FormatElement::SourceCodeSlice { slice, .. } => { + FormatElement::Space => self.print_text(Text::Token(" "), None), + FormatElement::Token { text } => self.print_text(Text::Token(text), None), + FormatElement::Text { text, text_width } => self.print_text( + Text::Text { + text, + text_width: *text_width, + }, + None, + ), + FormatElement::SourceCodeSlice { slice, text_width } => { let text = slice.text(self.source_code); - self.print_text(text, Some(slice.range())); + self.print_text( + Text::Text { + text, + text_width: *text_width, + }, + Some(slice.range()), + ); } FormatElement::Line(line_mode) => { if args.mode().is_flat() && matches!(line_mode, LineMode::Soft | LineMode::SoftOrSpace) { if line_mode == &LineMode::SoftOrSpace { - self.print_text(" ", None); + self.print_text(Text::Token(" "), None); } } else if self.state.line_suffixes.has_pending() { self.flush_line_suffixes(queue, stack, Some(element)); } else { // Only print a newline if the current line isn't already empty if self.state.line_width > 0 { - self.print_str("\n"); + self.print_char('\n'); } // Print a second line break if this is an empty line if line_mode == &LineMode::Empty { - self.print_str("\n"); + self.print_char('\n'); } self.state.pending_indent = args.indention(); @@ -352,11 +363,11 @@ impl<'a> Printer<'a> { Ok(print_mode) } - fn print_text(&mut self, text: &str, source_range: Option) { + fn print_text(&mut self, text: Text, source_range: Option) { if !self.state.pending_indent.is_empty() { let (indent_char, repeat_count) = match self.options.indent_style() { IndentStyle::Tab => ('\t', 1), - IndentStyle::Space(count) => (' ', count), + IndentStyle::Space => (' ', self.options.indent_width()), }; let indent = std::mem::take(&mut self.state.pending_indent); @@ -390,7 +401,26 @@ impl<'a> Printer<'a> { self.push_marker(); - self.print_str(text); + match text { + #[allow(clippy::cast_possible_truncation)] + Text::Token(token) => { + self.state.buffer.push_str(token); + self.state.line_width += token.len() as u32; + } + Text::Text { + text, + text_width: width, + } => { + if let Some(width) = width.width() { + self.state.buffer.push_str(text); + self.state.line_width += width.value(); + } else { + for char in text.chars() { + self.print_char(char); + } + } + } + } if let Some(range) = source_range { self.state.source_position = range.end(); @@ -718,12 +748,6 @@ impl<'a> Printer<'a> { invalid_end_tag(TagKind::Entry, stack.top_kind()) } - fn print_str(&mut self, content: &str) { - for char in content.chars() { - self.print_char(char); - } - } - fn print_char(&mut self, char: char) { if char == '\n' { self.state @@ -740,7 +764,7 @@ impl<'a> Printer<'a> { #[allow(clippy::cast_possible_truncation)] let char_width = if char == '\t' { - self.options.tab_width.value() + self.options.indent_width.value() } else { // SAFETY: A u32 is sufficient to represent the width of a file <= 4GB char.width().unwrap_or(0) as u32 @@ -1047,12 +1071,12 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> { let args = self.stack.top(); match element { - FormatElement::Space => return Ok(self.fits_text(" ", args)), + FormatElement::Space => return Ok(self.fits_text(Text::Token(" "), args)), FormatElement::Line(line_mode) => { match args.mode() { PrintMode::Flat => match line_mode { - LineMode::SoftOrSpace => return Ok(self.fits_text(" ", args)), + LineMode::SoftOrSpace => return Ok(self.fits_text(Text::Token(" "), args)), LineMode::Soft => {} LineMode::Hard | LineMode::Empty => { return Ok(if self.must_be_flat { @@ -1081,11 +1105,25 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> { } } - FormatElement::StaticText { text } => return Ok(self.fits_text(text, args)), - FormatElement::DynamicText { text, .. } => return Ok(self.fits_text(text, args)), - FormatElement::SourceCodeSlice { slice, .. } => { + FormatElement::Token { text } => return Ok(self.fits_text(Text::Token(text), args)), + FormatElement::Text { text, text_width } => { + return Ok(self.fits_text( + Text::Text { + text, + text_width: *text_width, + }, + args, + )) + } + FormatElement::SourceCodeSlice { slice, text_width } => { let text = slice.text(self.printer.source_code); - return Ok(self.fits_text(text, args)); + return Ok(self.fits_text( + Text::Text { + text, + text_width: *text_width, + }, + args, + )); } FormatElement::LineSuffixBoundary => { if self.state.has_line_suffix { @@ -1293,31 +1331,43 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> { Fits::Maybe } - fn fits_text(&mut self, text: &str, args: PrintElementArgs) -> Fits { + fn fits_text(&mut self, text: Text, args: PrintElementArgs) -> Fits { let indent = std::mem::take(&mut self.state.pending_indent); self.state.line_width += u32::from(indent.level()) * self.options().indent_width() + u32::from(indent.align()); - for c in text.chars() { - let char_width = match c { - '\t' => self.options().tab_width.value(), - '\n' => { - if self.must_be_flat { - return Fits::No; - } - match args.measure_mode() { - MeasureMode::FirstLine => return Fits::Yes, - MeasureMode::AllLines => { - self.state.line_width = 0; - continue; - } + match text { + #[allow(clippy::cast_possible_truncation)] + Text::Token(token) => { + self.state.line_width += token.len() as u32; + } + Text::Text { text, text_width } => { + if let Some(width) = text_width.width() { + self.state.line_width += width.value(); + } else { + for c in text.chars() { + let char_width = match c { + '\t' => self.options().indent_width.value(), + '\n' => { + if self.must_be_flat { + return Fits::No; + } + match args.measure_mode() { + MeasureMode::FirstLine => return Fits::Yes, + MeasureMode::AllLines => { + self.state.line_width = 0; + continue; + } + } + } + // SAFETY: A u32 is sufficient to format files <= 4GB + #[allow(clippy::cast_possible_truncation)] + c => c.width().unwrap_or(0) as u32, + }; + self.state.line_width += char_width; } } - // SAFETY: A u32 is sufficient to format files <= 4GB - #[allow(clippy::cast_possible_truncation)] - c => c.width().unwrap_or(0) as u32, - }; - self.state.line_width += char_width; + } } if self.state.line_width > self.options().line_width.into() { @@ -1434,13 +1484,24 @@ impl From for MeasureMode { } } +#[derive(Copy, Clone, Debug)] +enum Text<'a> { + /// ASCII only text that contains no line breaks or tab characters. + Token(&'a str), + /// Arbitrary text. May contain `\n` line breaks, tab characters, or unicode characters. + Text { + text: &'a str, + text_width: TextWidth, + }, +} + #[cfg(test)] mod tests { use crate::prelude::*; use crate::printer::{LineEnding, Printer, PrinterOptions}; use crate::source_code::SourceCode; use crate::{ - format_args, write, Document, FormatState, IndentStyle, LineWidth, Printed, TabWidth, + format_args, write, Document, FormatState, IndentStyle, IndentWidth, LineWidth, Printed, VecBuffer, }; @@ -1448,7 +1509,7 @@ mod tests { format_with_options( root, PrinterOptions { - indent_style: IndentStyle::Space(2), + indent_style: IndentStyle::Space, ..PrinterOptions::default() }, ) @@ -1469,10 +1530,10 @@ mod tests { fn it_prints_a_group_on_a_single_line_if_it_fits() { let result = format(&FormatArrayElements { items: vec![ - &text("\"a\""), - &text("\"b\""), - &text("\"c\""), - &text("\"d\""), + &token("\"a\""), + &token("\"b\""), + &token("\"c\""), + &token("\"d\""), ], }); @@ -1482,17 +1543,17 @@ mod tests { #[test] fn it_tracks_the_indent_for_each_token() { let formatted = format(&format_args!( - text("a"), + token("a"), soft_block_indent(&format_args!( - text("b"), + token("b"), soft_block_indent(&format_args!( - text("c"), - soft_block_indent(&format_args!(text("d"), soft_line_break(), text("d"),)), - text("c"), + token("c"), + soft_block_indent(&format_args!(token("d"), soft_line_break(), token("d"),)), + token("c"), )), - text("b"), + token("b"), )), - text("a") + token("a") )); assert_eq!( @@ -1517,9 +1578,9 @@ a"#, let result = format_with_options( &format_args![ - text("function main() {"), - block_indent(&text("let x = `This is a multiline\nstring`;")), - text("}"), + token("function main() {"), + block_indent(&text("let x = `This is a multiline\nstring`;", None)), + token("}"), hard_line_break() ], options, @@ -1535,8 +1596,8 @@ a"#, fn it_breaks_a_group_if_a_string_contains_a_newline() { let result = format(&FormatArrayElements { items: vec![ - &text("`This is a string spanning\ntwo lines`"), - &text("\"b\""), + &text("`This is a string spanning\ntwo lines`", None), + &token("\"b\""), ], }); @@ -1551,7 +1612,7 @@ two lines`, } #[test] fn it_breaks_a_group_if_it_contains_a_hard_line_break() { - let result = format(&group(&format_args![text("a"), block_indent(&text("b"))])); + let result = format(&group(&format_args![token("a"), block_indent(&token("b"))])); assert_eq!("a\n b\n", result.as_code()); } @@ -1560,17 +1621,17 @@ two lines`, fn it_breaks_parent_groups_if_they_dont_fit_on_a_single_line() { let result = format(&FormatArrayElements { items: vec![ - &text("\"a\""), - &text("\"b\""), - &text("\"c\""), - &text("\"d\""), + &token("\"a\""), + &token("\"b\""), + &token("\"c\""), + &token("\"d\""), &FormatArrayElements { items: vec![ - &text("\"0123456789\""), - &text("\"0123456789\""), - &text("\"0123456789\""), - &text("\"0123456789\""), - &text("\"0123456789\""), + &token("\"0123456789\""), + &token("\"0123456789\""), + &token("\"0123456789\""), + &token("\"0123456789\""), + &token("\"0123456789\""), ], }, ], @@ -1592,14 +1653,14 @@ two lines`, fn it_use_the_indent_character_specified_in_the_options() { let options = PrinterOptions { indent_style: IndentStyle::Tab, - tab_width: TabWidth::try_from(4).unwrap(), + indent_width: IndentWidth::try_from(4).unwrap(), line_width: LineWidth::try_from(19).unwrap(), ..PrinterOptions::default() }; let result = format_with_options( &FormatArrayElements { - items: vec![&text("'a'"), &text("'b'"), &text("'c'"), &text("'d'")], + items: vec![&token("'a'"), &token("'b'"), &token("'c'"), &token("'d'")], }, options, ); @@ -1610,11 +1671,11 @@ two lines`, #[test] fn it_prints_consecutive_hard_lines_as_one() { let result = format(&format_args![ - text("a"), + token("a"), hard_line_break(), hard_line_break(), hard_line_break(), - text("b"), + token("b"), ]); assert_eq!("a\nb", result.as_code()); @@ -1623,11 +1684,11 @@ two lines`, #[test] fn it_prints_consecutive_empty_lines_as_many() { let result = format(&format_args![ - text("a"), + token("a"), empty_line(), empty_line(), empty_line(), - text("b"), + token("b"), ]); assert_eq!("a\n\n\n\nb", result.as_code()); @@ -1636,12 +1697,12 @@ two lines`, #[test] fn it_prints_consecutive_mixed_lines_as_many() { let result = format(&format_args![ - text("a"), + token("a"), empty_line(), hard_line_break(), empty_line(), hard_line_break(), - text("b"), + token("b"), ]); assert_eq!("a\n\n\nb", result.as_code()); @@ -1649,7 +1710,7 @@ two lines`, #[test] fn test_fill_breaks() { - let mut state = FormatState::new(()); + let mut state = FormatState::new(SimpleFormatContext::default()); let mut buffer = VecBuffer::new(&mut state); let mut formatter = Formatter::new(&mut buffer); @@ -1658,37 +1719,37 @@ two lines`, // These all fit on the same line together .entry( &soft_line_break_or_space(), - &format_args!(text("1"), text(",")), + &format_args!(token("1"), token(",")), ) .entry( &soft_line_break_or_space(), - &format_args!(text("2"), text(",")), + &format_args!(token("2"), token(",")), ) .entry( &soft_line_break_or_space(), - &format_args!(text("3"), text(",")), + &format_args!(token("3"), token(",")), ) // This one fits on a line by itself, .entry( &soft_line_break_or_space(), - &format_args!(text("723493294"), text(",")), + &format_args!(token("723493294"), token(",")), ) // fits without breaking .entry( &soft_line_break_or_space(), &group(&format_args!( - text("["), - soft_block_indent(&text("5")), - text("],") + token("["), + soft_block_indent(&token("5")), + token("],") )), ) // this one must be printed in expanded mode to fit .entry( &soft_line_break_or_space(), &group(&format_args!( - text("["), - soft_block_indent(&text("123456789")), - text("]"), + token("["), + soft_block_indent(&token("123456789")), + token("]"), )), ) .finish() @@ -1713,27 +1774,27 @@ two lines`, fn line_suffix_printed_at_end() { let printed = format(&format_args![ group(&format_args![ - text("["), + token("["), soft_block_indent(&format_with(|f| { f.fill() .entry( &soft_line_break_or_space(), - &format_args!(text("1"), text(",")), + &format_args!(token("1"), token(",")), ) .entry( &soft_line_break_or_space(), - &format_args!(text("2"), text(",")), + &format_args!(token("2"), token(",")), ) .entry( &soft_line_break_or_space(), - &format_args!(text("3"), if_group_breaks(&text(","))), + &format_args!(token("3"), if_group_breaks(&token(","))), ) .finish() })), - text("]") + token("]") ]), - text(";"), - line_suffix(&format_args![space(), text("// trailing")], 0) + token(";"), + line_suffix(&format_args![space(), token("// trailing")], 0) ]); assert_eq!(printed.as_code(), "[1, 2, 3]; // trailing"); @@ -1743,27 +1804,27 @@ two lines`, fn line_suffix_with_reserved_width() { let printed = format(&format_args![ group(&format_args![ - text("["), + token("["), soft_block_indent(&format_with(|f| { f.fill() .entry( &soft_line_break_or_space(), - &format_args!(text("1"), text(",")), + &format_args!(token("1"), token(",")), ) .entry( &soft_line_break_or_space(), - &format_args!(text("2"), text(",")), + &format_args!(token("2"), token(",")), ) .entry( &soft_line_break_or_space(), - &format_args!(text("3"), if_group_breaks(&text(","))), + &format_args!(token("3"), if_group_breaks(&token(","))), ) .finish() })), - text("]") + token("]") ]), - text(";"), - line_suffix(&format_args![space(), text("// Using reserved width causes this content to not fit even though it's a line suffix element")], 93) + token(";"), + line_suffix(&format_args![space(), token("// Using reserved width causes this content to not fit even though it's a line suffix element")], 93) ]); assert_eq!(printed.as_code(), "[\n 1, 2, 3\n]; // Using reserved width causes this content to not fit even though it's a line suffix element"); @@ -1777,15 +1838,15 @@ two lines`, f, [ group(&format_args![ - text("The referenced group breaks."), + token("The referenced group breaks."), hard_line_break() ]) .with_group_id(Some(group_id)), group(&format_args![ - text("This group breaks because:"), + token("This group breaks because:"), soft_line_break_or_space(), - if_group_fits_on_line(&text("This content fits but should not be printed.")).with_group_id(Some(group_id)), - if_group_breaks(&text("It measures with the 'if_group_breaks' variant because the referenced group breaks and that's just way too much text.")).with_group_id(Some(group_id)), + if_group_fits_on_line(&token("This content fits but should not be printed.")).with_group_id(Some(group_id)), + if_group_breaks(&token("It measures with the 'if_group_breaks' variant because the referenced group breaks and that's just way too much text.")).with_group_id(Some(group_id)), ]) ] ) @@ -1805,7 +1866,7 @@ two lines`, write!( f, [ - group(&text("Group with id-2")).with_group_id(Some(id_2)), + group(&token("Group with id-2")).with_group_id(Some(id_2)), hard_line_break() ] )?; @@ -1813,7 +1874,7 @@ two lines`, write!( f, [ - group(&text("Group with id-1 does not fit on the line because it exceeds the line width of 80 characters by")).with_group_id(Some(id_1)), + group(&token("Group with id-1 does not fit on the line because it exceeds the line width of 80 characters by")).with_group_id(Some(id_1)), hard_line_break() ] )?; @@ -1821,9 +1882,9 @@ two lines`, write!( f, [ - if_group_fits_on_line(&text("Group 2 fits")).with_group_id(Some(id_2)), + if_group_fits_on_line(&token("Group 2 fits")).with_group_id(Some(id_2)), hard_line_break(), - if_group_breaks(&text("Group 1 breaks")).with_group_id(Some(id_1)) + if_group_breaks(&token("Group 1 breaks")).with_group_id(Some(id_1)) ] ) }); @@ -1848,15 +1909,15 @@ Group 1 breaks"# write!( f, [group(&format_args!( - text("["), + token("["), soft_block_indent(&format_args!( format_with(|f| f - .join_with(format_args!(text(","), soft_line_break_or_space())) + .join_with(format_args!(token(","), soft_line_break_or_space())) .entries(&self.items) .finish()), - if_group_breaks(&text(",")), + if_group_breaks(&token(",")), )), - text("]") + token("]") ))] ) } diff --git a/crates/ruff_formatter/src/printer/printer_options/mod.rs b/crates/ruff_formatter/src/printer/printer_options/mod.rs index f4d058d34f..c73ca1c62d 100644 --- a/crates/ruff_formatter/src/printer/printer_options/mod.rs +++ b/crates/ruff_formatter/src/printer/printer_options/mod.rs @@ -1,10 +1,13 @@ -use crate::{FormatOptions, IndentStyle, LineWidth, TabWidth}; +use crate::{FormatOptions, IndentStyle, IndentWidth, LineWidth}; /// Options that affect how the [`crate::Printer`] prints the format tokens #[derive(Clone, Debug, Eq, PartialEq, Default)] pub struct PrinterOptions { /// Width of a single tab character (does it equal 2, 4, ... spaces?) - pub tab_width: TabWidth, + pub indent_width: IndentWidth, + + /// Whether the printer should use tabs or spaces to indent code. + pub indent_style: IndentStyle, /// What's the max width of a line. Defaults to 80 pub line_width: LineWidth, @@ -12,9 +15,6 @@ pub struct PrinterOptions { /// The type of line ending to apply to the printed input pub line_ending: LineEnding, - /// Whether the printer should use tabs or spaces to indent code and if spaces, by how many. - pub indent_style: IndentStyle, - /// Whether the printer should build a source map that allows mapping positions in the source document /// to positions in the formatted document. pub source_map_generation: SourceMapGeneration, @@ -46,8 +46,8 @@ impl PrinterOptions { } #[must_use] - pub fn with_tab_width(mut self, width: TabWidth) -> Self { - self.tab_width = width; + pub fn with_tab_width(mut self, width: IndentWidth) -> Self { + self.indent_width = width; self } @@ -58,10 +58,7 @@ impl PrinterOptions { /// Width of an indent in characters. pub(super) const fn indent_width(&self) -> u32 { - match self.indent_style { - IndentStyle::Tab => self.tab_width.value(), - IndentStyle::Space(count) => count as u32, - } + self.indent_width.value() } } @@ -124,7 +121,8 @@ impl SourceMapGeneration { } #[allow(dead_code)] -#[derive(Clone, Debug, Eq, PartialEq, Default)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum LineEnding { /// Line Feed only (\n), common on Linux and macOS as well as inside git repos #[default] diff --git a/crates/ruff_macros/src/map_codes.rs b/crates/ruff_macros/src/map_codes.rs index eeee0d7ac9..8575ebc133 100644 --- a/crates/ruff_macros/src/map_codes.rs +++ b/crates/ruff_macros/src/map_codes.rs @@ -8,7 +8,7 @@ use syn::{ Ident, ItemFn, LitStr, Pat, Path, Stmt, Token, }; -use crate::rule_code_prefix::{get_prefix_ident, if_all_same, is_nursery}; +use crate::rule_code_prefix::{get_prefix_ident, if_all_same}; /// A rule entry in the big match statement such a /// `(Pycodestyle, "E112") => (RuleGroup::Nursery, rules::pycodestyle::rules::logical_lines::NoIndentedBlock),` @@ -113,9 +113,23 @@ pub(crate) fn map_codes(func: &ItemFn) -> syn::Result { Self::#linter(linter) } } + + // Rust doesn't yet support `impl const From for RuleSelector` + // See https://github.com/rust-lang/rust/issues/67792 impl From<#linter> for crate::rule_selector::RuleSelector { fn from(linter: #linter) -> Self { - Self::Prefix{prefix: RuleCodePrefix::#linter(linter), redirected_from: None} + let prefix = RuleCodePrefix::#linter(linter); + if is_single_rule_selector(&prefix) { + Self::Rule { + prefix, + redirected_from: None, + } + } else { + Self::Prefix { + prefix, + redirected_from: None, + } + } } } }); @@ -156,7 +170,7 @@ pub(crate) fn map_codes(func: &ItemFn) -> syn::Result { output.extend(quote! { impl #linter { - pub fn rules(self) -> ::std::vec::IntoIter { + pub fn rules(&self) -> ::std::vec::IntoIter { match self { #prefix_into_iter_match_arms } } } @@ -172,7 +186,7 @@ pub(crate) fn map_codes(func: &ItemFn) -> syn::Result { }) } - pub fn rules(self) -> ::std::vec::IntoIter { + pub fn rules(&self) -> ::std::vec::IntoIter { match self { #(RuleCodePrefix::#linter_idents(prefix) => prefix.clone().rules(),)* } @@ -195,26 +209,12 @@ fn rules_by_prefix( // TODO(charlie): Why do we do this here _and_ in `rule_code_prefix::expand`? let mut rules_by_prefix = BTreeMap::new(); - for (code, rule) in rules { - // Nursery rules have to be explicitly selected, so we ignore them when looking at - // prefix-level selectors (e.g., `--select SIM10`), but add the rule itself under - // its fully-qualified code (e.g., `--select SIM101`). - if is_nursery(&rule.group) { - rules_by_prefix.insert(code.clone(), vec![(rule.path.clone(), rule.attrs.clone())]); - continue; - } - + for code in rules.keys() { for i in 1..=code.len() { let prefix = code[..i].to_string(); let rules: Vec<_> = rules .iter() .filter_map(|(code, rule)| { - // Nursery rules have to be explicitly selected, so we ignore them when - // looking at prefixes. - if is_nursery(&rule.group) { - return None; - } - if code.starts_with(&prefix) { Some((rule.path.clone(), rule.attrs.clone())) } else { @@ -311,6 +311,11 @@ See also https://github.com/astral-sh/ruff/issues/2186. } } + pub fn is_preview(&self) -> bool { + matches!(self.group(), RuleGroup::Preview) + } + + #[allow(deprecated)] pub fn is_nursery(&self) -> bool { matches!(self.group(), RuleGroup::Nursery) } @@ -336,12 +341,10 @@ fn generate_iter_impl( let mut linter_rules_match_arms = quote!(); let mut linter_all_rules_match_arms = quote!(); for (linter, map) in linter_to_rules { - let rule_paths = map.values().filter(|rule| !is_nursery(&rule.group)).map( - |Rule { attrs, path, .. }| { - let rule_name = path.segments.last().unwrap(); - quote!(#(#attrs)* Rule::#rule_name) - }, - ); + let rule_paths = map.values().map(|Rule { attrs, path, .. }| { + let rule_name = path.segments.last().unwrap(); + quote!(#(#attrs)* Rule::#rule_name) + }); linter_rules_match_arms.extend(quote! { Linter::#linter => vec![#(#rule_paths,)*].into_iter(), }); diff --git a/crates/ruff_macros/src/rule_code_prefix.rs b/crates/ruff_macros/src/rule_code_prefix.rs index 29379b2cb3..89c7543c5b 100644 --- a/crates/ruff_macros/src/rule_code_prefix.rs +++ b/crates/ruff_macros/src/rule_code_prefix.rs @@ -12,22 +12,14 @@ pub(crate) fn expand<'a>( let mut prefix_to_codes: BTreeMap> = BTreeMap::default(); let mut code_to_attributes: BTreeMap = BTreeMap::default(); - for (variant, group, attr) in variants { + for (variant, .., attr) in variants { let code_str = variant.to_string(); - // Nursery rules have to be explicitly selected, so we ignore them when looking at prefixes. - if is_nursery(group) { + for i in 1..=code_str.len() { + let prefix = code_str[..i].to_string(); prefix_to_codes - .entry(code_str.clone()) + .entry(prefix) .or_default() .insert(code_str.clone()); - } else { - for i in 1..=code_str.len() { - let prefix = code_str[..i].to_string(); - prefix_to_codes - .entry(prefix) - .or_default() - .insert(code_str.clone()); - } } code_to_attributes.insert(code_str, attr); @@ -125,14 +117,3 @@ pub(crate) fn get_prefix_ident(prefix: &str) -> Ident { }; Ident::new(&prefix, Span::call_site()) } - -/// Returns true if the given group is the "nursery" group. -pub(crate) fn is_nursery(group: &Path) -> bool { - let group = group - .segments - .iter() - .map(|segment| segment.ident.to_string()) - .collect::>() - .join("::"); - group == "RuleGroup::Nursery" -} diff --git a/crates/ruff_notebook/Cargo.toml b/crates/ruff_notebook/Cargo.toml new file mode 100644 index 0000000000..7b3dfde8f6 --- /dev/null +++ b/crates/ruff_notebook/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "ruff_notebook" +version = "0.0.0" +publish = false +authors = { workspace = true } +edition = { workspace = true } +rust-version = { workspace = true } +homepage = { workspace = true } +documentation = { workspace = true } +repository = { workspace = true } +license = { workspace = true } + +[lib] + +[dependencies] +ruff_diagnostics = { path = "../ruff_diagnostics" } +ruff_source_file = { path = "../ruff_source_file" } +ruff_text_size = { path = "../ruff_text_size" } + +anyhow = { workspace = true } +itertools = { workspace = true } +once_cell = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_with = { version = "3.0.0", default-features = false, features = ["macros"] } +thiserror = { workspace = true } +uuid = { workspace = true } + +[dev-dependencies] +insta = { workspace = true } +test-case = { workspace = true } diff --git a/crates/ruff/resources/test/fixtures/jupyter/R.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/R.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/R.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/R.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/add_missing_cell_id.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/add_missing_cell_id.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/add_missing_cell_id.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/add_missing_cell_id.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/after_fix.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/after_fix.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/after_fix.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/after_fix.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/before_fix.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/before_fix.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/before_fix.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/before_fix.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/cell/cell_magic.json b/crates/ruff_notebook/resources/test/fixtures/jupyter/cell/cell_magic.json similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/cell/cell_magic.json rename to crates/ruff_notebook/resources/test/fixtures/jupyter/cell/cell_magic.json diff --git a/crates/ruff/resources/test/fixtures/jupyter/cell/code_and_magic.json b/crates/ruff_notebook/resources/test/fixtures/jupyter/cell/code_and_magic.json similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/cell/code_and_magic.json rename to crates/ruff_notebook/resources/test/fixtures/jupyter/cell/code_and_magic.json diff --git a/crates/ruff/resources/test/fixtures/jupyter/cell/markdown.json b/crates/ruff_notebook/resources/test/fixtures/jupyter/cell/markdown.json similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/cell/markdown.json rename to crates/ruff_notebook/resources/test/fixtures/jupyter/cell/markdown.json diff --git a/crates/ruff/resources/test/fixtures/jupyter/cell/only_code.json b/crates/ruff_notebook/resources/test/fixtures/jupyter/cell/only_code.json similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/cell/only_code.json rename to crates/ruff_notebook/resources/test/fixtures/jupyter/cell/only_code.json diff --git a/crates/ruff/resources/test/fixtures/jupyter/cell/only_magic.json b/crates/ruff_notebook/resources/test/fixtures/jupyter/cell/only_magic.json similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/cell/only_magic.json rename to crates/ruff_notebook/resources/test/fixtures/jupyter/cell/only_magic.json diff --git a/crates/ruff/resources/test/fixtures/jupyter/invalid_extension.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/invalid_extension.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/invalid_extension.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/invalid_extension.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/ipy_escape_command.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/ipy_escape_command.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command_expected.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/ipy_escape_command_expected.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/ipy_escape_command_expected.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/ipy_escape_command_expected.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/isort.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/isort.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/isort.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/isort.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/isort_expected.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/isort_expected.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/isort_expected.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/isort_expected.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/no_cell_id.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/no_cell_id.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/no_cell_id.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/no_cell_id.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/no_trailing_newline.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/no_trailing_newline.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/no_trailing_newline.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/no_trailing_newline.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/not_json.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/not_json.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/not_json.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/not_json.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/unused_variable.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/unused_variable.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/unused_variable.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/unused_variable.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/unused_variable_expected.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/unused_variable_expected.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/unused_variable_expected.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/unused_variable_expected.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/valid.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/valid.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/valid.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/valid.ipynb diff --git a/crates/ruff/resources/test/fixtures/jupyter/wrong_schema.ipynb b/crates/ruff_notebook/resources/test/fixtures/jupyter/wrong_schema.ipynb similarity index 100% rename from crates/ruff/resources/test/fixtures/jupyter/wrong_schema.ipynb rename to crates/ruff_notebook/resources/test/fixtures/jupyter/wrong_schema.ipynb diff --git a/crates/ruff/src/jupyter/index.rs b/crates/ruff_notebook/src/index.rs similarity index 89% rename from crates/ruff/src/jupyter/index.rs rename to crates/ruff_notebook/src/index.rs index f5150d01f7..23259468ee 100644 --- a/crates/ruff/src/jupyter/index.rs +++ b/crates/ruff_notebook/src/index.rs @@ -1,8 +1,10 @@ +use serde::{Deserialize, Serialize}; + /// Jupyter Notebook indexing table /// /// When we lint a jupyter notebook, we have to translate the row/column based on /// [`ruff_text_size::TextSize`] to jupyter notebook cell/row/column. -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct NotebookIndex { /// Enter a row (1-based), get back the cell (1-based) pub(super) row_to_cell: Vec, diff --git a/crates/ruff/src/jupyter/mod.rs b/crates/ruff_notebook/src/lib.rs similarity index 100% rename from crates/ruff/src/jupyter/mod.rs rename to crates/ruff_notebook/src/lib.rs diff --git a/crates/ruff/src/jupyter/notebook.rs b/crates/ruff_notebook/src/notebook.rs similarity index 57% rename from crates/ruff/src/jupyter/notebook.rs rename to crates/ruff_notebook/src/notebook.rs index f36ce19171..66b91199a4 100644 --- a/crates/ruff/src/jupyter/notebook.rs +++ b/crates/ruff_notebook/src/notebook.rs @@ -1,29 +1,23 @@ use std::cmp::Ordering; use std::fmt::Display; use std::fs::File; -use std::io::{BufReader, BufWriter, Cursor, Read, Seek, SeekFrom, Write}; -use std::iter; +use std::io::{BufReader, Cursor, Read, Seek, SeekFrom, Write}; use std::path::Path; +use std::{io, iter}; use itertools::Itertools; use once_cell::sync::OnceCell; use serde::Serialize; use serde_json::error::Category; +use thiserror::Error; use uuid::Uuid; -use ruff_diagnostics::Diagnostic; -use ruff_python_parser::lexer::lex; -use ruff_python_parser::Mode; +use ruff_diagnostics::{SourceMap, SourceMarker}; use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlineIterator}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::TextSize; -use crate::autofix::source_map::{SourceMap, SourceMarker}; -use crate::jupyter::index::NotebookIndex; -use crate::jupyter::schema::{Cell, RawNotebook, SortAlphabetically, SourceValue}; -use crate::rules::pycodestyle::rules::SyntaxError; -use crate::IOError; - -pub const JUPYTER_NOTEBOOK_EXT: &str = "ipynb"; +use crate::index::NotebookIndex; +use crate::schema::{Cell, RawNotebook, SortAlphabetically, SourceValue}; /// Run round-trip source code generation on a given Jupyter notebook file path. pub fn round_trip(path: &Path) -> anyhow::Result { @@ -37,7 +31,7 @@ pub fn round_trip(path: &Path) -> anyhow::Result { let code = notebook.source_code().to_string(); notebook.update_cell_content(&code); let mut writer = Vec::new(); - notebook.write_inner(&mut writer)?; + notebook.write(&mut writer)?; Ok(String::from_utf8(writer)?) } @@ -96,6 +90,21 @@ impl Cell { } } +/// An error that can occur while deserializing a Jupyter Notebook. +#[derive(Error, Debug)] +pub enum NotebookError { + #[error(transparent)] + Io(#[from] io::Error), + #[error(transparent)] + Json(serde_json::Error), + #[error("Expected a Jupyter Notebook, which must be internally stored as JSON, but this file isn't valid JSON: {0}")] + InvalidJson(serde_json::Error), + #[error("This file does not match the schema expected of Jupyter Notebooks: {0}")] + InvalidSchema(serde_json::Error), + #[error("Expected Jupyter Notebook format 4, found: {0}")] + InvalidFormat(i64), +} + #[derive(Clone, Debug, PartialEq)] pub struct Notebook { /// Python source code of the notebook. @@ -121,19 +130,12 @@ pub struct Notebook { impl Notebook { /// Read the Jupyter Notebook from the given [`Path`]. - pub fn from_path(path: &Path) -> Result> { - Self::from_reader(BufReader::new(File::open(path).map_err(|err| { - Diagnostic::new( - IOError { - message: format!("{err}"), - }, - TextRange::default(), - ) - })?)) + pub fn from_path(path: &Path) -> Result { + Self::from_reader(BufReader::new(File::open(path)?)) } /// Read the Jupyter Notebook from its JSON string. - pub fn from_source_code(source_code: &str) -> Result> { + pub fn from_source_code(source_code: &str) -> Result { Self::from_reader(Cursor::new(source_code)) } @@ -141,7 +143,7 @@ impl Notebook { /// /// See also the black implementation /// - fn from_reader(mut reader: R) -> Result> + fn from_reader(mut reader: R) -> Result where R: Read + Seek, { @@ -149,95 +151,27 @@ impl Notebook { let mut buf = [0; 1]; reader.read_exact(&mut buf).is_ok_and(|_| buf[0] == b'\n') }); - reader.rewind().map_err(|err| { - Diagnostic::new( - IOError { - message: format!("{err}"), - }, - TextRange::default(), - ) - })?; + reader.rewind()?; let mut raw_notebook: RawNotebook = match serde_json::from_reader(reader.by_ref()) { Ok(notebook) => notebook, Err(err) => { // Translate the error into a diagnostic - return Err(Box::new({ - match err.classify() { - Category::Io => Diagnostic::new( - IOError { - message: format!("{err}"), - }, - TextRange::default(), - ), - Category::Syntax | Category::Eof => { - // Maybe someone saved the python sources (those with the `# %%` separator) - // as jupyter notebook instead. Let's help them. - let mut contents = String::new(); - reader - .rewind() - .and_then(|_| reader.read_to_string(&mut contents)) - .map_err(|err| { - Diagnostic::new( - IOError { - message: format!("{err}"), - }, - TextRange::default(), - ) - })?; - - // Check if tokenizing was successful and the file is non-empty - if lex(&contents, Mode::Module).any(|result| result.is_err()) { - Diagnostic::new( - SyntaxError { - message: format!( - "A Jupyter Notebook (.{JUPYTER_NOTEBOOK_EXT}) must internally be JSON, \ - but this file isn't valid JSON: {err}" - ), - }, - TextRange::default(), - ) - } else { - Diagnostic::new( - SyntaxError { - message: format!( - "Expected a Jupyter Notebook (.{JUPYTER_NOTEBOOK_EXT}), \ - which must be internally stored as JSON, \ - but found a Python source file: {err}" - ), - }, - TextRange::default(), - ) - } - } - Category::Data => { - // We could try to read the schema version here but if this fails it's - // a bug anyway - Diagnostic::new( - SyntaxError { - message: format!( - "This file does not match the schema expected of Jupyter Notebooks: {err}" - ), - }, - TextRange::default(), - ) - } + return Err(match err.classify() { + Category::Io => NotebookError::Json(err), + Category::Syntax | Category::Eof => NotebookError::InvalidJson(err), + Category::Data => { + // We could try to read the schema version here but if this fails it's + // a bug anyway. + NotebookError::InvalidSchema(err) } - })); + }); } }; // v4 is what everybody uses if raw_notebook.nbformat != 4 { // bail because we should have already failed at the json schema stage - return Err(Box::new(Diagnostic::new( - SyntaxError { - message: format!( - "Expected Jupyter Notebook format 4, found {}", - raw_notebook.nbformat - ), - }, - TextRange::default(), - ))); + return Err(NotebookError::InvalidFormat(raw_notebook.nbformat)); } let valid_code_cells = raw_notebook @@ -304,13 +238,13 @@ impl Notebook { // The first offset is always going to be at 0, so skip it. for offset in self.cell_offsets.iter_mut().skip(1).rev() { let closest_marker = match last_marker { - Some(marker) if marker.source <= *offset => marker, + Some(marker) if marker.source() <= *offset => marker, _ => { let Some(marker) = source_map .markers() .iter() .rev() - .find(|m| m.source <= *offset) + .find(|marker| marker.source() <= *offset) else { // There are no markers above the current offset, so we can // stop here. @@ -321,9 +255,9 @@ impl Notebook { } }; - match closest_marker.source.cmp(&closest_marker.dest) { - Ordering::Less => *offset += closest_marker.dest - closest_marker.source, - Ordering::Greater => *offset -= closest_marker.source - closest_marker.dest, + match closest_marker.source().cmp(&closest_marker.dest()) { + Ordering::Less => *offset += closest_marker.dest() - closest_marker.source(), + Ordering::Greater => *offset -= closest_marker.source() - closest_marker.dest(), Ordering::Equal => (), } } @@ -431,18 +365,23 @@ impl Notebook { /// The index is built only once when required. This is only used to /// report diagnostics, so by that time all of the autofixes must have /// been applied if `--fix` was passed. - pub(crate) fn index(&self) -> &NotebookIndex { + pub fn index(&self) -> &NotebookIndex { self.index.get_or_init(|| self.build_index()) } /// Return the cell offsets for the concatenated source code corresponding /// the Jupyter notebook. - pub(crate) fn cell_offsets(&self) -> &[TextSize] { + pub fn cell_offsets(&self) -> &[TextSize] { &self.cell_offsets } + /// Return `true` if the notebook has a trailing newline, `false` otherwise. + pub fn trailing_newline(&self) -> bool { + self.trailing_newline + } + /// Update the notebook with the given sourcemap and transformed content. - pub(crate) fn update(&mut self, source_map: &SourceMap, transformed: String) { + pub fn update(&mut self, source_map: &SourceMap, transformed: String) { // Cell offsets must be updated before updating the cell content as // it depends on the offsets to extract the cell content. self.index.take(); @@ -465,7 +404,8 @@ impl Notebook { .map_or(true, |language| language.name == "python") } - fn write_inner(&self, writer: &mut impl Write) -> anyhow::Result<()> { + /// Write the notebook back to the given [`Write`] implementor. + pub fn write(&self, writer: &mut dyn Write) -> anyhow::Result<()> { // https://github.com/psf/black/blob/69ca0a4c7a365c5f5eea519a90980bab72cab764/src/black/__init__.py#LL1041 let formatter = serde_json::ser::PrettyFormatter::with_indent(b" "); let mut serializer = serde_json::Serializer::with_formatter(writer, formatter); @@ -475,13 +415,6 @@ impl Notebook { } Ok(()) } - - /// Write back with an indent of 1, just like black - pub fn write(&self, path: &Path) -> anyhow::Result<()> { - let mut writer = BufWriter::new(File::create(path)?); - self.write_inner(&mut writer)?; - Ok(()) - } } #[cfg(test)] @@ -491,58 +424,41 @@ mod tests { use anyhow::Result; use test_case::test_case; - use crate::jupyter::index::NotebookIndex; - use crate::jupyter::schema::Cell; - use crate::jupyter::Notebook; - use crate::registry::Rule; - use crate::source_kind::SourceKind; - use crate::test::{ - read_jupyter_notebook, test_contents, test_notebook_path, test_resource_path, - TestedNotebook, - }; - use crate::{assert_messages, settings}; + use crate::{Cell, Notebook, NotebookError, NotebookIndex}; - /// Read a Jupyter cell from the `resources/test/fixtures/jupyter/cell` directory. - fn read_jupyter_cell(path: impl AsRef) -> Result { - let path = test_resource_path("fixtures/jupyter/cell").join(path); - let source_code = std::fs::read_to_string(path)?; - Ok(serde_json::from_str(&source_code)?) + /// Construct a path to a Jupyter notebook in the `resources/test/fixtures/jupyter` directory. + fn notebook_path(path: impl AsRef) -> std::path::PathBuf { + Path::new("./resources/test/fixtures/jupyter").join(path) } #[test] - fn test_valid() { - assert!(read_jupyter_notebook(Path::new("valid.ipynb")).is_ok()); + fn test_python() -> Result<(), NotebookError> { + let notebook = Notebook::from_path(¬ebook_path("valid.ipynb"))?; + assert!(notebook.is_python_notebook()); + Ok(()) } #[test] - fn test_r() { - // We can load this, it will be filtered out later - assert!(read_jupyter_notebook(Path::new("R.ipynb")).is_ok()); + fn test_r() -> Result<(), NotebookError> { + let notebook = Notebook::from_path(¬ebook_path("R.ipynb"))?; + assert!(!notebook.is_python_notebook()); + Ok(()) } #[test] fn test_invalid() { - let path = Path::new("resources/test/fixtures/jupyter/invalid_extension.ipynb"); - assert_eq!( - Notebook::from_path(path).unwrap_err().kind.body, - "SyntaxError: Expected a Jupyter Notebook (.ipynb), \ - which must be internally stored as JSON, \ - but found a Python source file: \ - expected value at line 1 column 1" - ); - let path = Path::new("resources/test/fixtures/jupyter/not_json.ipynb"); - assert_eq!( - Notebook::from_path(path).unwrap_err().kind.body, - "SyntaxError: A Jupyter Notebook (.ipynb) must internally be JSON, \ - but this file isn't valid JSON: \ - expected value at line 1 column 1" - ); - let path = Path::new("resources/test/fixtures/jupyter/wrong_schema.ipynb"); - assert_eq!( - Notebook::from_path(path).unwrap_err().kind.body, - "SyntaxError: This file does not match the schema expected of Jupyter Notebooks: \ - missing field `cells` at line 1 column 2" - ); + assert!(matches!( + Notebook::from_path(¬ebook_path("invalid_extension.ipynb")), + Err(NotebookError::InvalidJson(_)) + )); + assert!(matches!( + Notebook::from_path(¬ebook_path("not_json.ipynb")), + Err(NotebookError::InvalidJson(_)) + )); + assert!(matches!( + Notebook::from_path(¬ebook_path("wrong_schema.ipynb")), + Err(NotebookError::InvalidSchema(_)) + )); } #[test_case(Path::new("markdown.json"), false; "markdown")] @@ -551,13 +467,20 @@ mod tests { #[test_case(Path::new("only_code.json"), true; "only_code")] #[test_case(Path::new("cell_magic.json"), false; "cell_magic")] fn test_is_valid_code_cell(path: &Path, expected: bool) -> Result<()> { + /// Read a Jupyter cell from the `resources/test/fixtures/jupyter/cell` directory. + fn read_jupyter_cell(path: impl AsRef) -> Result { + let path = notebook_path("cell").join(path); + let source_code = std::fs::read_to_string(path)?; + Ok(serde_json::from_str(&source_code)?) + } + assert_eq!(read_jupyter_cell(path)?.is_valid_code_cell(), expected); Ok(()) } #[test] - fn test_concat_notebook() -> Result<()> { - let notebook = read_jupyter_notebook(Path::new("valid.ipynb"))?; + fn test_concat_notebook() -> Result<(), NotebookError> { + let notebook = Notebook::from_path(¬ebook_path("valid.ipynb"))?; assert_eq!( notebook.source_code, r#"def unused_variable(): @@ -597,110 +520,4 @@ print("after empty cells") ); Ok(()) } - - #[test] - fn test_import_sorting() -> Result<()> { - let path = "isort.ipynb".to_string(); - let TestedNotebook { - messages, - source_notebook, - .. - } = test_notebook_path( - &path, - Path::new("isort_expected.ipynb"), - &settings::Settings::for_rule(Rule::UnsortedImports), - )?; - assert_messages!(messages, path, source_notebook); - Ok(()) - } - - #[test] - fn test_ipy_escape_command() -> Result<()> { - let path = "ipy_escape_command.ipynb".to_string(); - let TestedNotebook { - messages, - source_notebook, - .. - } = test_notebook_path( - &path, - Path::new("ipy_escape_command_expected.ipynb"), - &settings::Settings::for_rule(Rule::UnusedImport), - )?; - assert_messages!(messages, path, source_notebook); - Ok(()) - } - - #[test] - fn test_unused_variable() -> Result<()> { - let path = "unused_variable.ipynb".to_string(); - let TestedNotebook { - messages, - source_notebook, - .. - } = test_notebook_path( - &path, - Path::new("unused_variable_expected.ipynb"), - &settings::Settings::for_rule(Rule::UnusedVariable), - )?; - assert_messages!(messages, path, source_notebook); - Ok(()) - } - - #[test] - fn test_json_consistency() -> Result<()> { - let path = "before_fix.ipynb".to_string(); - let TestedNotebook { - linted_notebook: fixed_notebook, - .. - } = test_notebook_path( - path, - Path::new("after_fix.ipynb"), - &settings::Settings::for_rule(Rule::UnusedImport), - )?; - let mut writer = Vec::new(); - fixed_notebook.write_inner(&mut writer)?; - let actual = String::from_utf8(writer)?; - let expected = - std::fs::read_to_string(test_resource_path("fixtures/jupyter/after_fix.ipynb"))?; - assert_eq!(actual, expected); - Ok(()) - } - - #[test_case(Path::new("before_fix.ipynb"), true; "trailing_newline")] - #[test_case(Path::new("no_trailing_newline.ipynb"), false; "no_trailing_newline")] - fn test_trailing_newline(path: &Path, trailing_newline: bool) -> Result<()> { - let notebook = read_jupyter_notebook(path)?; - assert_eq!(notebook.trailing_newline, trailing_newline); - - let mut writer = Vec::new(); - notebook.write_inner(&mut writer)?; - let string = String::from_utf8(writer)?; - assert_eq!(string.ends_with('\n'), trailing_newline); - - Ok(()) - } - - // Version <4.5, don't emit cell ids - #[test_case(Path::new("no_cell_id.ipynb"), false; "no_cell_id")] - // Version 4.5, cell ids are missing and need to be added - #[test_case(Path::new("add_missing_cell_id.ipynb"), true; "add_missing_cell_id")] - fn test_cell_id(path: &Path, has_id: bool) -> Result<()> { - let source_notebook = read_jupyter_notebook(path)?; - let source_kind = SourceKind::IpyNotebook(source_notebook); - let (_, transformed) = test_contents( - &source_kind, - path, - &settings::Settings::for_rule(Rule::UnusedImport), - ); - let linted_notebook = transformed.into_owned().expect_ipy_notebook(); - let mut writer = Vec::new(); - linted_notebook.write_inner(&mut writer)?; - let actual = String::from_utf8(writer)?; - if has_id { - assert!(actual.contains(r#""id": ""#)); - } else { - assert!(!actual.contains(r#""id":"#)); - } - Ok(()) - } } diff --git a/crates/ruff/src/jupyter/schema.rs b/crates/ruff_notebook/src/schema.rs similarity index 99% rename from crates/ruff/src/jupyter/schema.rs rename to crates/ruff_notebook/src/schema.rs index e466615fec..63874def74 100644 --- a/crates/ruff/src/jupyter/schema.rs +++ b/crates/ruff_notebook/src/schema.rs @@ -46,7 +46,7 @@ fn sort_alphabetically( /// /// use serde::Serialize; /// -/// use ruff::jupyter::SortAlphabetically; +/// use ruff_notebook::SortAlphabetically; /// /// #[derive(Serialize)] /// struct MyStruct { diff --git a/crates/ruff_python_ast/Cargo.toml b/crates/ruff_python_ast/Cargo.toml index ac33034c90..b98a00ca23 100644 --- a/crates/ruff_python_ast/Cargo.toml +++ b/crates/ruff_python_ast/Cargo.toml @@ -19,6 +19,7 @@ ruff_text_size = { path = "../ruff_text_size" } bitflags = { workspace = true } is-macro = { workspace = true } +itertools = { workspace = true } memchr = { workspace = true } num-bigint = { workspace = true } num-traits = { workspace = true } diff --git a/crates/ruff_python_ast/src/comparable.rs b/crates/ruff_python_ast/src/comparable.rs index cf4fcc95a0..e0d7c99ba1 100644 --- a/crates/ruff_python_ast/src/comparable.rs +++ b/crates/ruff_python_ast/src/comparable.rs @@ -334,7 +334,7 @@ impl<'a> From<&'a ast::Decorator> for ComparableDecorator<'a> { pub enum ComparableConstant<'a> { None, Bool(&'a bool), - Str(&'a str), + Str { value: &'a str, unicode: bool }, Bytes(&'a [u8]), Int(&'a BigInt), Tuple(Vec>), @@ -353,7 +353,11 @@ impl<'a> From<&'a ast::Constant> for ComparableConstant<'a> { // Compare strings based on resolved value, not representation (i.e., ignore whether // the string was implicitly concatenated). implicit_concatenated: _, - }) => Self::Str(value), + unicode, + }) => Self::Str { + value, + unicode: *unicode, + }, ast::Constant::Bytes(ast::BytesConstant { value, // Compare bytes based on resolved value, not representation (i.e., ignore whether @@ -655,7 +659,6 @@ pub struct ExprFString<'a> { #[derive(Debug, PartialEq, Eq, Hash)] pub struct ExprConstant<'a> { value: ComparableConstant<'a>, - kind: Option<&'a str>, } #[derive(Debug, PartialEq, Eq, Hash)] @@ -904,14 +907,11 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> { }) => Self::FString(ExprFString { values: values.iter().map(Into::into).collect(), }), - ast::Expr::Constant(ast::ExprConstant { - value, - kind, - range: _, - }) => Self::Constant(ExprConstant { - value: value.into(), - kind: kind.as_ref().map(String::as_str), - }), + ast::Expr::Constant(ast::ExprConstant { value, range: _ }) => { + Self::Constant(ExprConstant { + value: value.into(), + }) + } ast::Expr::Attribute(ast::ExprAttribute { value, attr, diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index 8c97f9a172..9e9ce3179c 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -207,6 +207,8 @@ pub fn any_over_expr(expr: &Expr, func: &dyn Fn(&Expr) -> bool) -> bool { range: _, }) => { any_over_expr(call_func, func) + // Note that this is the evaluation order but not necessarily the declaration order + // (e.g. for `f(*args, a=2, *args2, **kwargs)` it's not) || args.iter().any(|expr| any_over_expr(expr, func)) || keywords .iter() @@ -347,6 +349,8 @@ pub fn any_over_stmt(stmt: &Stmt, func: &dyn Fn(&Expr) -> bool) -> bool { decorator_list, .. }) => { + // Note that e.g. `class A(*args, a=2, *args2, **kwargs): pass` is a valid class + // definition arguments .as_deref() .is_some_and(|Arguments { args, keywords, .. }| { @@ -576,7 +580,6 @@ pub const fn is_const_none(expr: &Expr) -> bool { expr, Expr::Constant(ast::ExprConstant { value: Constant::None, - kind: None, .. }), ) @@ -588,7 +591,6 @@ pub const fn is_const_true(expr: &Expr) -> bool { expr, Expr::Constant(ast::ExprConstant { value: Constant::Bool(true), - kind: None, .. }), ) @@ -600,7 +602,6 @@ pub const fn is_const_false(expr: &Expr) -> bool { expr, Expr::Constant(ast::ExprConstant { value: Constant::Bool(false), - kind: None, .. }), ) @@ -653,6 +654,17 @@ pub fn map_subscript(expr: &Expr) -> &Expr { } } +/// Given an [`Expr`] that can be starred, return the underlying starred expression. +pub fn map_starred(expr: &Expr) -> &Expr { + if let Expr::Starred(ast::ExprStarred { value, .. }) = expr { + // Ex) `*args` + value + } else { + // Ex) `args` + expr + } +} + /// Return `true` if the body uses `locals()`, `globals()`, `vars()`, `eval()`. /// /// Accepts a closure that determines whether a given name (e.g., `"list"`) is a Python builtin. @@ -1179,17 +1191,14 @@ mod tests { }); let constant_one = Expr::Constant(ExprConstant { value: Constant::Int(1.into()), - kind: Some("x".to_string()), range: TextRange::default(), }); let constant_two = Expr::Constant(ExprConstant { value: Constant::Int(2.into()), - kind: Some("y".to_string()), range: TextRange::default(), }); let constant_three = Expr::Constant(ExprConstant { value: Constant::Int(3.into()), - kind: Some("z".to_string()), range: TextRange::default(), }); let type_var_one = TypeParam::TypeVar(TypeParamTypeVar { @@ -1232,7 +1241,6 @@ mod tests { let bound = Expr::Constant(ExprConstant { value: Constant::Int(1.into()), - kind: Some("x".to_string()), range: TextRange::default(), }); diff --git a/crates/ruff_python_ast/src/node.rs b/crates/ruff_python_ast/src/node.rs index 8c96479221..35cfb9147c 100644 --- a/crates/ruff_python_ast/src/node.rs +++ b/crates/ruff_python_ast/src/node.rs @@ -1,9 +1,9 @@ use crate::visitor::preorder::PreorderVisitor; use crate::{ - self as ast, Alias, Arguments, Comprehension, Decorator, ExceptHandler, Expr, Keyword, - MatchCase, Mod, Parameter, ParameterWithDefault, Parameters, Pattern, PatternArguments, - PatternKeyword, Stmt, TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, - TypeParams, WithItem, + self as ast, Alias, ArgOrKeyword, Arguments, Comprehension, Decorator, ExceptHandler, Expr, + Keyword, MatchCase, Mod, Parameter, ParameterWithDefault, Parameters, Pattern, + PatternArguments, PatternKeyword, Stmt, TypeParam, TypeParamParamSpec, TypeParamTypeVar, + TypeParamTypeVarTuple, TypeParams, WithItem, }; use ruff_text_size::{Ranged, TextRange}; use std::ptr::NonNull; @@ -2682,11 +2682,7 @@ impl AstNode for ast::ExprConstant { where V: PreorderVisitor<'a> + ?Sized, { - let ast::ExprConstant { - value, - range: _, - kind: _, - } = self; + let ast::ExprConstant { value, range: _ } = self; visitor.visit_constant(value); } } @@ -3553,18 +3549,11 @@ impl AstNode for Arguments { where V: PreorderVisitor<'a> + ?Sized, { - let ast::Arguments { - range: _, - args, - keywords, - } = self; - - for arg in args { - visitor.visit_expr(arg); - } - - for keyword in keywords { - visitor.visit_keyword(keyword); + for arg_or_keyword in self.arguments_source_order() { + match arg_or_keyword { + ArgOrKeyword::Arg(arg) => visitor.visit_expr(arg), + ArgOrKeyword::Keyword(keyword) => visitor.visit_keyword(keyword), + } } } } diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index 514ed6c8ff..9c4d8b594a 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -1,5 +1,6 @@ #![allow(clippy::derive_partial_eq_without_eq)] +use itertools::Itertools; use std::fmt; use std::fmt::Debug; use std::ops::Deref; @@ -98,6 +99,59 @@ pub enum Stmt { IpyEscapeCommand(StmtIpyEscapeCommand), } +/// An AST node used to represent a IPython escape command at the statement level. +/// +/// For example, +/// ```python +/// %matplotlib inline +/// ``` +/// +/// ## Terminology +/// +/// Escape commands are special IPython syntax which starts with a token to identify +/// the escape kind followed by the command value itself. [Escape kind] are the kind +/// of escape commands that are recognized by the token: `%`, `%%`, `!`, `!!`, +/// `?`, `??`, `/`, `;`, and `,`. +/// +/// Help command (or Dynamic Object Introspection as it's called) are the escape commands +/// of the kind `?` and `??`. For example, `?str.replace`. Help end command are a subset +/// of Help command where the token can be at the end of the line i.e., after the value. +/// For example, `str.replace?`. +/// +/// Here's where things get tricky. I'll divide the help end command into two types for +/// better understanding: +/// 1. Strict version: The token is _only_ at the end of the line. For example, +/// `str.replace?` or `str.replace??`. +/// 2. Combined version: Along with the `?` or `??` token, which are at the end of the +/// line, there are other escape kind tokens that are present at the start as well. +/// For example, `%matplotlib?` or `%%timeit?`. +/// +/// Priority comes into picture for the "Combined version" mentioned above. How do +/// we determine the escape kind if there are tokens on both side of the value, i.e., which +/// token to choose? The Help end command always takes priority over any other token which +/// means that if there is `?`/`??` at the end then that is used to determine the kind. +/// For example, in `%matplotlib?` the escape kind is determined using the `?` token +/// instead of `%` token. +/// +/// ## Syntax +/// +/// `` +/// +/// The simplest form is an escape kind token followed by the command value. For example, +/// `%matplotlib inline`, `/foo`, `!pwd`, etc. +/// +/// `` +/// +/// The help end escape command would be the reverse of the above syntax. Here, the +/// escape kind token can only be either `?` or `??` and it is at the end of the line. +/// For example, `str.replace?`, `math.pi??`, etc. +/// +/// `` +/// +/// The final syntax is the combined version of the above two. For example, `%matplotlib?`, +/// `%%timeit??`, etc. +/// +/// [Escape kind]: IpyEscapeKind #[derive(Clone, Debug, PartialEq)] pub struct StmtIpyEscapeCommand { pub range: TextRange, @@ -559,6 +613,17 @@ pub enum Expr { IpyEscapeCommand(ExprIpyEscapeCommand), } +/// An AST node used to represent a IPython escape command at the expression level. +/// +/// For example, +/// ```python +/// dir = !pwd +/// ``` +/// +/// Here, the escape kind can only be `!` or `%` otherwise it is a syntax error. +/// +/// For more information related to terminology and syntax of escape commands, +/// see [`StmtIpyEscapeCommand`]. #[derive(Clone, Debug, PartialEq)] pub struct ExprIpyEscapeCommand { pub range: TextRange, @@ -881,7 +946,6 @@ impl From for Expr { pub struct ExprConstant { pub range: TextRange, pub value: Constant, - pub kind: Option, } impl From for Expr { @@ -2114,6 +2178,34 @@ pub struct Arguments { pub keywords: Vec, } +/// An entry in the argument list of a function call. +#[derive(Clone, Debug, PartialEq)] +pub enum ArgOrKeyword<'a> { + Arg(&'a Expr), + Keyword(&'a Keyword), +} + +impl<'a> From<&'a Expr> for ArgOrKeyword<'a> { + fn from(arg: &'a Expr) -> Self { + Self::Arg(arg) + } +} + +impl<'a> From<&'a Keyword> for ArgOrKeyword<'a> { + fn from(keyword: &'a Keyword) -> Self { + Self::Keyword(keyword) + } +} + +impl Ranged for ArgOrKeyword<'_> { + fn range(&self) -> TextRange { + match self { + Self::Arg(arg) => arg.range(), + Self::Keyword(keyword) => keyword.range(), + } + } +} + impl Arguments { /// Return the number of positional and keyword arguments. pub fn len(&self) -> usize { @@ -2149,6 +2241,46 @@ impl Arguments { .map(|keyword| &keyword.value) .or_else(|| self.find_positional(position)) } + + /// Return the positional and keyword arguments in the order of declaration. + /// + /// Positional arguments are generally before keyword arguments, but star arguments are an + /// exception: + /// ```python + /// class A(*args, a=2, *args2, **kwargs): + /// pass + /// + /// f(*args, a=2, *args2, **kwargs) + /// ``` + /// where `*args` and `args2` are `args` while `a=1` and `kwargs` are `keywords`. + /// + /// If you would just chain `args` and `keywords` the call would get reordered which we don't + /// want. This function instead "merge sorts" them into the correct order. + /// + /// Note that the order of evaluation is always first `args`, then `keywords`: + /// ```python + /// def f(*args, **kwargs): + /// pass + /// + /// def g(x): + /// print(x) + /// return x + /// + /// + /// f(*g([1]), a=g(2), *g([3]), **g({"4": 5})) + /// ``` + /// Output: + /// ```text + /// [1] + /// [3] + /// 2 + /// {'4': 5} + /// ``` + pub fn arguments_source_order(&self) -> impl Iterator> { + let args = self.args.iter().map(ArgOrKeyword::Arg); + let keywords = self.keywords.iter().map(ArgOrKeyword::Keyword); + args.merge_by(keywords, |left, right| left.start() < right.start()) + } } /// An AST node used to represent a sequence of type parameters. @@ -2495,6 +2627,8 @@ pub struct StringConstant { /// The string value as resolved by the parser (i.e., without quotes, or escape sequences, or /// implicit concatenations). pub value: String, + /// Whether the string is a Unicode string (i.e., `u"..."`). + pub unicode: bool, /// Whether the string contains multiple string tokens that were implicitly concatenated. pub implicit_concatenated: bool, } @@ -2534,6 +2668,7 @@ impl From for Constant { fn from(value: String) -> Constant { Self::Str(StringConstant { value, + unicode: false, implicit_concatenated: false, }) } @@ -2716,7 +2851,7 @@ impl Ranged for crate::nodes::StmtContinue { self.range } } -impl Ranged for StmtIpyEscapeCommand { +impl Ranged for crate::nodes::StmtIpyEscapeCommand { fn range(&self) -> TextRange { self.range } @@ -2888,7 +3023,7 @@ impl Ranged for crate::nodes::ExprSlice { self.range } } -impl Ranged for ExprIpyEscapeCommand { +impl Ranged for crate::nodes::ExprIpyEscapeCommand { fn range(&self) -> TextRange { self.range } @@ -2927,7 +3062,6 @@ impl Ranged for crate::Expr { } } } - impl Ranged for crate::nodes::Comprehension { fn range(&self) -> TextRange { self.range @@ -2945,7 +3079,6 @@ impl Ranged for crate::ExceptHandler { } } } - impl Ranged for crate::nodes::Parameter { fn range(&self) -> TextRange { self.range @@ -3086,6 +3219,173 @@ impl Ranged for crate::nodes::ParameterWithDefault { } } +/// An expression that may be parenthesized. +#[derive(Clone, Debug)] +pub struct ParenthesizedExpr { + /// The range of the expression, including any parentheses. + pub range: TextRange, + /// The underlying expression. + pub expr: Expr, +} +impl Ranged for ParenthesizedExpr { + fn range(&self) -> TextRange { + self.range + } +} +impl From for ParenthesizedExpr { + fn from(expr: Expr) -> Self { + ParenthesizedExpr { + range: expr.range(), + expr, + } + } +} +impl From for Expr { + fn from(parenthesized_expr: ParenthesizedExpr) -> Self { + parenthesized_expr.expr + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprIpyEscapeCommand) -> Self { + Expr::IpyEscapeCommand(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprBoolOp) -> Self { + Expr::BoolOp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprNamedExpr) -> Self { + Expr::NamedExpr(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprBinOp) -> Self { + Expr::BinOp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprUnaryOp) -> Self { + Expr::UnaryOp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprLambda) -> Self { + Expr::Lambda(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprIfExp) -> Self { + Expr::IfExp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprDict) -> Self { + Expr::Dict(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprSet) -> Self { + Expr::Set(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprListComp) -> Self { + Expr::ListComp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprSetComp) -> Self { + Expr::SetComp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprDictComp) -> Self { + Expr::DictComp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprGeneratorExp) -> Self { + Expr::GeneratorExp(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprAwait) -> Self { + Expr::Await(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprYield) -> Self { + Expr::Yield(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprYieldFrom) -> Self { + Expr::YieldFrom(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprCompare) -> Self { + Expr::Compare(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprCall) -> Self { + Expr::Call(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprFormattedValue) -> Self { + Expr::FormattedValue(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprFString) -> Self { + Expr::FString(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprConstant) -> Self { + Expr::Constant(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprAttribute) -> Self { + Expr::Attribute(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprSubscript) -> Self { + Expr::Subscript(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprStarred) -> Self { + Expr::Starred(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprName) -> Self { + Expr::Name(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprList) -> Self { + Expr::List(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprTuple) -> Self { + Expr::Tuple(payload).into() + } +} +impl From for ParenthesizedExpr { + fn from(payload: ExprSlice) -> Self { + Expr::Slice(payload).into() + } +} + #[cfg(target_pointer_width = "64")] mod size_assertions { use static_assertions::assert_eq_size; diff --git a/crates/ruff_python_ast/src/visitor.rs b/crates/ruff_python_ast/src/visitor.rs index 7d30a76e08..d0b62fa7af 100644 --- a/crates/ruff_python_ast/src/visitor.rs +++ b/crates/ruff_python_ast/src/visitor.rs @@ -573,6 +573,9 @@ pub fn walk_format_spec<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, format_spe } pub fn walk_arguments<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, arguments: &'a Arguments) { + // Note that the there might be keywords before the last arg, e.g. in + // f(*args, a=2, *args2, **kwargs)`, but we follow Python in evaluating first `args` and then + // `keywords`. See also [Arguments::arguments_source_order`]. for arg in &arguments.args { visitor.visit_expr(arg); } diff --git a/crates/ruff_python_codegen/src/generator.rs b/crates/ruff_python_codegen/src/generator.rs index 4408ff9f05..d17cb3e75f 100644 --- a/crates/ruff_python_codegen/src/generator.rs +++ b/crates/ruff_python_codegen/src/generator.rs @@ -1,20 +1,21 @@ //! Generate Python source code from an abstract syntax tree (AST). -use ruff_python_ast::{ParameterWithDefault, TypeParams}; use std::ops::Deref; use ruff_python_ast::{ - self as ast, Alias, BoolOp, CmpOp, Comprehension, Constant, ConversionFlag, DebugText, - ExceptHandler, Expr, Identifier, MatchCase, Operator, Parameter, Parameters, Pattern, Stmt, - Suite, TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, WithItem, + self as ast, Alias, ArgOrKeyword, BoolOp, CmpOp, Comprehension, Constant, ConversionFlag, + DebugText, ExceptHandler, Expr, Identifier, MatchCase, Operator, Parameter, Parameters, + Pattern, Stmt, Suite, TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, + WithItem, }; +use ruff_python_ast::{ParameterWithDefault, TypeParams}; use ruff_python_literal::escape::{AsciiEscape, Escape, UnicodeEscape}; - use ruff_source_file::LineEnding; use super::stylist::{Indentation, Quote, Stylist}; mod precedence { + pub(crate) const NAMED_EXPR: u8 = 1; pub(crate) const ASSIGN: u8 = 3; pub(crate) const ANN_ASSIGN: u8 = 5; pub(crate) const AUG_ASSIGN: u8 = 5; @@ -31,7 +32,6 @@ mod precedence { pub(crate) const TUPLE: u8 = 19; pub(crate) const FORMATTED_VALUE: u8 = 19; pub(crate) const COMMA: u8 = 21; - pub(crate) const NAMED_EXPR: u8 = 23; pub(crate) const ASSERT: u8 = 23; pub(crate) const COMPREHENSION_ELEMENT: u8 = 27; pub(crate) const LAMBDA: u8 = 27; @@ -266,19 +266,23 @@ impl<'a> Generator<'a> { if let Some(arguments) = arguments { self.p("("); let mut first = true; - for base in &arguments.args { - self.p_delim(&mut first, ", "); - self.unparse_expr(base, precedence::MAX); - } - for keyword in &arguments.keywords { - self.p_delim(&mut first, ", "); - if let Some(arg) = &keyword.arg { - self.p_id(arg); - self.p("="); - } else { - self.p("**"); + for arg_or_keyword in arguments.arguments_source_order() { + match arg_or_keyword { + ArgOrKeyword::Arg(arg) => { + self.p_delim(&mut first, ", "); + self.unparse_expr(arg, precedence::MAX); + } + ArgOrKeyword::Keyword(keyword) => { + self.p_delim(&mut first, ", "); + if let Some(arg) = &keyword.arg { + self.p_id(arg); + self.p("="); + } else { + self.p("**"); + } + self.unparse_expr(&keyword.value, precedence::MAX); + } } - self.unparse_expr(&keyword.value, precedence::MAX); } self.p(")"); } @@ -359,7 +363,7 @@ impl<'a> Generator<'a> { self.unparse_expr(target, precedence::ANN_ASSIGN); self.p_if(need_parens, ")"); self.p(": "); - self.unparse_expr(annotation, precedence::ANN_ASSIGN); + self.unparse_expr(annotation, precedence::COMMA); if let Some(value) = value { self.p(" = "); self.unparse_expr(value, precedence::COMMA); @@ -1046,19 +1050,24 @@ impl<'a> Generator<'a> { self.unparse_comp(generators); } else { let mut first = true; - for arg in &arguments.args { - self.p_delim(&mut first, ", "); - self.unparse_expr(arg, precedence::COMMA); - } - for kw in &arguments.keywords { - self.p_delim(&mut first, ", "); - if let Some(arg) = &kw.arg { - self.p_id(arg); - self.p("="); - self.unparse_expr(&kw.value, precedence::COMMA); - } else { - self.p("**"); - self.unparse_expr(&kw.value, precedence::MAX); + + for arg_or_keyword in arguments.arguments_source_order() { + match arg_or_keyword { + ArgOrKeyword::Arg(arg) => { + self.p_delim(&mut first, ", "); + self.unparse_expr(arg, precedence::COMMA); + } + ArgOrKeyword::Keyword(keyword) => { + self.p_delim(&mut first, ", "); + if let Some(arg) = &keyword.arg { + self.p_id(arg); + self.p("="); + self.unparse_expr(&keyword.value, precedence::COMMA); + } else { + self.p("**"); + self.unparse_expr(&keyword.value, precedence::MAX); + } + } } } } @@ -1079,14 +1088,7 @@ impl<'a> Generator<'a> { Expr::FString(ast::ExprFString { values, .. }) => { self.unparse_f_string(values, false); } - Expr::Constant(ast::ExprConstant { - value, - kind, - range: _, - }) => { - if let Some(kind) = kind { - self.p(kind); - } + Expr::Constant(ast::ExprConstant { value, range: _ }) => { self.unparse_constant(value); } Expr::Attribute(ast::ExprAttribute { value, attr, .. }) => { @@ -1169,7 +1171,10 @@ impl<'a> Generator<'a> { Constant::Bytes(b) => { self.p_bytes_repr(b); } - Constant::Str(ast::StringConstant { value, .. }) => { + Constant::Str(ast::StringConstant { value, unicode, .. }) => { + if *unicode { + self.p("u"); + } self.p_str_repr(value); } Constant::None => self.p("None"), @@ -1381,12 +1386,12 @@ impl<'a> Generator<'a> { mod tests { use ruff_python_ast::{Mod, ModModule}; use ruff_python_parser::{self, parse_suite, Mode}; - use ruff_source_file::LineEnding; - use super::Generator; use crate::stylist::{Indentation, Quote}; + use super::Generator; + fn round_trip(contents: &str) -> String { let indentation = Indentation::default(); let quote = Quote::default(); @@ -1413,7 +1418,7 @@ mod tests { let indentation = Indentation::default(); let quote = Quote::default(); let line_ending = LineEnding::default(); - let ast = ruff_python_parser::parse(contents, Mode::Jupyter, "").unwrap(); + let ast = ruff_python_parser::parse(contents, Mode::Ipython, "").unwrap(); let Mod::Module(ModModule { body, .. }) = ast else { panic!("Source code didn't return ModModule") }; @@ -1636,6 +1641,17 @@ class Foo: assert_round_trip!(r#"[n * 2 for n in range(10)]"#); assert_round_trip!(r#"{n * 2 for n in range(10)}"#); assert_round_trip!(r#"{i: n * 2 for i, n in enumerate(range(10))}"#); + assert_round_trip!( + "class SchemaItem(NamedTuple): + fields: ((\"property_key\", str),)" + ); + assert_round_trip!( + "def func(): + return (i := 1)" + ); + assert_round_trip!("yield (i := 1)"); + assert_round_trip!("x = (i := 1)"); + assert_round_trip!("x += (i := 1)"); // Type aliases assert_round_trip!(r#"type Foo = int | str"#); @@ -1643,6 +1659,11 @@ class Foo: assert_round_trip!(r#"type Foo[*Ts] = ..."#); assert_round_trip!(r#"type Foo[**P] = ..."#); assert_round_trip!(r#"type Foo[T, U, *Ts, **P] = ..."#); + // https://github.com/astral-sh/ruff/issues/6498 + assert_round_trip!(r#"f(a=1, *args, **kwargs)"#); + assert_round_trip!(r#"f(*args, a=1, **kwargs)"#); + assert_round_trip!(r#"f(*args, a=1, *args2, **kwargs)"#); + assert_round_trip!("class A(*args, a=2, *args2, **kwargs):\n pass"); } #[test] diff --git a/crates/ruff_python_formatter/CONTRIBUTING.md b/crates/ruff_python_formatter/CONTRIBUTING.md new file mode 100644 index 0000000000..c302a4dc49 --- /dev/null +++ b/crates/ruff_python_formatter/CONTRIBUTING.md @@ -0,0 +1,426 @@ +# Contributing to the Ruff Formatter + +The goal of our formatter is to be compatible with Black except for rare edge cases (mostly +involving comment placement). This document outlines the expected development workflow for the +formatter and walks through some of its internals. + +## Testing your changes + +You can use the `ruff_python_formatter` binary to format individual files and show debug info. +It's fast to compile because it doesn't depend on `ruff`. The easiest way is to create a +`scratch.py` (or `scratch.pyi`) in the project root and run: + +```shell +cargo run --bin ruff_python_formatter -- --emit stdout scratch.py +``` + +...which supports the `--print-ir` and `--print-comments` flag. (We recommend running with +`--print-comments`.) + +
+Usage example + +Command + +```shell +cargo run --bin ruff_python_formatter -- --emit stdout --print-comments --print-ir scratch.py +``` + +Input + +```python +def f(): # a + pass +``` + +Output + +```text +[ + "def f", + group([group(["()"]), source_position(7)]), + ":", + line_suffix([" # a"]), + expand_parent, + indent([hard_line_break, "pass", source_position(21)]), + hard_line_break, + source_position(21), + hard_line_break, + source_position(22) +] +{ + Node { + kind: StmtFunctionDef, + range: 0..21, + source: `def f(): # a⏎`, + }: { + "leading": [], + "dangling": [ + SourceComment { + text: "# a", + position: EndOfLine, + formatted: true, + }, + ], + "trailing": [], + }, +} +def f(): # a + pass +``` + +
+ +The other option is to use the playground (also check the playground README): + +```shell +cd playground && npm install && npm run dev:wasm && npm run dev +``` + +Run`npm run dev:wasm` and reload the page in the browser to refresh. + +**Tests** Running the entire ruff test suite is slow, `cargo test -p ruff_python_formatter` is a +lot faster. We use [insta](https://insta.rs/) to create snapshots of all tests in +`crates/ruff_python_formatter/resources/test/fixtures/ruff`. We have copied the majority of tests +over from Black to check the difference between Ruff and Black output. Whenever we have no more +differences on a Black input file, the snapshot is deleted. + +**Ecosystem checks** `scripts/formatter_ecosystem_checks.sh` runs Black compatibility and stability +checks on a number of selected projects. It will print the similarity index, the percentage of lines +that remains unchanged between Black's formatting and our formatting. You could compute it as the +number of neutral lines in a diff divided by the neutral plus the removed lines. We run this script +in CI, you can view the results in a PR page under "Checks" > "CI" > "Summary" at the bottom of the +page. The stability checks catch for three common problems: The second +formatting pass looks different than the first (formatter instability or lack of idempotency), +printing invalid syntax (e.g. missing parentheses around multiline expressions) and panics (mostly +in debug assertions). You should ensure that your changes don't decrease the similarity index. + +**Terminology** For `()`, `[]` and `{}` we use the following terminology: + +- Parentheses: `(`, `)` or all kind of parentheses (`()`, `[]` and `{}`, e.g. + `has_own_parentheses`) +- Brackets: `[`, `]` +- Braces: `{`, `}` + +## `format_dev` + +It's possible to format an entire project: + +```shell +cargo run --bin ruff_dev -- format-dev --write /path/to/my_project +``` + +Available options: + +- `--write`: Format the files and write them back to disk. +- `--stability-check`: Format twice (but don't write to disk without `--write`) and check for + differences and crashes. +- `--multi-project`: Treat every subdirectory as a separate project. Useful for ecosystem checks. +- `--error-file`: Write all errors to the given file. +- `--log-file`: Write all messages to the given file. +- `--stats-file`: Use together with `--multi-project`, this writes the similarity index as unicode + table to the given file. + +**Large ecosystem checks** It is also possible to check a large number of repositories. This dataset +is large (~60GB), so we only do this occasionally: + +```shell +# Get the list of projects +curl https://raw.githubusercontent.com/akx/ruff-usage-aggregate/master/data/known-github-tomls-clean.jsonl > github_search.jsonl +# Repurpose this script to download the repositories for us +python scripts/check_ecosystem.py --checkouts target/checkouts --projects github_search.jsonl -v $(which true) $(which true) +# Check each project for formatter stability +cargo run --bin ruff_dev -- format-dev --stability-check --error-file target/formatter-ecosystem-errors.txt --multi-project target/checkouts +``` + +**Shrinking** To shrink a formatter error from an entire file to a minimal reproducible example, +you can use `ruff_shrinking`: + +```shell +cargo run --bin ruff_shrinking -- target/shrinking.py "Unstable formatting" "target/debug/ruff_dev format-dev --stability-check target/shrinking.py" +``` + +The first argument is the input file, the second is the output file where the candidates +and the eventual minimized version will be written to. The third argument is a regex matching the +error message, e.g. "Unstable formatting" or "Formatter error". The last argument is the command +with the error, e.g. running the stability check on the candidate file. The script will try various +strategies to remove parts of the code. If the output of the command still matches, it will use that +slightly smaller code as starting point for the next iteration, otherwise it will revert and try +a different strategy until all strategies are exhausted. + +## Helper structs + +To abstract formatting something into a helper, create a new struct with the data you want to +format and implement `Format> for MyStruct`. Below is a small dummy example. + +```rust +/// Helper to hide the fields for the struct +pub(crate) fn empty_parenthesized<'content>( + comments: &'content [SourceComment], + has_plus_prefix: bool, +) -> FormatEmptyParenthesized<'content> { + FormatEmptyParenthesized { + comments, + has_plus_prefix, + } +} + +/// The wrapper struct +pub(crate) struct FormatEmptyParenthesized<'content> { + comments: &'content [SourceComment], + has_plus_prefix: bool, +} + +impl Format> for FormatEmptyParenthesized<'_> { + /// Here we implement the actual formatting + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + if self.has_plus_prefix { + text("+").fmt(f)?; // This is equivalent to `write!(f, [text("*")])?;` + } + write!( + f, + [ + text("("), + soft_block_indent(&dangling_comments(&self.comments)), + text(")") + ] + ) + } +} +``` + +If the struct is used across modules, also adds constructor function that hides the fields of the +struct. Since it implements `Format`, you can directly use it in write calls: + +```rust +write!(f, [empty_parenthesized(dangling_end_of_line_comments)])?; +``` + +Check the `builders` module for existing primitives. + +## Adding new syntax + +Occasionally, Python will add new syntax. After adding it to `ruff_python_ast`, run `generate.py` +to generate stubs for node formatting. This will add a `Format{{Node}}` struct +that implements `Default` (and `AsFormat`/`IntoFormat` impls in `generated.rs`, see orphan rules +below). + +```rust +#[derive(Default)] +pub struct FormatStmtReturn; +``` + +We implement `FormatNodeRule<{{Node}}> for Format{{Node}}`. Inside, we destructure the item to make +sure we're not missing any field. If we want to write multiple items, we use an efficient `write!` +call, for single items `.format().fmt(f)` or `.fmt(f)` is sufficient. + +```rust +impl FormatNodeRule for FormatStmtReturn { + fn fmt_fields(&self, item: &StmtReturn, f: &mut PyFormatter) -> FormatResult<()> { + // Here we destructure item and make sure each field is listed. + // We generally don't need range is it's underscore-ignored + let StmtReturn { range: _, value } = item; + // Implement some formatting logic, in this case no space (and no value) after a return with + // no value + if let Some(value) = value { + write!( + f, + [ + text("return"), + // There are multiple different space and newline types (e.g. + // `soft_line_break_or_space()`, check the builders module), this one will + // always be translate to a normal ascii whitespace character + space(), + // `return a, b` is valid, but if it wraps we'd need parentheses. + // This is different from `(a, b).count(1)` where the parentheses around the + // tuple are mandatory + value.format().with_options(Parenthesize::IfBreaks) + ] + ) + } else { + text("return").fmt(f) + } + } +} +``` + +If something such as list or a tuple can break into multiple lines if it is too long for a single +line, wrap it into a `group`. Ignoring comments, we could format a tuple with two items like this: + +```rust +write!( + f, + [group(&format_args![ + text("("), + soft_block_indent(&format_args![ + item1.format() + text(","), + soft_line_break_or_space(), + item2.format(), + if_group_breaks(&text(",")) + ]), + text(")") + ])] +) +``` + +If everything fits on a single line, the group doesn't break and we get something like `("a", "b")`. +If it doesn't, we get something like + +```Python +( + "a", + "b", +) +``` + +For a list of expression, you don't need to format it manually but can use the `JoinBuilder` util, +accessible through `.join_comma_separated`. Finish will write to the formatter internally. + +```rust +f.join_comma_separated(item.end()) + .nodes(elts.iter()) + .finish() +// Here we have a builder that separates each element by a `,` and a [`soft_line_break_or_space`]. +// It emits a trailing `,` that is only shown if the enclosing group expands. It forces the enclosing +// group to expand if the last item has a trailing `comma` and the magical comma option is enabled. +``` + +If you need avoid second mutable borrows with a builder, you can use `format_with(|f| { ... })` as +a formattable element similar to `text()` or `group()`. + +## Comments + +Comments can either be own line or end-of-line and can be marked as `Leading`, `Trailing` and `Dangling`. + +```python +# Leading comment (always own line) +print("hello world") # Trailing comment (end-of-line) +# Trailing comment (own line) +``` + +Comments are automatically attached as `Leading` or `Trailing` to a node close to them, or `Dangling` +if there are only tokens and no nodes surrounding it. Categorization is automatic but sometimes +needs to be overridden in +[`place_comment`](https://github.com/astral-sh/ruff/blob/be11cae619d5a24adb4da34e64d3c5f270f9727b/crates/ruff_python_formatter/src/comments/placement.rs#L13) +in `placement.rs`, which this section is about. + +```Python +[ + # This needs to be handled as a dangling comment +] +``` + +Here, the comment is dangling because it is preceded by `[`, which is a non-trivia token but not a +node, and followed by `]`, which is also a non-trivia token but not a node. In the `FormatExprList` +implementation, we have to call `dangling_comments` manually and stub out the +`fmt_dangling_comments` default from `FormatNodeRule`. + +```rust +impl FormatNodeRule for FormatExprList { + fn fmt_fields(&self, item: &ExprList, f: &mut PyFormatter) -> FormatResult<()> { + // ... + + write!( + f, + [group(&format_args![ + text("["), + dangling_comments(dangling), // Gets all the comments marked as dangling for the node + soft_block_indent(&items), + text("]") + ])] + ) + } + + fn fmt_dangling_comments(&self, _node: &ExprList, _f: &mut PyFormatter) -> FormatResult<()> { + // Handled as part of `fmt_fields` + Ok(()) + } +} +``` + +A related common challenge is that we want to attach comments to tokens (think keywords and +syntactically meaningful characters such as `:`) that have no node on their own. A slightly +simplified version of the `while` node in our AST looks like the following: + +```rust +pub struct StmtWhile { + pub range: TextRange, + pub test: Box>, + pub body: Vec>, + pub orelse: Vec>, +} +``` + +That means in + +```python +while True: # Trailing condition comment + if f(): + break + # trailing while comment +# leading else comment +else: + print("while-else") +``` + +the `else` has no node, we're just getting the statements in its body. + +The preceding token of the leading else comment is the `break`, which has a node, the following +token is the `else`, which lacks a node, so by default the comment would be marked as trailing +the `break` and wrongly formatted as such. We can identify these cases by looking for comments +between two bodies that have the same indentation level as the keyword, e.g. in our case the +leading else comment is inside the `while` node (which spans the entire snippet) and on the same +level as the `else`. We identify those case in +[`handle_own_line_comment_around_body`](https://github.com/astral-sh/ruff/blob/4bdd99f8822d914a59f918fc46bbd17a88e2fe47/crates/ruff_python_formatter/src/comments/placement.rs#L390) +and mark them as dangling for manual formatting later. Similarly, we find and mark comment after +the colon(s) in +[`handle_end_of_line_comment_around_body`](https://github.com/astral-sh/ruff/blob/4bdd99f8822d914a59f918fc46bbd17a88e2fe47/crates/ruff_python_formatter/src/comments/placement.rs#L238C4-L238C14) +. + +The comments don't carry any extra information such as why we marked the comment as trailing, +instead they are sorted into one list of leading, one list of trailing and one list of dangling +comments per node. In `FormatStmtWhile`, we can have multiple types of dangling comments, so we +have to split the dangling list into after-colon-comments, before-else-comments, etc. by some +element separating them (e.g. all comments trailing the colon come before the first statement in +the body) and manually insert them in the right position. + +A simplified implementation with only those two kinds of comments: + +```rust +fn fmt_fields(&self, item: &StmtWhile, f: &mut PyFormatter) -> FormatResult<()> { + + // ... + + // See FormatStmtWhile for the real, more complex implementation + let first_while_body_stmt = item.body.first().unwrap().end(); + let trailing_condition_comments_end = + dangling_comments.partition_point(|comment| comment.slice().end() < first_while_body_stmt); + let (trailing_condition_comments, or_else_comments) = + dangling_comments.split_at(trailing_condition_comments_end); + + write!( + f, + [ + text("while"), + space(), + test.format(), + text(":"), + trailing_comments(trailing_condition_comments), + block_indent(&body.format()) + leading_comments(or_else_comments), + text("else:"), + block_indent(&orelse.format()) + ] + )?; +} +``` + +## The orphan rules and trait structure + +For the formatter, we would like to implement `Format` from the rust_formatter crate for all AST +nodes, defined in the rustpython_parser crate. This violates Rust's orphan rules. We therefore +generate in `generate.py` a newtype for each AST node with implementations of `FormatNodeRule`, +`FormatRule`, `AsFormat` and `IntoFormat` on it. + +![excalidraw showing the relationships between the different types](orphan_rules_in_the_formatter.svg) diff --git a/crates/ruff_python_formatter/Cargo.toml b/crates/ruff_python_formatter/Cargo.toml index e63bbeb872..8e7a3b55ad 100644 --- a/crates/ruff_python_formatter/Cargo.toml +++ b/crates/ruff_python_formatter/Cargo.toml @@ -23,14 +23,15 @@ anyhow = { workspace = true } bitflags = { workspace = true } clap = { workspace = true } countme = "3.0.1" -is-macro = { workspace = true } itertools = { workspace = true } memchr = { workspace = true } once_cell = { workspace = true } rustc-hash = { workspace = true } serde = { workspace = true, optional = true } smallvec = { workspace = true } +static_assertions = { workspace = true } thiserror = { workspace = true } +tracing = { workspace = true } unicode-width = { workspace = true } [dev-dependencies] diff --git a/crates/ruff_python_formatter/README.md b/crates/ruff_python_formatter/README.md index 42f4fd7693..6a015b4d25 100644 --- a/crates/ruff_python_formatter/README.md +++ b/crates/ruff_python_formatter/README.md @@ -1,433 +1,307 @@ -# Rust Python Formatter +# Ruff Formatter -The goal of our formatter is to be compatible with Black except for rare edge cases (mostly -involving comment placement). +The Ruff formatter is an extremely fast Python code formatter that ships as part of the `ruff` +CLI (as of Ruff v0.0.289). -You can try an experimental version of the formatter on your project with: +The formatter is currently in an **Alpha** state. The Alpha is primarily intended for +experimentation: our focus is on collecting feedback that we can address prior to a production-ready +Beta release later this year. (While we're using the formatter in production on our own projects, +the CLI, configuration options, and code style may change arbitrarily between the Alpha and Beta.) -```shell -cargo run --bin ruff -- format path/to/your/project +[_We'd love to hear your feedback._](https://github.com/astral-sh/ruff/discussions/7310) + +## Goals + +The formatter is designed to be a drop-in replacement for [Black](https://github.com/psf/black), +but with an excessive focus on performance and direct integration with Ruff. + +Specifically, the formatter is intended to emit near-identical output when run over Black-formatted +code. When run over extensive Black-formatted projects like Django and Zulip, > 99.9% of lines +are formatted identically. When migrating an existing project from Black to Ruff, you should expect +to see a few differences on the margins, but the vast majority of your code should be unchanged. + +If you identify deviations in your project, spot-check them against the [intentional deviations](#intentional-deviations) +enumerated below, as well as the [unintentional deviations](https://github.com/astral-sh/ruff/issues?q=is%3Aopen+is%3Aissue+label%3Aformatter) +filed in the issue tracker. If you've identified a new deviation, please [file an issue](https://github.com/astral-sh/ruff/issues/new). + +When run over _non_-Black-formatted code, the formatter makes some different decisions than Black, +and so more deviations should be expected, especially around the treatment of end-of-line comments. +For details, see [Black compatibility](#black-compatibility). + +## Getting started + +The Ruff formatter shipped in an Alpha state as part of Ruff v0.0.289. + +### CLI + +The Ruff formatter is available as a standalone subcommand on the `ruff` CLI: + +```console +❯ ruff format --help +Run the Ruff formatter on the given files or directories + +Usage: ruff format [OPTIONS] [FILES]... + +Arguments: + [FILES]... List of files or directories to format + +Options: + --check Avoid writing any formatted files back; instead, exit with a non-zero status code if any files would have been modified, and zero otherwise + --config Path to the `pyproject.toml` or `ruff.toml` file to use for configuration + -h, --help Print help + +File selection: + --respect-gitignore Respect file exclusions via `.gitignore` and other standard ignore files + --force-exclude Enforce exclusions, even for paths passed to Ruff directly on the command-line + +Miscellaneous: + --isolated Ignore all configuration files + --stdin-filename The name of the file when passing it through stdin + +Log levels: + -v, --verbose Enable verbose logging + -q, --quiet Print diagnostics, but nothing else + -s, --silent Disable all logging (but still exit with status code "1" upon detecting diagnostics) ``` -Note that currently the only supported option is `line-length` and that both the CLI and the -formatting are a work-in-progress and will change before the stable release. +Note: `ruff format` is currently hidden by default and will not be visible when running +`ruff --help`. -## Dev tools +Similar to Black, running `ruff format /path/to/file.py` will format the given file or directory +in-place, while `ruff format --check /path/to/file.py` will avoid writing any formatted files back, +instead exiting with a non-zero status code if any files are not already formatted. -**Testing your changes** You can use the `ruff_python_formatter` binary to format individual files -and show debug info. It's fast to compile because it doesn't depend on `ruff`. The easiest way is to -create a `scratch.py` (or `scratch.pyi`) in the project root and run +### VS Code -```shell -cargo run --bin ruff_python_formatter -- --emit stdout scratch.py -``` +As of `v2023.36.0`, the [Ruff VS Code extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) +ships with support for the Ruff formatter. To enable formatting capabilities, set the +`ruff.enableExperimentalFormatter` setting to `true` in your `settings.json`, and mark the Ruff +extension as your default Python formatter: -which has `--print-ir` and `--print-comments` options. We especially recommend `--print-comments`. - -
-Usage example - -Command - -```shell -cargo run --bin ruff_python_formatter -- --emit stdout --print-comments --print-ir scratch.py -``` - -Input - -```python -def f(): # a - pass -``` - -Output - -```text -[ - "def f", - group([group(["()"]), source_position(7)]), - ":", - line_suffix([" # a"]), - expand_parent, - indent([hard_line_break, "pass", source_position(21)]), - hard_line_break, - source_position(21), - hard_line_break, - source_position(22) -] +```json { - Node { - kind: StmtFunctionDef, - range: 0..21, - source: `def f(): # a⏎`, - }: { - "leading": [], - "dangling": [ - SourceComment { - text: "# a", - position: EndOfLine, - formatted: true, - }, - ], - "trailing": [], - }, -} -def f(): # a - pass -``` - -
- -The other option is to use the playground (also check the playground README): - -```shell -cd playground && npm install && npm run dev:wasm && npm run dev -``` - -Run`npm run dev:wasm` and reload the page in the browser to refresh. - -**Tests** Running the entire ruff test suite is slow, `cargo test -p ruff_python_formatter` is a -lot faster. We use [insta](https://insta.rs/) to create snapshots of all tests in -`crates/ruff_python_formatter/resources/test/fixtures/ruff`. We have copied the majority of tests -over from Black to check the difference between Ruff and Black output. Whenever we have no more -differences on a Black input file, the snapshot is deleted. - -**Ecosystem checks** `scripts/formatter_ecosystem_checks.sh` runs Black compatibility and stability -checks on a number of selected projects. It will print the similarity index, the percentage of lines -that remains unchanged between Black's formatting and our formatting. You could compute it as the -number of neutral lines in a diff divided by the neutral plus the removed lines. We run this script -in CI, you can view the results in a PR page under "Checks" > "CI" > "Summary" at the bottom of the -page. The stability checks catch for three common problems: The second -formatting pass looks different than the first (formatter instability or lack of idempotency), -printing invalid syntax (e.g. missing parentheses around multiline expressions) and panics (mostly -in debug assertions). You should ensure that your changes don't decrease the similarity index. - -**Terminology** For `()`, `[]` and `{}` we use the following terminology: - -- Parentheses: `(`, `)` or all kind of parentheses (`()`, `[]` and `{}`, e.g. - `has_own_parentheses`) -- Brackets: `[`, `]` -- Braces: `{`, `}` - -## `format_dev` - -It's possible to format an entire project: - -```shell -cargo run --bin ruff_dev -- format-dev --write /path/to/my_project -``` - -Available options: - -- `--write`: Format the files and write them back to disk. -- `--stability-check`: Format twice (but don't write to disk without `--write`) and check for - differences and crashes. -- `--multi-project`: Treat every subdirectory as a separate project. Useful for ecosystem checks. -- `--error-file`: Write all errors to the given file. -- `--log-file`: Write all messages to the given file. -- `--stats-file`: Use together with `--multi-project`, this writes the similarity index as unicode - table to the given file. - -**Large ecosystem checks** It is also possible to check a large number of repositories. This dataset -is large (~60GB), so we only do this occasionally: - -```shell -# Get the list of projects -curl https://raw.githubusercontent.com/akx/ruff-usage-aggregate/master/data/known-github-tomls-clean.jsonl > github_search.jsonl -# Repurpose this script to download the repositories for us -python scripts/check_ecosystem.py --checkouts target/checkouts --projects github_search.jsonl -v $(which true) $(which true) -# Check each project for formatter stability -cargo run --bin ruff_dev -- format-dev --stability-check --error-file target/formatter-ecosystem-errors.txt --multi-project target/checkouts -``` - -**Shrinking** To shrink a formatter error from an entire file to a minimal reproducible example, -you can use `ruff_shrinking`: - -```shell -cargo run --bin ruff_shrinking -- target/shrinking.py "Unstable formatting" "target/debug/ruff_dev format-dev --stability-check target/shrinking.py" -``` - -The first argument is the input file, the second is the output file where the candidates -and the eventual minimized version will be written to. The third argument is a regex matching the -error message, e.g. "Unstable formatting" or "Formatter error". The last argument is the command -with the error, e.g. running the stability check on the candidate file. The script will try various -strategies to remove parts of the code. If the output of the command still matches, it will use that -slightly smaller code as starting point for the next iteration, otherwise it will revert and try -a different strategy until all strategies are exhausted. - -## Helper structs - -To abstract formatting something into a helper, create a new struct with the data you want to -format and implement `Format> for MyStruct`. Below is a small dummy example. - -```rust -/// Helper to hide the fields for the struct -pub(crate) fn empty_parenthesized<'content>( - comments: &'content [SourceComment], - has_plus_prefix: bool, -) -> FormatEmptyParenthesized<'content> { - FormatEmptyParenthesized { - comments, - has_plus_prefix, - } -} - -/// The wrapper struct -pub(crate) struct FormatEmptyParenthesized<'content> { - comments: &'content [SourceComment], - has_plus_prefix: bool, -} - -impl Format> for FormatEmptyParenthesized<'_> { - /// Here we implement the actual formatting - fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { - if self.has_plus_prefix { - text("+").fmt(f)?; // This is equivalent to `write!(f, [text("*")])?;` - } - write!( - f, - [ - text("("), - soft_block_indent(&dangling_comments(&self.comments)), - text(")") - ] - ) - } + "ruff.enableExperimentalFormatter": true, + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff" + } } ``` -If the struct is used across modules, also adds constructor function that hides the fields of the -struct. Since it implements `Format`, you can directly use it in write calls: +From there, you can format a file by running the `Format Document` command, or enable formatting +on-save by adding `"editor.formatOnSave": true` to your `settings.json`: -```rust -write!(f, [empty_parenthesized(dangling_end_of_line_comments)])?; -``` - -Check the `builders` module for existing primitives. - -## Adding new syntax - -Occasionally, Python will add new syntax. After adding it to `ruff_python_ast`, run `generate.py` -to generate stubs for node formatting. This will add a `Format{{Node}}` struct -that implements `Default` (and `AsFormat`/`IntoFormat` impls in `generated.rs`, see orphan rules -below). - -```rust -#[derive(Default)] -pub struct FormatStmtReturn; -``` - -We implement `FormatNodeRule<{{Node}}> for Format{{Node}}`. Inside, we destructure the item to make -sure we're not missing any field. If we want to write multiple items, we use an efficient `write!` -call, for single items `.format().fmt(f)` or `.fmt(f)` is sufficient. - -```rust -impl FormatNodeRule for FormatStmtReturn { - fn fmt_fields(&self, item: &StmtReturn, f: &mut PyFormatter) -> FormatResult<()> { - // Here we destructure item and make sure each field is listed. - // We generally don't need range is it's underscore-ignored - let StmtReturn { range: _, value } = item; - // Implement some formatting logic, in this case no space (and no value) after a return with - // no value - if let Some(value) = value { - write!( - f, - [ - text("return"), - // There are multiple different space and newline types (e.g. - // `soft_line_break_or_space()`, check the builders module), this one will - // always be translate to a normal ascii whitespace character - space(), - // `return a, b` is valid, but if it wraps we'd need parentheses. - // This is different from `(a, b).count(1)` where the parentheses around the - // tuple are mandatory - value.format().with_options(Parenthesize::IfBreaks) - ] - ) - } else { - text("return").fmt(f) - } - } +```json +{ + "ruff.enableExperimentalFormatter": true, + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.formatOnSave": true + } } ``` -If something such as list or a tuple can break into multiple lines if it is too long for a single -line, wrap it into a `group`. Ignoring comments, we could format a tuple with two items like this: +### Configuration -```rust -write!( - f, - [group(&format_args![ - text("("), - soft_block_indent(&format_args![ - item1.format() - text(","), - soft_line_break_or_space(), - item2.format(), - if_group_breaks(&text(",")) - ]), - text(")") - ])] -) +The Ruff formatter respects Ruff's [`line-length`](https://beta.ruff.rs/docs/settings/#line-length) +setting, which can be provided via a `pyproject.toml` or `ruff.toml` file, or on the CLI, as in: + +```console +ruff format --line-length 100 /path/to/file.py ``` -If everything fits on a single line, the group doesn't break and we get something like `("a", "b")`. -If it doesn't, we get something like +In future releases, the Ruff formatter will likely support configuration of: -```Python -( - "a", - "b", -) -``` +- Quote style (single vs. double). +- Line endings (LF vs. CRLF). +- Indentation (tabs vs. spaces). +- Tab width. -For a list of expression, you don't need to format it manually but can use the `JoinBuilder` util, -accessible through `.join_comma_separated`. Finish will write to the formatter internally. +### Excluding code from formatting -```rust -f.join_comma_separated(item.end()) - .nodes(elts.iter()) - .finish() -// Here we have a builder that separates each element by a `,` and a [`soft_line_break_or_space`]. -// It emits a trailing `,` that is only shown if the enclosing group expands. It forces the enclosing -// group to expand if the last item has a trailing `comma` and the magical comma option is enabled. -``` +Ruff supports Black's `# fmt: off`, `# fmt: on`, and `# fmt: skip` pragmas, with a few caveats. -If you need avoid second mutable borrows with a builder, you can use `format_with(|f| { ... })` as -a formattable element similar to `text()` or `group()`. +See Ruff's [suppression comment proposal](https://github.com/astral-sh/ruff/discussions/6338) for +details. -## Comments +## Black compatibility -Comments can either be own line or end-of-line and can be marked as `Leading`, `Trailing` and `Dangling`. +The formatter is designed to be a drop-in replacement for [Black](https://github.com/psf/black). + +Specifically, the formatter is intended to emit near-identical output when run over Black-formatted +code. When migrating an existing project from Black to Ruff, you should expect to see a few +differences on the margins, but the vast majority of your code should be formatted identically. +Note, however, that the formatter does not yet implement or support Black's preview style. + +When run over _non_-Black-formatted code, the formatter makes some different decisions than Black, +and so more deviations should be expected. + +### Intentional deviations + +This section enumerates the known, intentional deviations between the Ruff formatter and Black's +stable style. (Unintentional deviations are tracked in the [issue tracker](https://github.com/astral-sh/ruff/issues?q=is%3Aopen+is%3Aissue+label%3Aformatter).) + +#### Trailing end-of-line comments + +Black's priority is to fit an entire statement on a line, even if it contains end-of-line comments. +In such cases, Black collapses the statement, and moves the comment to the end of the collapsed +statement: ```python -# Leading comment (always own line) -print("hello world") # Trailing comment (end-of-line) -# Trailing comment (own line) +# Input +while ( + cond1 # almost always true + and cond2 # almost never true +): + print("Do something") + +# Black +while cond1 and cond2: # almost always true # almost never true + print("Do something") ``` -Comments are automatically attached as `Leading` or `Trailing` to a node close to them, or `Dangling` -if there are only tokens and no nodes surrounding it. Categorization is automatic but sometimes -needs to be overridden in -[`place_comment`](https://github.com/astral-sh/ruff/blob/be11cae619d5a24adb4da34e64d3c5f270f9727b/crates/ruff_python_formatter/src/comments/placement.rs#L13) -in `placement.rs`, which this section is about. +Ruff, like [Prettier](https://prettier.io/), expands any statement that contains trailing +end-of-line comments. For example, Ruff would avoid collapsing the `while` test in the snippet +above. This ensures that the comments remain close to their original position and retain their +original intent, at the cost of retaining additional vertical space. -```Python +This deviation only impacts unformatted code, in that Ruff's output should not deviate for code that +has already been formatted by Black. + +### Pragma comments are ignored when computing line width + +Pragma comments (`# type`, `# noqa`, `# pyright`, `# pylint`, etc.) are ignored when computing the width of a line. +This prevents Ruff from moving pragma comments around, thereby modifying their meaning and behavior: + +See Ruff's [pragma comment handling proposal](https://github.com/astral-sh/ruff/discussions/6670) +for details. + +This is similar to [Pyink](https://github.com/google/pyink) but a deviation from Black. Black avoids +splitting any lines that contain a `# type` comment ([#997](https://github.com/psf/black/issues/997)), +but otherwise avoids special-casing pragma comments. + +As Ruff expands trailing end-of-line comments, Ruff will also avoid moving pragma comments in cases +like the following, where moving the `# noqa` to the end of the line causes it to suppress errors +on both `first()` and `second()`: + +```python +# Input [ - # This needs to be handled as a dangling comment + first(), # noqa + second() +] + +# Black +[first(), second()] # noqa + +# Ruff +[ + first(), # noqa + second(), ] ``` -Here, the comment is dangling because it is preceded by `[`, which is a non-trivia token but not a -node, and followed by `]`, which is also a non-trivia token but not a node. In the `FormatExprList` -implementation, we have to call `dangling_comments` manually and stub out the -`fmt_dangling_comments` default from `FormatNodeRule`. +### Line width vs. line length -```rust -impl FormatNodeRule for FormatExprList { - fn fmt_fields(&self, item: &ExprList, f: &mut PyFormatter) -> FormatResult<()> { - // ... +Ruff uses the Unicode width of a line to determine if a line fits. Black's stable style uses +character width, while Black's preview style uses Unicode width for strings ([#3445](https://github.com/psf/black/pull/3445)), +and character width for all other tokens. Ruff's behavior is closer to Black's preview style than +Black's stable style, although Ruff _also_ uses Unicode width for identifiers and comments. - write!( - f, - [group(&format_args![ - text("["), - dangling_comments(dangling), // Gets all the comments marked as dangling for the node - soft_block_indent(&items), - text("]") - ])] - ) - } +### Walruses in slice expressions - fn fmt_dangling_comments(&self, _node: &ExprList, _f: &mut PyFormatter) -> FormatResult<()> { - // Handled as part of `fmt_fields` - Ok(()) - } -} -``` - -A related common challenge is that we want to attach comments to tokens (think keywords and -syntactically meaningful characters such as `:`) that have no node on their own. A slightly -simplified version of the `while` node in our AST looks like the following: - -```rust -pub struct StmtWhile { - pub range: TextRange, - pub test: Box>, - pub body: Vec>, - pub orelse: Vec>, -} -``` - -That means in +Black avoids inserting space around `:=` operators within slices. For example, the following adheres +to Black stable style: ```python -while True: # Trailing condition comment - if f(): - break - # trailing while comment -# leading else comment -else: - print("while-else") +# Input +x[y:=1] + +# Black +x[y:=1] ``` -the `else` has no node, we're just getting the statements in its body. +Ruff will instead add space around the `:=` operator: -The preceding token of the leading else comment is the `break`, which has a node, the following -token is the `else`, which lacks a node, so by default the comment would be marked as trailing -the `break` and wrongly formatted as such. We can identify these cases by looking for comments -between two bodies that have the same indentation level as the keyword, e.g. in our case the -leading else comment is inside the `while` node (which spans the entire snippet) and on the same -level as the `else`. We identify those case in -[`handle_own_line_comment_around_body`](https://github.com/astral-sh/ruff/blob/4bdd99f8822d914a59f918fc46bbd17a88e2fe47/crates/ruff_python_formatter/src/comments/placement.rs#L390) -and mark them as dangling for manual formatting later. Similarly, we find and mark comment after -the colon(s) in -[`handle_end_of_line_comment_around_body`](https://github.com/astral-sh/ruff/blob/4bdd99f8822d914a59f918fc46bbd17a88e2fe47/crates/ruff_python_formatter/src/comments/placement.rs#L238C4-L238C14) -. +```python +# Input +x[y:=1] -The comments don't carry any extra information such as why we marked the comment as trailing, -instead they are sorted into one list of leading, one list of trailing and one list of dangling -comments per node. In `FormatStmtWhile`, we can have multiple types of dangling comments, so we -have to split the dangling list into after-colon-comments, before-else-comments, etc. by some -element separating them (e.g. all comments trailing the colon come before the first statement in -the body) and manually insert them in the right position. - -A simplified implementation with only those two kinds of comments: - -```rust -fn fmt_fields(&self, item: &StmtWhile, f: &mut PyFormatter) -> FormatResult<()> { - - // ... - - // See FormatStmtWhile for the real, more complex implementation - let first_while_body_stmt = item.body.first().unwrap().end(); - let trailing_condition_comments_end = - dangling_comments.partition_point(|comment| comment.slice().end() < first_while_body_stmt); - let (trailing_condition_comments, or_else_comments) = - dangling_comments.split_at(trailing_condition_comments_end); - - write!( - f, - [ - text("while"), - space(), - test.format(), - text(":"), - trailing_comments(trailing_condition_comments), - block_indent(&body.format()) - leading_comments(or_else_comments), - text("else:"), - block_indent(&orelse.format()) - ] - )?; -} +# Ruff +x[y := 1] ``` -## The orphan rules and trait structure +This will likely be incorporated into Black's preview style ([#3823](https://github.com/psf/black/pull/3823)). -For the formatter, we would like to implement `Format` from the rust_formatter crate for all AST -nodes, defined in the rustpython_parser crate. This violates Rust's orphan rules. We therefore -generate in `generate.py` a newtype for each AST node with implementations of `FormatNodeRule`, -`FormatRule`, `AsFormat` and `IntoFormat` on it. +### `global` and `nonlocal` names are broken across multiple lines by continuations -![excalidraw showing the relationships between the different types](orphan_rules_in_the_formatter.svg) +If a `global` or `nonlocal` statement includes multiple names, and exceeds the configured line +width, Ruff will break them across multiple lines using continuations: + +```python +# Input +global analyze_featuremap_layer, analyze_featuremapcompression_layer, analyze_latencies_post, analyze_motions_layer, analyze_size_model + +# Ruff +global \ + analyze_featuremap_layer, \ + analyze_featuremapcompression_layer, \ + analyze_latencies_post, \ + analyze_motions_layer, \ + analyze_size_model +``` + +### Newlines are inserted after all class docstrings + +Black typically enforces a single newline after a class docstring. However, it does not apply such +formatting if the docstring is single-quoted rather than triple-quoted, while Ruff enforces a +single newline in both cases: + +```python +# Input +class IntFromGeom(GEOSFuncFactory): + "Argument is a geometry, return type is an integer." + argtypes = [GEOM_PTR] + restype = c_int + errcheck = staticmethod(check_minus_one) + +# Black +class IntFromGeom(GEOSFuncFactory): + "Argument is a geometry, return type is an integer." + argtypes = [GEOM_PTR] + restype = c_int + errcheck = staticmethod(check_minus_one) + +# Ruff +class IntFromGeom(GEOSFuncFactory): + "Argument is a geometry, return type is an integer." + + argtypes = [GEOM_PTR] + restype = c_int + errcheck = staticmethod(check_minus_one) +``` + +### Trailing own-line comments on imports are not moved to the next line + +Black enforces a single empty line between an import and a trailing own-line comment. Ruff leaves +such comments in-place: + +```python +# Input +import os +# comment + +import sys + +# Black +import os + +# comment + +import sys + +# Ruff +import os +# comment + +import sys +``` diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/comments_non_breaking_space.py b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/comments_non_breaking_space.py index d1d42f0259..0c5f5660eb 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/comments_non_breaking_space.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/comments_non_breaking_space.py @@ -14,6 +14,6 @@ def function(a:int=42): a b """ - #  There's a NBSP + 3 spaces before + #    There's a NBSP + 3 spaces before # And 4 spaces on the next line pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/docstring.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/docstring.options.json index 1c76291bcc..f709c8d714 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/docstring.options.json +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/docstring.options.json @@ -1,3 +1,3 @@ { - "tab_width": 8 + "indent_width": 4 } diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.options.json index 932f00f7e8..0e595f5597 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.options.json +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.options.json @@ -1,22 +1,18 @@ [ { - "indent_style": { - "Space": 4 - }, - "tab_width": 8 + "indent_style": "Space", + "indent_width": 4 }, { - "indent_style": { - "Space": 2 - }, - "tab_width": 8 + "indent_style": "Space", + "indent_width": 2 }, { "indent_style": "Tab", - "tab_width": 8 + "indent_width": 8 }, { "indent_style": "Tab", - "tab_width": 4 + "indent_width": 4 } ] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py index 572518635e..1ea6d78e15 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py @@ -222,3 +222,170 @@ x = ( x = ( () - () # ) + + +# Avoid unnecessary parentheses around multiline strings. +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" % ( + self.base_url, + date.today(), +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + # Needs parentheses + % ( + self.base_url, + date.today(), + ) +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + # Needs parentheses + ( + self.base_url, + date.today(), + ) +) + + +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" + a.call.expression( + self.base_url, + date.today(), +) + +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" + sssssssssssssssssssssssssssssssssssssssssooooo * looooooooooooooooooooooooooooooongggggggggggg + +call(arg1, arg2, """ +short +""", arg3=True) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + ( + self.base_url + ) +) + + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + ( + # Needs parentheses + self.base_url + ) +) + + +rowuses = [(1 << j) | # column ordinal + (1 << (n + i-j + n-1)) | # NW-SE ordinal + (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal + for j in rangen] + +rowuses = [((1 << j) # column ordinal + )| + ( + # comment + (1 << (n + i-j + n-1))) | # NW-SE ordinal + (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal + for j in rangen] + +skip_bytes = ( + header.timecnt * 5 # Transition times and types + + header.typecnt * 6 # Local time type records + + header.charcnt # Time zone designations + + header.leapcnt * 8 # Leap second records + + header.isstdcnt # Standard/wall indicators + + header.isutcnt # UT/local indicators +) + + +if ( + (1 + 2) # test + or (3 + 4) # other + or (4 + 5) # more +): + pass + + +if ( + (1 and 2) # test + + (3 and 4) # other + + (4 and 5) # more +): + pass + + +if ( + (1 + 2) # test + < (3 + 4) # other + > (4 + 5) # more +): + pass + + z = ( + a + + + # a: extracts this comment + ( + # b: and this comment + ( + # c: formats it as part of the expression + x and y + ) + ) + ) + +z = ( + ( + + ( + + x and y + # a: formats it as part of the expression + + ) + # b: extracts this comment + + ) + # c: and this comment + + a +) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py index 9f56e06e4a..1901fa3e18 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py @@ -84,6 +84,15 @@ self._assert_skipping( + x ) +( + b + c + d + + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + f"bbbbbb{z}bbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" + % aaaaaaaaaaaa + + x +) + ( b < c > d < "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -118,3 +127,65 @@ def test3(): "(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) " "THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)" ) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3 + +c = (a + + # test leading binary comment + "a" "b" * b +) + +c = (a * + # test leading comment + "a" "b" + b + ) + +c = (a + + # test trailing comment + "a" "b" * b + ) + +c = (a + + + "a" "b" # test trailing comment + * b + ) + +c = (a + * + "a" "b" # test trailing binary comment + + b + ) + +c = (a + * + "a" "b" + + # test trailing operator comment + b + ) + +c = (a + * + "a" "b" + + + # test trailing operator comment + b + ) + +c = ("a" "b" + + # test leading binary comment + "a" "b" + ) + +( + b + c + d + + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + + "cccccccccccccccccccccccccc" + "dddddddddddddddddddddddddd" + % aaaaaaaaaaaa + + x +) + +"a" "b" "c" + "d" "e" + "f" "g" + "h" "i" "j" +class EC2REPATH: + f.write ("Pathway name" + "\t" "Database Identifier" + "\t" "Source database" + "\n") + diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py index c85f6a4daa..0293ff7da6 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py @@ -102,3 +102,86 @@ def test(): and {k.lower(): v for k, v in self.items()} == {k.lower(): v for k, v in other.items()} ) + + + +if "_continue" in request.POST or ( + # Redirecting after "Save as new". + "_saveasnew" in request.POST + and self.save_as_continue + and self.has_change_permission(request, obj) +): + pass + + +if True: + if False: + if True: + if ( + self.validate_max + and self.total_form_count() - len(self.deleted_forms) > self.max_num + ) or self.management_form.cleaned_data[ + TOTAL_FORM_COUNT + ] > self.absolute_max: + pass + + +if True: + if ( + reference_field_name is None + or + # Unspecified to_field(s). + to_fields is None + or + # Reference to primary key. + ( + None in to_fields + and (reference_field is None or reference_field.primary_key) + ) + or + # Reference to field. + reference_field_name in to_fields + ): + pass + + +field = opts.get_field(name) +if ( + field.is_relation + and + # Generic foreign keys OR reverse relations + ((field.many_to_one and not field.related_model) or field.one_to_many) +): + pass + + +if True: + return ( + filtered.exists() + and + # It may happen that the object is deleted from the DB right after + # this check, causing the subsequent UPDATE to return zero matching + # rows. The same result can occur in some rare cases when the + # database returns zero despite the UPDATE being executed + # successfully (a row is matched and updated). In order to + # distinguish these two cases, the object's existence in the + # database is again checked for if the UPDATE query returns 0. + (filtered._update(values) > 0 or filtered.exists()) + ) + + +if (self._proc is not None + # has the child process finished? + and self._returncode is None + # the child process has finished, but the + # transport hasn't been notified yet? + and self._proc.poll() is None): + pass + +if (self._proc + # has the child process finished? + * self._returncode + # the child process has finished, but the + # transport hasn't been notified yet? + + self._proc.poll()): + pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py index 5dc7d1af44..7123bd85d4 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py @@ -80,6 +80,21 @@ f( # oddly placed own line comment dict() ) +f( + session, + b=1, + **(# oddly placed own line comment + dict() + ) +) +f( + session, + b=1, + **( + # oddly placed own line comment + dict() + ) +) # Don't add a magic trailing comma when there is only one entry # Minimized from https://github.com/django/django/blob/7eeadc82c2f7d7a778e3bb43c34d642e6275dacf/django/contrib/admin/checks.py#L674-L681 @@ -205,3 +220,48 @@ aaa = ( () .bbbbbbbbbbbbbbbb ) + +# Comments around keywords +f(x= # comment + 1) + +f(x # comment + = + 1) + +f(x= + # comment + 1) + +f(x=(# comment + 1 +)) + + +f(x=( + # comment + 1 +)) + +args = [2] +args2 = [3] +kwargs = {"4": 5} + +# https://github.com/astral-sh/ruff/issues/6498 +f(a=1, *args, **kwargs) +f(*args, a=1, **kwargs) +f(*args, a=1, *args2, **kwargs) +f( # a + * # b + args + # c + , # d + a=1, + # e + * # f + args2 + # g + ** # h + kwargs, +) + diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py index 88b6da20bd..99dd8f4b14 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py @@ -111,3 +111,70 @@ ct_match = ( ct_match = ( (aaaaaaaaaaaaaaaa) == self.get_content_type[obj, rel_obj, using, instance._state.db].id ) + +# comments + +c = ( + 1 > # 1 + # 2 + 3 # 3 + > # 4 + 5 # 5 + # 6 +) + +# Implicit strings and comments + +assert ( + "One or more packages has an associated PGP signature; these will " + "be silently ignored by the index" + in caplog.messages +) + +( + b < c > d < + f"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" + % aaaaaaaaaaaa + > x +) + +c = (a > + # test leading binary comment + "a" "b" * b + ) + +c = (a * + # test leading comment + "a" "b" > b + ) + +c = (a + > # test trailing comment + "a" "b" * b + ) + +c = (a + > + "a" "b" # test trailing comment + * b + ) + +c = (a + > + "a" "b" # test trailing binary comment + + b + ) + + +c = (a > + # test leading binary comment + "a" "b" * b + ) + +c = (a * + # test leading comment + "a" "b" > b + ) + diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py index a60efa1cdd..f808f11e94 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py @@ -33,3 +33,27 @@ result_f = ( # comment '' ) + +( + f'{1}' # comment + f'{2}' +) + +( + f'{1}' + f'{2}' # comment +) + +( + 1, ( # comment + f'{2}' + ) +) + +( + ( + f'{1}' + # comment + ), + 2 +) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py index 7baf9602e7..1fa75f6986 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py @@ -16,6 +16,11 @@ f((1) for _ in (a)) # combination of the two above f(((1) for _ in (a))) +bases = tuple( + (base._meta.label_lower if hasattr(base, "_meta") else base) + for base in flattened_bases +) + # black keeps these atm, but intends to remove them in the future: # https://github.com/psf/black/issues/2943 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py index df4c488603..b3fc460e44 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py @@ -39,3 +39,72 @@ d1 = [ ("b") else # 2 ("c") ] + +e1 = ( + a + if True # 1 + else b + if False # 2 + else c +) + + +# Flattening nested if-expressions. +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + (NamedValuesListIterable + if named + else FlatValuesListIterable) + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else (FlatValuesListIterable + if flat + else ValuesListIterable) + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable(1,) + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else (FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + if flat + else ValuesListIterable) + ) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py index 32a57bed4a..12e167d413 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py @@ -118,3 +118,38 @@ lambda a, /, c: a # 4 None # 5 ) + +( + lambda + # comment + *x: x +) + +( + lambda + # comment 1 + * + # comment 2 + x: + # comment 3 + x +) + +( + lambda # comment 1 + * # comment 2 + x: # comment 3 + x +) + +lambda *x\ + :x + +( + lambda + # comment + *\ + x: x +) + + diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py index 9c6c5a6d5b..af5273484d 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py @@ -66,3 +66,6 @@ g2 = ( # a h1 = ((((1, 2)))) h2 = ((((1, "qweiurpoiqwurepqiurpqirpuqoiwrupqoirupqoirupqoiurpqiorupwqiourpqurpqurpqurpqurpqurpqurüqurqpuriq")))) h3 = 1, "qweiurpoiqwurepqiurpqirpuqoiwrupqoirupqoirupqoiurpqiorupwqiourpqurpqurpqurpqurpqurpqurüqurqpuriq" + +i1 = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # This should break + diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.options.json index e662f72879..3bcc422e22 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.options.json +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.options.json @@ -1,8 +1,10 @@ [ { - "indent_style": { "Space": 4 } + "indent_style": "Space", + "indent_width": 4 }, { - "indent_style": { "Space": 2 } + "indent_style": "Space", + "indent_width": 2 } ] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.options.json index 8f229d10a5..ae4c01b250 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.options.json +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.options.json @@ -1,9 +1,11 @@ [ { - "indent_style": { "Space": 4 } + "indent_style": "Space", + "indent_width": 4 }, { - "indent_style": { "Space": 1 } + "indent_style": "Space", + "indent_width": 1 }, { "indent_style": "Tab" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py index c0cb6c1849..e69de29bb2 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py @@ -1,55 +0,0 @@ -def test(): - # fmt: off - a_very_small_indent - ( -not_fixed - ) - - if True: - pass - more - # fmt: on - - formatted - - def test(): - a_small_indent - # fmt: off -# fix under-indented comments - (or_the_inner_expression + -expressions - ) - - if True: - pass - # fmt: on - - -# fmt: off -def test(): - pass - - # It is necessary to indent comments because the following fmt: on comment because it otherwise becomes a trailing comment - # of the `test` function if the "proper" indentation is larger than 2 spaces. - # fmt: on - -disabled + formatting; - -# fmt: on - -formatted; - -def test(): - pass - # fmt: off - """A multiline strings - that should not get formatted""" - - "A single quoted multiline \ - string" - - disabled + formatting; - -# fmt: on - -formatted; diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.options.json index e40788162c..769ca99e87 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.options.json +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.options.json @@ -1,9 +1,11 @@ [ { - "indent_style": { "Space": 4 } + "indent_style": "Space", + "indent_width": 4 }, { - "indent_style": { "Space": 2 } + "indent_style": "Space", + "indent_width": 2 }, { "indent_style": "Tab" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py new file mode 100644 index 0000000000..f73a7077ea --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py @@ -0,0 +1,36 @@ +def func(): + pass +# fmt: off +x = 1 +# fmt: on + + +# fmt: off +def func(): + pass +# fmt: on +x = 1 + + +# fmt: off +def func(): + pass +# fmt: on +def func(): + pass + + +# fmt: off +def func(): + pass +# fmt: off +def func(): + pass + + +# fmt: on +def func(): + pass +# fmt: on +def func(): + pass diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment1.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment1.py new file mode 100644 index 0000000000..5b52d9b5c5 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment1.py @@ -0,0 +1,3 @@ +__all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] + +# Shared types throughout the stub diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment2.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment2.py new file mode 100644 index 0000000000..15d2886e54 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment2.py @@ -0,0 +1,2 @@ +__all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] +# Shared types throughout the stub diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.py new file mode 100644 index 0000000000..0d33408ecb --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.py @@ -0,0 +1,161 @@ +### +# Blank lines around functions +### + +x = 1 + +# comment + +def f(): + pass + + +if True: + x = 1 + +# comment + +def f(): + pass + + +x = 1 + + + +# comment + +def f(): + pass + + +x = 1 + + + +# comment +def f(): + pass + + +x = 1 + +# comment + +# comment +def f(): + pass + +x = 1 + +# comment +# comment + +def f(): + pass + +x = 1 + +# comment +# comment +def f(): + pass + + +x = 1 + + +# comment + + + +# comment + + + +def f(): + pass +# comment + + +def f(): + pass + +# comment + +def f(): + pass + + +# comment + +### +# Blank lines around imports. +### + +def f(): + import x + # comment + import y + + +def f(): + import x + + # comment + import y + + +def f(): + import x + # comment + + import y + + +def f(): + import x + # comment + + + import y + + +def f(): + import x + + + # comment + import y + + +def f(): + import x + + # comment + + import y + + +def f(): + import x # comment + # comment + + import y + + +def f(): pass # comment +# comment + +x = 1 + + +def f(): + pass + + + + +# comment + +x = 1 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/call_chains.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/call_chains.py index c5d806e27e..0b49a1dd11 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/call_chains.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/parentheses/call_chains.py @@ -161,3 +161,58 @@ max_message_id = ( max_message_id = ( Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id() ) + +# Parentheses with fluent style within and outside of the parentheses. +( + ( + df1_aaaaaaaaaaaa.merge() + ) + .groupby(1,) + .sum() +) + +( + ( # foo + df1_aaaaaaaaaaaa.merge() + ) + .groupby(1,) + .sum() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + ) + .sum() +) + + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + ) + .sum() + .bar() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + .bar() + ) + .sum() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + .bar() + ) + .sum() + .baz() +) + diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py index 442441465e..296b4a79ad 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py @@ -206,3 +206,19 @@ class TestTypeParams[Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa class TestTypeParams[A, B, C](meta=Aaaaaaaaaaaaaaaaaaaaaa): pass + + +# Regression test for: https://github.com/astral-sh/ruff/pull/7001 +class QuerySet(AltersData): + """Represent a lazy database lookup for a set of objects.""" + + def as_manager(cls): + # Address the circular dependency between `Queryset` and `Manager`. + from django.db.models.manager import Manager + + manager = Manager.from_queryset(cls)() + manager._built_with_as_manager = True + return manager + + as_manager.queryset_only = True + as_manager = classmethod(as_manager) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/comments.pyi b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/comments.pyi new file mode 100644 index 0000000000..fe1713355a --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/comments.pyi @@ -0,0 +1,7 @@ +class SupportsAnext: + def __anext__(self): ... + +# Comparison protocols + +class SupportsDunderLT: + def __init__(self): ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/nesting.pyi b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/nesting.pyi new file mode 100644 index 0000000000..8fe78c4e5c --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/nesting.pyi @@ -0,0 +1,31 @@ +"""Tests specifically for https://github.com/psf/black/issues/3861""" + +import sys + + +class OuterClassOrOtherSuite: + class Nested11: + class Nested12: + assignment = 1 + def function_definition(self): ... + + def f1(self) -> str: ... + + class Nested21: + class Nested22: + def function_definition(self): ... + assignment = 1 + + def f2(self) -> str: ... + +if sys.version_info > (3, 7): + if sys.platform == "win32": + assignment = 1 + def function_definition(self): ... + + def f1(self) -> str: ... + if sys.platform != "win32": + def function_definition(self): ... + assignment = 1 + + def f2(self) -> str: ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/suite.pyi b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/suite.pyi new file mode 100644 index 0000000000..c14b239354 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/suite.pyi @@ -0,0 +1,149 @@ +"""Tests for empty line rules in stub files, mostly inspired by typeshed. +The rules are a list of nested exceptions. See also +https://github.com/psf/black/blob/c160e4b7ce30c661ac4f2dfa5038becf1b8c5c33/src/black/lines.py#L576-L744 +""" + +import sys +from typing import Self, TypeAlias, final + +if sys.version_info >= (3, 8): + class InnerClass1: ... + + class InnerClass2: + def a(self): ... + + class InnerClass3: + def a(self): ... + + class InnerClass4: ... + details: int + def f1(self, hresult: int, text: str | None, detail: int) -> None: ... + details: int + def f2(self, hresult: int, text: str | None, detail: int) -> None: ... + @final + class DecoratorInsteadOfEmptyLine: ... + + def open(device: str) -> None: ... + + # oss_mixer_device return type + def openmixer(device: str = ...) -> None: ... + def open2(device: str) -> None: ... + # oss_mixer_device2 return type + def openmixer2(device: str = ...) -> None: ... + +else: + class Slice1: ... + _Slice1: TypeAlias = Slice1 + + class Slice2: ... + _Slice2: TypeAlias = Slice2 + +class NoEmptyLinesBetweenFunctions: + def multi_line_but_only_ellipsis( + self, + mandatory_release: float | None, + ) -> None: ... + def only_ellipsis1(self) -> float: ... + def only_ellipsis2(self) -> float | None: ... + def has_impl1(self): + print(self) + return 1 + + def has_impl2(self): + print(self) + return 2 + + def no_impl4(self): ... + +class NoEmptyLinesBetweenField: + field1: int + field2: ( + # type + int + ) + field3 = 3 + field4 = ( + 1, + 2, + ) + field5 = 5 + +class FieldAndFunctionsWithOptionalEmptyLines: + details1: int + def f1(self, hresult: int, text: str | None, detail: int) -> None: ... + details2: int + def f2(self, hresult: int, text: str | None, detail: int) -> None: ... + details3: int + +class NewlinesBetweenStubInnerClasses: + def f1(self): ... + + class InnerClass1: ... + class InnerClass2: ... + + def f2(self): ... + + class InnerClass3: ... + class InnerClass4: ... + field = 1 + + class InnerClass3: ... + class InnerClass4: ... + + def f3(self): ... + @final + class DecoratorInsteadOfEmptyLine: ... + + @final + class DecoratorStillEmptyLine: ... + +class NewlinesBetweenInnerClasses: + class InnerClass1: ... + + class InnerClass2: + def a(self): ... + + class InnerClass3: + def a(self): ... + + class InnerClass4: ... + + class InnerClass5: + def a(self): ... + field1 = 1 + + class InnerClass6: + def a(self): ... + + def f1(self): ... + + class InnerClass7: + def a(self): ... + print("hi") + + class InnerClass8: + def a(self): ... + +class ComplexStatements: + # didn't match the name in the C implementation, + # meaning it is only *safe* to pass it as a keyword argument on 3.12+ + if sys.version_info >= (3, 12): + @classmethod + def fromtimestamp(cls, timestamp: float, tz: float | None = ...) -> Self: ... + else: + @classmethod + def fromtimestamp(cls, __timestamp: float, tz: float | None = ...) -> Self: ... + + @classmethod + def utcfromtimestamp(cls, __t: float) -> Self: ... + if sys.version_info >= (3, 8): + @classmethod + def now(cls, tz: float | None = None) -> Self: ... + else: + @classmethod + def now(cls, tz: None = None) -> Self: ... + @classmethod + def now2(cls, tz: float) -> Self: ... + + @classmethod + def utcnow(cls) -> Self: ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/top_level.pyi b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/top_level.pyi new file mode 100644 index 0000000000..fe08563fff --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/top_level.pyi @@ -0,0 +1,17 @@ +from typing import final + + +def count1(): ... +def count2(): ... +@final +def count3(): ... +@final +class LockType1: ... + +def count4(): ... + +class LockType2: ... +class LockType3: ... + +@final +class LockType4: ... diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.options.json index 772a750723..fb4a15ba44 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.options.json +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.options.json @@ -1,8 +1,11 @@ [ { - "tab_width": 2 + "indent_width": 2 }, { - "tab_width": 4 + "indent_width": 4 + }, + { + "indent_width": 8 } ] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.py index 33276e786d..e0c991d14c 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.py @@ -1,8 +1,8 @@ # Fits with tab width 2 -1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567890" +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567") # Fits with tab width 4 -1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345678" +(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345") # Fits with tab width 8 -1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234" +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901") diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/trailing_comments.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/trailing_comments.py new file mode 100644 index 0000000000..86c33a0f4e --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/trailing_comments.py @@ -0,0 +1,29 @@ +# Pragma reserved width fixtures +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # type: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pyright: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pylint: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # nocoverage: This should break + + +# Pragma fixtures for non-breaking space (lead by NBSP) +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # type: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pyright: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pylint: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # nocoverage: This should break + + +# As of adding this fixture Black adds a space before the non-breaking space if part of a type pragma. +# https://github.com/psf/black/blob/b4dca26c7d93f930bbd5a7b552807370b60d4298/src/black/comments.py#L122-L129 +i = "" #  type: Add space before leading NBSP followed by spaces +i = "" #type: A space is added +i = "" #  type: Add space before leading NBSP followed by a space +i = "" # type: Add space before leading NBSP +i = "" #  type: Add space before two leading NBSP + + +# A noqa as `#\u{A0}\u{A0}noqa` becomes `# \u{A0}noqa` +i = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" #  noqa diff --git a/crates/ruff_python_formatter/src/builders.rs b/crates/ruff_python_formatter/src/builders.rs index 40327ce7da..fa4e30ea79 100644 --- a/crates/ruff_python_formatter/src/builders.rs +++ b/crates/ruff_python_formatter/src/builders.rs @@ -27,9 +27,9 @@ impl<'ast> Format> for ParenthesizeIfExpands<'_, 'ast> { write!( f, [group(&format_args![ - if_group_breaks(&text("(")), + if_group_breaks(&token("(")), soft_block_indent(&Arguments::from(&self.inner)), - if_group_breaks(&text(")")), + if_group_breaks(&token(")")), ])] ) } @@ -152,7 +152,7 @@ impl<'fmt, 'ast, 'buf> JoinCommaSeparatedBuilder<'fmt, 'ast, 'buf> { { self.result = self.result.and_then(|_| { if self.entries.is_one_or_more() { - write!(self.fmt, [text(","), separator])?; + write!(self.fmt, [token(","), separator])?; } self.entries = self.entries.next(node.end()); @@ -204,7 +204,7 @@ impl<'fmt, 'ast, 'buf> JoinCommaSeparatedBuilder<'fmt, 'ast, 'buf> { || self.trailing_comma == TrailingComma::OneOrMore || self.entries.is_more_than_one() { - if_group_breaks(&text(",")).fmt(self.fmt)?; + if_group_breaks(&token(",")).fmt(self.fmt)?; } if magic_trailing_comma { diff --git a/crates/ruff_python_formatter/src/cli.rs b/crates/ruff_python_formatter/src/cli.rs index fff146fdb9..6b79bacdbd 100644 --- a/crates/ruff_python_formatter/src/cli.rs +++ b/crates/ruff_python_formatter/src/cli.rs @@ -9,7 +9,9 @@ use ruff_formatter::SourceCode; use ruff_python_index::CommentRangesBuilder; use ruff_python_parser::lexer::lex; use ruff_python_parser::{parse_tokens, Mode}; +use ruff_text_size::Ranged; +use crate::comments::collect_comments; use crate::{format_node, PyFormatOptions}; #[derive(ValueEnum, Clone, Debug)] @@ -64,6 +66,29 @@ pub fn format_and_debug_print(input: &str, cli: &Cli, source_type: &Path) -> Res println!("{}", formatted.document().display(SourceCode::new(input))); } if cli.print_comments { + // Print preceding, following and enclosing nodes + let source_code = SourceCode::new(input); + let decorated_comments = collect_comments(&python_ast, source_code, &comment_ranges); + if !decorated_comments.is_empty() { + println!("# Comment decoration: Range, Preceding, Following, Enclosing, Comment"); + } + for comment in decorated_comments { + println!( + "{:?}, {:?}, {:?}, {:?}, {:?}", + comment.slice().range(), + comment + .preceding_node() + .map(|node| (node.kind(), node.range())), + comment + .following_node() + .map(|node| (node.kind(), node.range())), + ( + comment.enclosing_node().kind(), + comment.enclosing_node().range() + ), + comment.slice().text(SourceCode::new(input)), + ); + } println!( "{:#?}", formatted.context().comments().debug(SourceCode::new(input)) diff --git a/crates/ruff_python_formatter/src/comments/format.rs b/crates/ruff_python_formatter/src/comments/format.rs index 4084d76a28..55f374bfe4 100644 --- a/crates/ruff_python_formatter/src/comments/format.rs +++ b/crates/ruff_python_formatter/src/comments/format.rs @@ -1,8 +1,10 @@ -use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; +use std::borrow::Cow; -use ruff_formatter::{format_args, write, FormatError, SourceCode}; +use ruff_formatter::{format_args, write, FormatError, FormatOptions, SourceCode}; use ruff_python_ast::node::{AnyNodeRef, AstNode}; +use ruff_python_ast::PySourceType; use ruff_python_trivia::{lines_after, lines_after_ignoring_trivia, lines_before}; +use ruff_text_size::{Ranged, TextLen, TextRange}; use crate::comments::{CommentLinePosition, SourceComment}; use crate::context::NodeLevel; @@ -29,29 +31,30 @@ pub(crate) enum FormatLeadingComments<'a> { impl Format> for FormatLeadingComments<'_> { fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { - let comments = f.context().comments().clone(); + fn write_leading_comments( + comments: &[SourceComment], + f: &mut PyFormatter, + ) -> FormatResult<()> { + for comment in comments.iter().filter(|comment| comment.is_unformatted()) { + let lines_after_comment = lines_after(comment.end(), f.context().source()); + write!( + f, + [format_comment(comment), empty_lines(lines_after_comment)] + )?; - let leading_comments = match self { - FormatLeadingComments::Node(node) => comments.leading(*node), - FormatLeadingComments::Comments(comments) => comments, - }; + comment.mark_formatted(); + } - for comment in leading_comments - .iter() - .filter(|comment| comment.is_unformatted()) - { - let slice = comment.slice(); - - let lines_after_comment = lines_after(slice.end(), f.context().source()); - write!( - f, - [format_comment(comment), empty_lines(lines_after_comment)] - )?; - - comment.mark_formatted(); + Ok(()) } - Ok(()) + match self { + FormatLeadingComments::Node(node) => { + let comments = f.context().comments().clone(); + write_leading_comments(comments.leading(*node), f) + } + FormatLeadingComments::Comments(comments) => write_leading_comments(comments, f), + } } } @@ -83,7 +86,7 @@ impl Format> for FormatLeadingAlternateBranchComments<'_> { if let Some(first_leading) = self.comments.first() { // Leading comments only preserves the lines after the comment but not before. // Insert the necessary lines. - if lines_before(first_leading.slice().start(), f.context().source()) > 1 { + if lines_before(first_leading.start(), f.context().source()) > 1 { write!(f, [empty_line()])?; } @@ -100,45 +103,22 @@ impl Format> for FormatLeadingAlternateBranchComments<'_> { } } -/// Formats the trailing comments of `node` -pub(crate) fn trailing_node_comments(node: &T) -> FormatTrailingComments -where - T: AstNode, -{ - FormatTrailingComments::Node(node.as_any_node_ref()) -} - /// Formats the passed comments as trailing comments pub(crate) fn trailing_comments(comments: &[SourceComment]) -> FormatTrailingComments { - FormatTrailingComments::Comments(comments) + FormatTrailingComments(comments) } -pub(crate) enum FormatTrailingComments<'a> { - Node(AnyNodeRef<'a>), - Comments(&'a [SourceComment]), -} +pub(crate) struct FormatTrailingComments<'a>(&'a [SourceComment]); impl Format> for FormatTrailingComments<'_> { fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { - let comments = f.context().comments().clone(); - - let trailing_comments = match self { - FormatTrailingComments::Node(node) => comments.trailing(*node), - FormatTrailingComments::Comments(comments) => comments, - }; - let mut has_trailing_own_line_comment = false; - for trailing in trailing_comments - .iter() - .filter(|comment| comment.is_unformatted()) - { - let slice = trailing.slice(); - + for trailing in self.0.iter().filter(|comment| comment.is_unformatted()) { has_trailing_own_line_comment |= trailing.line_position().is_own_line(); if has_trailing_own_line_comment { - let lines_before_comment = lines_before(slice.start(), f.context().source()); + let lines_before_comment = lines_before(trailing.start(), f.context().source()); // A trailing comment at the end of a body or list // ```python @@ -155,19 +135,22 @@ impl Format> for FormatTrailingComments<'_> { empty_lines(lines_before_comment), format_comment(trailing) ], + // Reserving width isn't necessary because we don't split + // comments and the empty lines expand any enclosing group. 0 ), expand_parent() ] )?; } else { - write!( - f, - [ - line_suffix(&format_args![space(), space(), format_comment(trailing)], 0), - expand_parent() - ] - )?; + // A trailing comment at the end of a line has a reserved width to + // consider during line measurement. + // ```python + // tup = ( + // "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + // ) # Some comment + // ``` + trailing_end_of_line_comment(trailing).fmt(f)?; } trailing.mark_formatted(); @@ -223,7 +206,7 @@ impl Format> for FormatDanglingComments<'_> { f, [ format_comment(comment), - empty_lines(lines_after(comment.slice().end(), f.context().source())) + empty_lines(lines_after(comment.end(), f.context().source())) ] )?; @@ -266,13 +249,7 @@ impl Format> for FormatDanglingOpenParenthesisComments<'_> { "Expected dangling comment to be at the end of the line" ); - write!( - f, - [ - line_suffix(&format_args!(space(), space(), format_comment(comment)), 0), - expand_parent() - ] - )?; + trailing_end_of_line_comment(comment).fmt(f)?; comment.mark_formatted(); } @@ -295,57 +272,18 @@ pub(crate) struct FormatComment<'a> { impl Format> for FormatComment<'_> { fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { let slice = self.comment.slice(); - let comment_text = slice.text(SourceCode::new(f.context().source())); + let source = SourceCode::new(f.context().source()); - let trimmed = comment_text.trim_end(); - let trailing_whitespace_len = comment_text.text_len() - trimmed.text_len(); + let normalized_comment = normalize_comment(self.comment, source)?; - let Some(content) = trimmed.strip_prefix('#') else { - return Err(FormatError::syntax_error( - "Didn't find expected comment token `#`", - )); - }; - - // Fast path for correctly formatted comments: - // * Start with a `#` and are followed by a space - // * Have no trailing whitespace. - if trailing_whitespace_len == TextSize::new(0) && content.starts_with(' ') { - return source_text_slice(slice.range(), ContainsNewlines::No).fmt(f); - } - - write!(f, [source_position(slice.start()), text("#")])?; - - // Starts with a non breaking space - let start_offset = - if content.starts_with('\u{A0}') && !content.trim_start().starts_with("type:") { - // Replace non-breaking space with a space (if not followed by a normal space) - "#\u{A0}".text_len() - } else { - '#'.text_len() - }; - - // Add a space between the `#` and the text if the source contains none. - if !content.is_empty() && !content.starts_with([' ', '!', ':', '#', '\'']) { - write!(f, [space()])?; - } - - let start = slice.start() + start_offset; - let end = slice.end() - trailing_whitespace_len; - - write!( - f, - [ - source_text_slice(TextRange::new(start, end), ContainsNewlines::No), - source_position(slice.end()) - ] - ) + format_normalized_comment(normalized_comment, slice.range()).fmt(f) } } -// Helper that inserts the appropriate number of empty lines before a comment, depending on the node level. -// Top level: Up to two empty lines -// parenthesized: A single empty line -// other: Up to a single empty line +/// Helper that inserts the appropriate number of empty lines before a comment, depending on the node level: +/// - Top-level: Up to two empty lines. +/// - Parenthesized: A single empty line. +/// - Otherwise: Up to a single empty line. pub(crate) const fn empty_lines(lines: u32) -> FormatEmptyLines { FormatEmptyLines { lines } } @@ -376,3 +314,216 @@ impl Format> for FormatEmptyLines { } } } + +/// A helper that constructs a formattable element using a reserved-width line-suffix +/// for normalized comments. +/// +/// * Black normalization of `SourceComment`. +/// * Line suffix with reserved width for the final, normalized content. +/// * Expands parent node. +pub(crate) const fn trailing_end_of_line_comment( + comment: &SourceComment, +) -> FormatTrailingEndOfLineComment { + FormatTrailingEndOfLineComment { comment } +} + +pub(crate) struct FormatTrailingEndOfLineComment<'a> { + comment: &'a SourceComment, +} + +impl Format> for FormatTrailingEndOfLineComment<'_> { + fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { + let slice = self.comment.slice(); + let source = SourceCode::new(f.context().source()); + + let normalized_comment = normalize_comment(self.comment, source)?; + + // Trim the normalized comment to detect excluded pragmas (strips NBSP). + let trimmed = strip_comment_prefix(&normalized_comment)?.trim_start(); + + let is_pragma = if let Some((maybe_pragma, _)) = trimmed.split_once(':') { + matches!(maybe_pragma, "noqa" | "type" | "pyright" | "pylint") + } else { + trimmed.starts_with("noqa") + }; + + // Don't reserve width for excluded pragma comments. + let reserved_width = if is_pragma { + 0 + } else { + // Start with 2 because of the two leading spaces. + let width = 2u32.saturating_add( + TextWidth::from_text(&normalized_comment, f.options().indent_width()) + .width() + .expect("Expected comment not to contain any newlines") + .value(), + ); + + width + }; + + write!( + f, + [ + line_suffix( + &format_args![ + space(), + space(), + format_normalized_comment(normalized_comment, slice.range()) + ], + reserved_width + ), + expand_parent() + ] + ) + } +} + +/// A helper that constructs formattable normalized comment text as efficiently as +/// possible. +/// +/// * If the content is unaltered then format with source text slice strategy and no +/// unnecessary allocations. +/// * If the content is modified then make as few allocations as possible and use +/// a dynamic text element at the original slice's start position. +pub(crate) const fn format_normalized_comment( + comment: Cow<'_, str>, + range: TextRange, +) -> FormatNormalizedComment<'_> { + FormatNormalizedComment { comment, range } +} + +pub(crate) struct FormatNormalizedComment<'a> { + comment: Cow<'a, str>, + range: TextRange, +} + +impl Format> for FormatNormalizedComment<'_> { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + match self.comment { + Cow::Borrowed(borrowed) => { + source_text_slice(TextRange::at(self.range.start(), borrowed.text_len())).fmt(f) + } + + Cow::Owned(ref owned) => { + write!( + f, + [ + text(owned, Some(self.range.start())), + source_position(self.range.end()) + ] + ) + } + } + } +} + +/// A helper for normalizing comments efficiently. +/// +/// * Return as fast as possible without making unnecessary allocations. +/// * Trim any trailing whitespace. +/// * Normalize for a leading '# '. +/// * Retain non-breaking spaces for 'type:' pragmas by leading with '# \u{A0}'. +fn normalize_comment<'a>( + comment: &'a SourceComment, + source: SourceCode<'a>, +) -> FormatResult> { + let slice = comment.slice(); + let comment_text = slice.text(source); + + let trimmed = comment_text.trim_end(); + + let content = strip_comment_prefix(trimmed)?; + + if content.is_empty() { + return Ok(Cow::Borrowed("#")); + } + + // Fast path for correctly formatted comments: + // * Start with a `# '. + // * Have no trailing whitespace. + if content.starts_with([' ', '!', ':', '#', '\'']) { + return Ok(Cow::Borrowed(trimmed)); + } + + if content.starts_with('\u{A0}') { + let trimmed = content.trim_start_matches('\u{A0}'); + + if trimmed.trim_start().starts_with("type:") { + // Black adds a space before the non-breaking space if part of a type pragma. + Ok(Cow::Owned(std::format!("# {content}"))) + } else if trimmed.starts_with(' ') { + // Black replaces the non-breaking space with a space if followed by a space. + Ok(Cow::Owned(std::format!("# {trimmed}"))) + } else { + // Otherwise we replace the first non-breaking space with a regular space. + Ok(Cow::Owned(std::format!("# {}", &content["\u{A0}".len()..]))) + } + } else { + Ok(Cow::Owned(std::format!("# {}", content.trim_start()))) + } +} + +/// A helper for stripping '#' from comments. +fn strip_comment_prefix(comment_text: &str) -> FormatResult<&str> { + let Some(content) = comment_text.strip_prefix('#') else { + return Err(FormatError::syntax_error( + "Didn't find expected comment token `#`", + )); + }; + + Ok(content) +} + +/// Format the empty lines between a node and its trailing comments. +/// +/// For example, given: +/// ```python +/// def func(): +/// ... +/// # comment +/// ``` +/// +/// This builder will insert two empty lines before the comment. +/// ``` +pub(crate) fn empty_lines_before_trailing_comments<'a>( + f: &PyFormatter, + comments: &'a [SourceComment], +) -> FormatEmptyLinesBeforeTrailingComments<'a> { + // Black has different rules for stub vs. non-stub and top level vs. indented + let empty_lines = match (f.options().source_type(), f.context().node_level()) { + (PySourceType::Stub, NodeLevel::TopLevel) => 1, + (PySourceType::Stub, _) => 0, + (_, NodeLevel::TopLevel) => 2, + (_, _) => 1, + }; + + FormatEmptyLinesBeforeTrailingComments { + comments, + empty_lines, + } +} + +#[derive(Copy, Clone, Debug)] +pub(crate) struct FormatEmptyLinesBeforeTrailingComments<'a> { + /// The trailing comments of the node. + comments: &'a [SourceComment], + /// The expected number of empty lines before the trailing comments. + empty_lines: u32, +} + +impl Format> for FormatEmptyLinesBeforeTrailingComments<'_> { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + if let Some(comment) = self + .comments + .iter() + .find(|comment| comment.line_position().is_own_line()) + { + let actual = lines_before(comment.start(), f.context().source()).saturating_sub(1); + for _ in actual..self.empty_lines { + write!(f, [empty_line()])?; + } + } + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/comments/mod.rs b/crates/ruff_python_formatter/src/comments/mod.rs index 57ded7ba08..4d6eac168c 100644 --- a/crates/ruff_python_formatter/src/comments/mod.rs +++ b/crates/ruff_python_formatter/src/comments/mod.rs @@ -87,28 +87,28 @@ //! //! It is possible to add an additional optional label to [`SourceComment`] If ever the need arises to distinguish two *dangling comments* in the formatting logic, -use ruff_text_size::{Ranged, TextRange}; use std::cell::Cell; use std::fmt::Debug; use std::rc::Rc; -use ruff_python_ast::Mod; - pub(crate) use format::{ dangling_comments, dangling_node_comments, dangling_open_parenthesis_comments, leading_alternate_branch_comments, leading_comments, leading_node_comments, trailing_comments, - trailing_node_comments, }; use ruff_formatter::{SourceCode, SourceCodeSlice}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::visitor::preorder::{PreorderVisitor, TraversalSignal}; +use ruff_python_ast::Mod; use ruff_python_index::CommentRanges; use ruff_python_trivia::PythonWhitespace; +use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::debug::{DebugComment, DebugComments}; use crate::comments::map::{LeadingDanglingTrailing, MultiMap}; use crate::comments::node_key::NodeRefEqualityKey; -use crate::comments::visitor::CommentsVisitor; +use crate::comments::visitor::{CommentsMapBuilder, CommentsVisitor}; +pub(crate) use visitor::collect_comments; mod debug; pub(crate) mod format; @@ -324,12 +324,25 @@ impl<'a> Comments<'a> { let map = if comment_ranges.is_empty() { CommentsMap::new() } else { - CommentsVisitor::new(source_code, comment_ranges).visit(root) + let mut builder = CommentsMapBuilder::new(Locator::new(source_code.as_str())); + CommentsVisitor::new(source_code, comment_ranges, &mut builder).visit(root); + builder.finish() }; Self::new(map) } + /// Returns `true` if the given `node` has any comments. + #[inline] + pub(crate) fn has(&self, node: T) -> bool + where + T: Into>, + { + self.data + .comments + .has(&NodeRefEqualityKey::from_ref(node.into())) + } + /// Returns `true` if the given `node` has any [leading comments](self#leading-comments). #[inline] pub(crate) fn has_leading(&self, node: T) -> bool @@ -470,6 +483,28 @@ impl<'a> Comments<'a> { pub(crate) type LeadingDanglingTrailingComments<'a> = LeadingDanglingTrailing<'a, SourceComment>; +impl LeadingDanglingTrailingComments<'_> { + /// Returns `true` if the struct has any [leading comments](self#leading-comments). + #[inline] + pub(crate) fn has_leading(&self) -> bool { + !self.leading.is_empty() + } + + /// Returns `true` if the struct has any [trailing comments](self#trailing-comments). + #[inline] + pub(crate) fn has_trailing(&self) -> bool { + !self.trailing.is_empty() + } + + /// Returns `true` if the struct has any [trailing own line comments](self#trailing-comments). + #[inline] + pub(crate) fn has_trailing_own_line(&self) -> bool { + self.trailing + .iter() + .any(|comment| comment.line_position().is_own_line()) + } +} + #[derive(Debug, Default)] struct CommentsData<'a> { comments: CommentsMap<'a>, @@ -490,12 +525,12 @@ impl<'a> PreorderVisitor<'a> for MarkVerbatimCommentsAsFormattedVisitor<'a> { #[cfg(test)] mod tests { use insta::assert_debug_snapshot; - use ruff_python_ast::Mod; - use ruff_python_parser::lexer::lex; - use ruff_python_parser::{parse_tokens, Mode}; use ruff_formatter::SourceCode; + use ruff_python_ast::Mod; use ruff_python_index::{CommentRanges, CommentRangesBuilder}; + use ruff_python_parser::lexer::lex; + use ruff_python_parser::{parse_tokens, Mode}; use crate::comments::Comments; diff --git a/crates/ruff_python_formatter/src/comments/placement.rs b/crates/ruff_python_formatter/src/comments/placement.rs index 0db12e13c8..005cfb002d 100644 --- a/crates/ruff_python_formatter/src/comments/placement.rs +++ b/crates/ruff_python_formatter/src/comments/placement.rs @@ -38,7 +38,7 @@ pub(super) fn place_comment<'a>( /// ): /// ... /// ``` -/// The parentheses enclose `True`, but the range of `True`doesn't include the `# comment`. +/// The parentheses enclose `True`, but the range of `True` doesn't include the `# comment`. /// /// Default handling can get parenthesized comments wrong in a number of ways. For example, the /// comment here is marked (by default) as a trailing comment of `x`, when it should be a leading @@ -70,6 +70,20 @@ fn handle_parenthesized_comment<'a>( comment: DecoratedComment<'a>, locator: &Locator, ) -> CommentPlacement<'a> { + // As a special-case, ignore comments within f-strings, like: + // ```python + // ( + // f'{1}' # comment + // f'{2}' + // ) + // ``` + // These can't be parenthesized, as they must fall between two string tokens in an implicit + // concatenation. But the expression ranges only include the `1` and `2` above, so we also + // can't lex the contents between them. + if comment.enclosing_node().is_expr_f_string() { + return CommentPlacement::Default(comment); + } + let Some(preceding) = comment.preceding_node() else { return CommentPlacement::Default(comment); }; @@ -106,10 +120,8 @@ fn handle_parenthesized_comment<'a>( // For now, we _can_ assert, but to do so, we stop lexing when we hit a token that precedes an // identifier. if comment.line_position().is_end_of_line() { - let tokenizer = SimpleTokenizer::new( - locator.contents(), - TextRange::new(preceding.end(), comment.start()), - ); + let range = TextRange::new(preceding.end(), comment.start()); + let tokenizer = SimpleTokenizer::new(locator.contents(), range); if tokenizer .skip_trivia() .take_while(|token| { @@ -122,7 +134,7 @@ fn handle_parenthesized_comment<'a>( debug_assert!( !matches!(token.kind, SimpleTokenKind::Bogus), "Unexpected token between nodes: `{:?}`", - locator.slice(TextRange::new(preceding.end(), comment.start()),) + locator.slice(range) ); token.kind() == SimpleTokenKind::LParen @@ -131,10 +143,8 @@ fn handle_parenthesized_comment<'a>( return CommentPlacement::leading(following, comment); } } else { - let tokenizer = SimpleTokenizer::new( - locator.contents(), - TextRange::new(comment.end(), following.start()), - ); + let range = TextRange::new(comment.end(), following.start()); + let tokenizer = SimpleTokenizer::new(locator.contents(), range); if tokenizer .skip_trivia() .take_while(|token| { @@ -147,7 +157,7 @@ fn handle_parenthesized_comment<'a>( debug_assert!( !matches!(token.kind, SimpleTokenKind::Bogus), "Unexpected token between nodes: `{:?}`", - locator.slice(TextRange::new(comment.end(), following.start())) + locator.slice(range) ); token.kind() == SimpleTokenKind::RParen }) @@ -191,7 +201,13 @@ fn handle_enclosed_comment<'a>( locator, ) } - AnyNodeRef::Keyword(_) => handle_dict_unpacking_comment(comment, locator), + AnyNodeRef::ExprBoolOp(_) | AnyNodeRef::ExprCompare(_) => { + handle_trailing_binary_like_comment(comment, locator) + } + AnyNodeRef::Keyword(keyword) => handle_keyword_comment(comment, keyword, locator), + AnyNodeRef::PatternKeyword(pattern_keyword) => { + handle_pattern_keyword_comment(comment, pattern_keyword, locator) + } AnyNodeRef::ExprNamedExpr(_) => handle_named_expr_comment(comment, locator), AnyNodeRef::ExprDict(_) => handle_dict_unpacking_comment(comment, locator) .or_else(|comment| handle_bracketed_end_of_line_comment(comment, locator)), @@ -422,7 +438,7 @@ fn handle_own_line_comment_around_body<'a>( return CommentPlacement::Default(comment); }; - // If there's any non-trivia token between the preceding node and the comment, than it means + // If there's any non-trivia token between the preceding node and the comment, then it means // we're past the case of the alternate branch, defer to the default rules // ```python // if a: @@ -443,11 +459,78 @@ fn handle_own_line_comment_around_body<'a>( } // Check if we're between bodies and should attach to the following body. - handle_own_line_comment_between_branches(comment, preceding, locator).or_else(|comment| { - // Otherwise, there's no following branch or the indentation is too deep, so attach to the - // recursively last statement in the preceding body with the matching indentation. - handle_own_line_comment_after_branch(comment, preceding, locator) - }) + handle_own_line_comment_between_branches(comment, preceding, locator) + .or_else(|comment| { + // Otherwise, there's no following branch or the indentation is too deep, so attach to the + // recursively last statement in the preceding body with the matching indentation. + handle_own_line_comment_after_branch(comment, preceding, locator) + }) + .or_else(|comment| handle_own_line_comment_between_statements(comment, locator)) +} + +/// Handles own-line comments between statements. If an own-line comment is between two statements, +/// it's treated as a leading comment of the following statement _if_ there are no empty lines +/// separating the comment and the statement; otherwise, it's treated as a trailing comment of the +/// preceding statement. +/// +/// For example, this comment would be a trailing comment of `x = 1`: +/// ```python +/// x = 1 +/// # comment +/// +/// y = 2 +/// ``` +/// +/// However, this comment would be a leading comment of `y = 2`: +/// ```python +/// x = 1 +/// +/// # comment +/// y = 2 +/// ``` +fn handle_own_line_comment_between_statements<'a>( + comment: DecoratedComment<'a>, + locator: &Locator, +) -> CommentPlacement<'a> { + let Some(preceding) = comment.preceding_node() else { + return CommentPlacement::Default(comment); + }; + + let Some(following) = comment.following_node() else { + return CommentPlacement::Default(comment); + }; + + // We're looking for comments between two statements, like: + // ```python + // x = 1 + // # comment + // y = 2 + // ``` + if !preceding.is_statement() || !following.is_statement() { + return CommentPlacement::Default(comment); + } + + // If the comment is directly attached to the following statement; make it a leading + // comment: + // ```python + // x = 1 + // + // # leading comment + // y = 2 + // ``` + // + // Otherwise, if there's at least one empty line, make it a trailing comment: + // ```python + // x = 1 + // # trailing comment + // + // y = 2 + // ``` + if max_empty_lines(locator.slice(TextRange::new(comment.end(), following.start()))) == 0 { + CommentPlacement::leading(following, comment) + } else { + CommentPlacement::trailing(preceding, comment) + } } /// Handles own line comments between two branches of a node. @@ -647,11 +730,10 @@ fn handle_parameters_separator_comment<'a>( locator: &Locator, ) -> CommentPlacement<'a> { let (slash, star) = find_parameter_separators(locator.contents(), parameters); - let comment_range = comment.slice().range(); let placement = assign_argument_separator_comment_placement( slash.as_ref(), star.as_ref(), - comment_range, + comment.range(), comment.line_position(), ); if placement.is_some() { @@ -695,9 +777,7 @@ fn handle_trailing_binary_expression_left_or_operator_comment<'a>( .expect("Expected a token for the operator") .start(); - let comment_range = comment.slice().range(); - - if comment_range.end() < operator_offset { + if comment.end() < operator_offset { // ```python // a = ( // 5 @@ -755,6 +835,47 @@ fn handle_trailing_binary_expression_left_or_operator_comment<'a>( } } +/// Attaches comments between two bool or compare expression operands to the preceding operand if the comment is before the operator. +/// +/// ```python +/// a = ( +/// 5 > 3 +/// # trailing comment +/// and 3 == 3 +/// ) +/// ``` +fn handle_trailing_binary_like_comment<'a>( + comment: DecoratedComment<'a>, + locator: &Locator, +) -> CommentPlacement<'a> { + debug_assert!( + comment.enclosing_node().is_expr_bool_op() || comment.enclosing_node().is_expr_compare() + ); + + // Only if there's a preceding node (in which case, the preceding node is `left` or middle node). + let (Some(left_operand), Some(right_operand)) = + (comment.preceding_node(), comment.following_node()) + else { + return CommentPlacement::Default(comment); + }; + + let between_operands_range = TextRange::new(left_operand.end(), right_operand.start()); + + let mut tokens = SimpleTokenizer::new(locator.contents(), between_operands_range) + .skip_trivia() + .skip_while(|token| token.kind == SimpleTokenKind::RParen); + let operator_offset = tokens + .next() + .expect("Expected a token for the operator") + .start(); + + if comment.end() < operator_offset { + CommentPlacement::trailing(left_operand, comment) + } else { + CommentPlacement::Default(comment) + } +} + /// Handles own line comments on the module level before a class or function statement. /// A comment only becomes the leading comment of a class or function if it isn't separated by an empty /// line from the class. Comments that are separated by at least one empty line from the header of the @@ -816,8 +937,7 @@ fn handle_module_level_own_line_comment_before_class_or_function_comment<'a>( } // Make the comment a leading comment if there's no empty line between the comment and the function / class header - if max_empty_lines(locator.slice(TextRange::new(comment.slice().end(), following.start()))) == 0 - { + if max_empty_lines(locator.slice(TextRange::new(comment.end(), following.start()))) == 0 { CommentPlacement::leading(following, comment) } else { // Otherwise attach the comment as trailing comment to the previous statement @@ -872,8 +992,7 @@ fn handle_slice_comments<'a>( return CommentPlacement::dangling(comment.enclosing_node(), comment); } - let assignment = - assign_comment_in_slice(comment.slice().range(), locator.contents(), expr_slice); + let assignment = assign_comment_in_slice(comment.range(), locator.contents(), expr_slice); let node = match assignment { ExprSliceCommentSection::Lower => lower, ExprSliceCommentSection::Upper => upper, @@ -945,6 +1064,74 @@ fn handle_leading_class_with_decorators_comment<'a>( CommentPlacement::Default(comment) } +/// Handles comments between a keyword's identifier and value: +/// ```python +/// func( +/// x # dangling +/// = # dangling +/// # dangling +/// 1, +/// ** # dangling +/// y +/// ) +/// ``` +fn handle_keyword_comment<'a>( + comment: DecoratedComment<'a>, + keyword: &'a ast::Keyword, + locator: &Locator, +) -> CommentPlacement<'a> { + let start = keyword.arg.as_ref().map_or(keyword.start(), Ranged::end); + + // If the comment is parenthesized, it should be attached to the value: + // ```python + // func( + // x=( # comment + // 1 + // ) + // ) + // ``` + let mut tokenizer = + SimpleTokenizer::new(locator.contents(), TextRange::new(start, comment.start())); + if tokenizer.any(|token| token.kind == SimpleTokenKind::LParen) { + return CommentPlacement::Default(comment); + } + + CommentPlacement::leading(comment.enclosing_node(), comment) +} + +/// Handles comments between a pattern keyword's identifier and value: +/// ```python +/// case Point2D( +/// x # dangling +/// = # dangling +/// # dangling +/// 1 +/// ) +/// ``` +fn handle_pattern_keyword_comment<'a>( + comment: DecoratedComment<'a>, + pattern_keyword: &'a ast::PatternKeyword, + locator: &Locator, +) -> CommentPlacement<'a> { + // If the comment is parenthesized, it should be attached to the value: + // ```python + // case Point2D( + // x=( # comment + // 1 + // ) + // ) + // ``` + let mut tokenizer = SimpleTokenizer::new( + locator.contents(), + TextRange::new(pattern_keyword.attr.end(), comment.start()), + ); + if tokenizer.any(|token| token.kind == SimpleTokenKind::LParen) { + return CommentPlacement::Default(comment); + } + + CommentPlacement::leading(comment.enclosing_node(), comment) +} + /// Handles comments between `**` and the variable name in dict unpacking /// It attaches these to the appropriate value node. /// @@ -959,10 +1146,7 @@ fn handle_dict_unpacking_comment<'a>( comment: DecoratedComment<'a>, locator: &Locator, ) -> CommentPlacement<'a> { - debug_assert!(matches!( - comment.enclosing_node(), - AnyNodeRef::ExprDict(_) | AnyNodeRef::Keyword(_) - )); + debug_assert!(matches!(comment.enclosing_node(), AnyNodeRef::ExprDict(_))); // no node after our comment so we can't be between `**` and the name (node) let Some(following) = comment.following_node() else { @@ -985,7 +1169,7 @@ fn handle_dict_unpacking_comment<'a>( // if the remaining tokens from the previous node are exactly `**`, // re-assign the comment to the one that follows the stars if tokens.any(|token| token.kind == SimpleTokenKind::DoubleStar) { - CommentPlacement::trailing(following, comment) + CommentPlacement::leading(following, comment) } else { CommentPlacement::Default(comment) } @@ -1558,7 +1742,7 @@ fn handle_comprehension_comment<'a>( // b in c // ] // ``` - if comment.slice().end() < comprehension.target.start() { + if comment.end() < comprehension.target.start() { return if is_own_line { // own line comments are correctly assigned as leading the target CommentPlacement::Default(comment) @@ -1774,6 +1958,7 @@ fn max_empty_lines(contents: &str) -> u32 { } } + max_new_lines = newlines.max(max_new_lines); max_new_lines.saturating_sub(1) } diff --git a/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__base_test.snap b/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__base_test.snap index 3ace969501..1a8dc9fcd7 100644 --- a/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__base_test.snap +++ b/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__base_test.snap @@ -16,7 +16,13 @@ expression: comments.debug(test_case.source_code) }, ], "dangling": [], - "trailing": [], + "trailing": [ + SourceComment { + text: "# own line comment", + position: OwnLine, + formatted: false, + }, + ], }, Node { kind: StmtIf, @@ -48,19 +54,4 @@ expression: comments.debug(test_case.source_code) "dangling": [], "trailing": [], }, - Node { - kind: StmtExpr, - range: 234..246, - source: `test(10, 20)`, - }: { - "leading": [ - SourceComment { - text: "# own line comment", - position: OwnLine, - formatted: false, - }, - ], - "dangling": [], - "trailing": [], - }, } diff --git a/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__match_cases.snap b/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__match_cases.snap index a7056aad31..bc93d702de 100644 --- a/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__match_cases.snap +++ b/crates/ruff_python_formatter/src/comments/snapshots/ruff_python_formatter__comments__tests__match_cases.snap @@ -3,6 +3,21 @@ source: crates/ruff_python_formatter/src/comments/mod.rs expression: comments.debug(test_case.source_code) --- { + Node { + kind: StmtMatch, + range: 27..550, + source: `match pt:⏎`, + }: { + "leading": [], + "dangling": [], + "trailing": [ + SourceComment { + text: "# After match comment", + position: OwnLine, + formatted: false, + }, + ], + }, Node { kind: MatchCase, range: 84..132, @@ -108,19 +123,4 @@ expression: comments.debug(test_case.source_code) }, ], }, - Node { - kind: StmtExpr, - range: 656..670, - source: `print("other")`, - }: { - "leading": [ - SourceComment { - text: "# After match comment", - position: OwnLine, - formatted: false, - }, - ], - "dangling": [], - "trailing": [], - }, } diff --git a/crates/ruff_python_formatter/src/comments/visitor.rs b/crates/ruff_python_formatter/src/comments/visitor.rs index c6aa5abb7c..c291e635e9 100644 --- a/crates/ruff_python_formatter/src/comments/visitor.rs +++ b/crates/ruff_python_formatter/src/comments/visitor.rs @@ -1,36 +1,51 @@ +use std::fmt::Debug; use std::iter::Peekable; -use ruff_python_ast::{Mod, Stmt}; -use ruff_text_size::{Ranged, TextRange, TextSize}; - use ruff_formatter::{SourceCode, SourceCodeSlice}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_index::CommentRanges; -use ruff_source_file::Locator; +use ruff_python_ast::{Mod, Stmt}; // The interface is designed to only export the members relevant for iterating nodes in // pre-order. #[allow(clippy::wildcard_imports)] use ruff_python_ast::visitor::preorder::*; +use ruff_python_index::CommentRanges; use ruff_python_trivia::is_python_whitespace; +use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::comments::node_key::NodeRefEqualityKey; use crate::comments::placement::place_comment; use crate::comments::{CommentLinePosition, CommentsMap, SourceComment}; +/// Collect the preceding, following and enclosing node for each comment without applying +/// [`place_comment`] for debugging. +pub(crate) fn collect_comments<'a>( + root: &'a Mod, + source_code: SourceCode<'a>, + comment_ranges: &'a CommentRanges, +) -> Vec> { + let mut collector = CommentsVecBuilder::default(); + CommentsVisitor::new(source_code, comment_ranges, &mut collector).visit(root); + collector.comments +} + /// Visitor extracting the comments from an AST. -#[derive(Debug, Clone)] -pub(crate) struct CommentsVisitor<'a> { - builder: CommentsBuilder<'a>, +pub(super) struct CommentsVisitor<'a, 'builder> { + builder: &'builder mut (dyn PushComment<'a> + 'a), source_code: SourceCode<'a>, parents: Vec>, preceding_node: Option>, comment_ranges: Peekable>, } -impl<'a> CommentsVisitor<'a> { - pub(crate) fn new(source_code: SourceCode<'a>, comment_ranges: &'a CommentRanges) -> Self { +impl<'a, 'builder> CommentsVisitor<'a, 'builder> { + pub(super) fn new( + source_code: SourceCode<'a>, + comment_ranges: &'a CommentRanges, + builder: &'builder mut (dyn PushComment<'a> + 'a), + ) -> Self { Self { - builder: CommentsBuilder::default(), + builder, source_code, parents: Vec::new(), preceding_node: None, @@ -38,10 +53,8 @@ impl<'a> CommentsVisitor<'a> { } } - pub(super) fn visit(mut self, root: &'a Mod) -> CommentsMap<'a> { + pub(super) fn visit(mut self, root: &'a Mod) { self.visit_mod(root); - - self.finish() } // Try to skip the subtree if @@ -52,13 +65,9 @@ impl<'a> CommentsVisitor<'a> { .peek() .map_or(true, |next_comment| next_comment.start() >= node_end) } - - fn finish(self) -> CommentsMap<'a> { - self.builder.finish() - } } -impl<'ast> PreorderVisitor<'ast> for CommentsVisitor<'ast> { +impl<'ast> PreorderVisitor<'ast> for CommentsVisitor<'ast, '_> { fn enter_node(&mut self, node: AnyNodeRef<'ast>) -> TraversalSignal { let node_range = node.range(); @@ -82,10 +91,7 @@ impl<'ast> PreorderVisitor<'ast> for CommentsVisitor<'ast> { slice: self.source_code.slice(*comment_range), }; - self.builder.add_comment(place_comment( - comment, - &Locator::new(self.source_code.as_str()), - )); + self.builder.push_comment(comment); self.comment_ranges.next(); } @@ -125,10 +131,7 @@ impl<'ast> PreorderVisitor<'ast> for CommentsVisitor<'ast> { slice: self.source_code.slice(*comment_range), }; - self.builder.add_comment(place_comment( - comment, - &Locator::new(self.source_code.as_str()), - )); + self.builder.push_comment(comment); self.comment_ranges.next(); } @@ -177,7 +180,7 @@ fn text_position(comment_range: TextRange, source_code: SourceCode) -> CommentLi /// /// Used by [`CommentStyle::place_comment`] to determine if this should become a [leading](self#leading-comments), [dangling](self#dangling-comments), or [trailing](self#trailing-comments) comment. #[derive(Debug, Clone)] -pub(super) struct DecoratedComment<'a> { +pub(crate) struct DecoratedComment<'a> { enclosing: AnyNodeRef<'a>, preceding: Option>, following: Option>, @@ -203,7 +206,7 @@ impl<'a> DecoratedComment<'a> { /// /// The enclosing node is the list expression and not the name `b` because /// `a` and `b` are children of the list expression and `comment` is between the two nodes. - pub(super) fn enclosing_node(&self) -> AnyNodeRef<'a> { + pub(crate) fn enclosing_node(&self) -> AnyNodeRef<'a> { self.enclosing } @@ -212,11 +215,6 @@ impl<'a> DecoratedComment<'a> { self.parent } - /// Returns the slice into the source code. - pub(super) fn slice(&self) -> &SourceCodeSlice { - &self.slice - } - /// Returns the comment's preceding node. /// /// The direct child node (ignoring lists) of the [`enclosing_node`](DecoratedComment::enclosing_node) that precedes this comment. @@ -257,7 +255,7 @@ impl<'a> DecoratedComment<'a> { /// /// Returns `Some(a)` because `a` is the preceding node of `comment`. The presence of the `,` token /// doesn't change that. - pub(super) fn preceding_node(&self) -> Option> { + pub(crate) fn preceding_node(&self) -> Option> { self.preceding } @@ -315,7 +313,7 @@ impl<'a> DecoratedComment<'a> { /// /// Returns `None` because `comment` is enclosed inside the parenthesized expression and it has no children /// following `# comment`. - pub(super) fn following_node(&self) -> Option> { + pub(crate) fn following_node(&self) -> Option> { self.following } @@ -323,6 +321,11 @@ impl<'a> DecoratedComment<'a> { pub(super) fn line_position(&self) -> CommentLinePosition { self.line_position } + + /// Returns the slice into the source code. + pub(crate) fn slice(&self) -> &SourceCodeSlice { + &self.slice + } } impl Ranged for DecoratedComment<'_> { @@ -512,13 +515,33 @@ impl<'a> CommentPlacement<'a> { } } -#[derive(Clone, Debug, Default)] -struct CommentsBuilder<'a> { - comments: CommentsMap<'a>, +pub(super) trait PushComment<'a> { + fn push_comment(&mut self, placement: DecoratedComment<'a>); } -impl<'a> CommentsBuilder<'a> { - fn add_comment(&mut self, placement: CommentPlacement<'a>) { +/// A storage for the [`CommentsVisitor`] that just pushes the decorated comments to a [`Vec`] for +/// debugging purposes. +#[derive(Debug, Default)] +struct CommentsVecBuilder<'a> { + comments: Vec>, +} + +impl<'a> PushComment<'a> for CommentsVecBuilder<'a> { + fn push_comment(&mut self, placement: DecoratedComment<'a>) { + self.comments.push(placement); + } +} + +/// A storage for the [`CommentsVisitor`] that fixes the placement and stores the comments in a +/// [`CommentsMap`]. +pub(super) struct CommentsMapBuilder<'a> { + comments: CommentsMap<'a>, + locator: Locator<'a>, +} + +impl<'a> PushComment<'a> for CommentsMapBuilder<'a> { + fn push_comment(&mut self, placement: DecoratedComment<'a>) { + let placement = place_comment(placement, &self.locator); match placement { CommentPlacement::Leading { node, comment } => { self.push_leading_comment(node, comment); @@ -577,8 +600,17 @@ impl<'a> CommentsBuilder<'a> { } } } +} - fn finish(self) -> CommentsMap<'a> { +impl<'a> CommentsMapBuilder<'a> { + pub(crate) fn new(locator: Locator<'a>) -> Self { + Self { + comments: CommentsMap::default(), + locator, + } + } + + pub(crate) fn finish(self) -> CommentsMap<'a> { self.comments } diff --git a/crates/ruff_python_formatter/src/expression/binary_like.rs b/crates/ruff_python_formatter/src/expression/binary_like.rs new file mode 100644 index 0000000000..9350459035 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/binary_like.rs @@ -0,0 +1,1109 @@ +use std::num::NonZeroUsize; +use std::ops::{Deref, Index}; + +use smallvec::SmallVec; + +use ruff_formatter::write; +use ruff_python_ast::{ + Constant, Expr, ExprAttribute, ExprBinOp, ExprBoolOp, ExprCompare, ExprConstant, ExprUnaryOp, + UnaryOp, +}; +use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer}; +use ruff_text_size::{Ranged, TextRange}; + +use crate::comments::{leading_comments, trailing_comments, Comments, SourceComment}; +use crate::expression::parentheses::{ + in_parentheses_only_group, in_parentheses_only_soft_line_break, + in_parentheses_only_soft_line_break_or_space, is_expression_parenthesized, + write_in_parentheses_only_group_end_tag, write_in_parentheses_only_group_start_tag, + Parentheses, +}; +use crate::expression::string::{AnyString, FormatString, StringLayout}; +use crate::expression::OperatorPrecedence; +use crate::prelude::*; + +#[derive(Copy, Clone, Debug)] +pub(super) enum BinaryLike<'a> { + Binary(&'a ExprBinOp), + Compare(&'a ExprCompare), + Bool(&'a ExprBoolOp), +} + +impl<'a> BinaryLike<'a> { + /// Flattens the hierarchical binary expression into a flat operand, operator, operand... sequence. + /// + /// See [`FlatBinaryExpressionSlice`] for an in depth explanation. + fn flatten(self, comments: &'a Comments<'a>, source: &str) -> FlatBinaryExpression<'a> { + fn recurse_compare<'a>( + compare: &'a ExprCompare, + leading_comments: &'a [SourceComment], + trailing_comments: &'a [SourceComment], + comments: &'a Comments, + source: &str, + parts: &mut SmallVec<[OperandOrOperator<'a>; 8]>, + ) { + parts.reserve(compare.comparators.len() * 2 + 1); + + rec( + Operand::Left { + expression: &compare.left, + leading_comments, + }, + comments, + source, + parts, + ); + + assert_eq!( + compare.comparators.len(), + compare.ops.len(), + "Compare expression with an unbalanced number of comparators and operations." + ); + + if let Some((last_expression, middle_expressions)) = compare.comparators.split_last() { + let (last_operator, middle_operators) = compare.ops.split_last().unwrap(); + + for (operator, expression) in middle_operators.iter().zip(middle_expressions) { + parts.push(OperandOrOperator::Operator(Operator { + symbol: OperatorSymbol::Comparator(*operator), + trailing_comments: &[], + })); + + rec(Operand::Middle { expression }, comments, source, parts); + } + + parts.push(OperandOrOperator::Operator(Operator { + symbol: OperatorSymbol::Comparator(*last_operator), + trailing_comments: &[], + })); + + rec( + Operand::Right { + expression: last_expression, + trailing_comments, + }, + comments, + source, + parts, + ); + } + } + + fn recurse_bool<'a>( + bool_expression: &'a ExprBoolOp, + leading_comments: &'a [SourceComment], + trailing_comments: &'a [SourceComment], + comments: &'a Comments, + source: &str, + parts: &mut SmallVec<[OperandOrOperator<'a>; 8]>, + ) { + parts.reserve(bool_expression.values.len() * 2 - 1); + + if let Some((left, rest)) = bool_expression.values.split_first() { + rec( + Operand::Left { + expression: left, + leading_comments, + }, + comments, + source, + parts, + ); + + parts.push(OperandOrOperator::Operator(Operator { + symbol: OperatorSymbol::Bool(bool_expression.op), + trailing_comments: &[], + })); + + if let Some((right, middle)) = rest.split_last() { + for expression in middle { + rec(Operand::Middle { expression }, comments, source, parts); + parts.push(OperandOrOperator::Operator(Operator { + symbol: OperatorSymbol::Bool(bool_expression.op), + trailing_comments: &[], + })); + } + + rec( + Operand::Right { + expression: right, + trailing_comments, + }, + comments, + source, + parts, + ); + } + } + } + + fn recurse_binary<'a>( + binary: &'a ExprBinOp, + leading_comments: &'a [SourceComment], + trailing_comments: &'a [SourceComment], + comments: &'a Comments, + source: &str, + parts: &mut SmallVec<[OperandOrOperator<'a>; 8]>, + ) { + rec( + Operand::Left { + leading_comments, + expression: &binary.left, + }, + comments, + source, + parts, + ); + + parts.push(OperandOrOperator::Operator(Operator { + symbol: OperatorSymbol::Binary(binary.op), + trailing_comments: comments.dangling(binary), + })); + + rec( + Operand::Right { + expression: binary.right.as_ref(), + trailing_comments, + }, + comments, + source, + parts, + ); + } + + fn rec<'a>( + operand: Operand<'a>, + comments: &'a Comments, + source: &str, + parts: &mut SmallVec<[OperandOrOperator<'a>; 8]>, + ) { + let expression = operand.expression(); + match expression { + Expr::BinOp(binary) if !is_expression_parenthesized(expression.into(), source) => { + let leading_comments = operand + .leading_binary_comments() + .unwrap_or_else(|| comments.leading(binary)); + + let trailing_comments = operand + .trailing_binary_comments() + .unwrap_or_else(|| comments.trailing(binary)); + + recurse_binary( + binary, + leading_comments, + trailing_comments, + comments, + source, + parts, + ); + } + Expr::Compare(compare) + if !is_expression_parenthesized(expression.into(), source) => + { + let leading_comments = operand + .leading_binary_comments() + .unwrap_or_else(|| comments.leading(compare)); + + let trailing_comments = operand + .trailing_binary_comments() + .unwrap_or_else(|| comments.trailing(compare)); + + recurse_compare( + compare, + leading_comments, + trailing_comments, + comments, + source, + parts, + ); + } + Expr::BoolOp(bool_op) + if !is_expression_parenthesized(expression.into(), source) => + { + let leading_comments = operand + .leading_binary_comments() + .unwrap_or_else(|| comments.leading(bool_op)); + + let trailing_comments = operand + .trailing_binary_comments() + .unwrap_or_else(|| comments.trailing(bool_op)); + + recurse_bool( + bool_op, + leading_comments, + trailing_comments, + comments, + source, + parts, + ); + } + _ => { + parts.push(OperandOrOperator::Operand(operand)); + } + } + } + + let mut parts = SmallVec::new(); + match self { + BinaryLike::Binary(binary) => { + // Leading and trailing comments are handled by the binary's ``FormatNodeRule` implementation. + recurse_binary(binary, &[], &[], comments, source, &mut parts); + } + BinaryLike::Compare(compare) => { + // Leading and trailing comments are handled by the compare's ``FormatNodeRule` implementation. + recurse_compare(compare, &[], &[], comments, source, &mut parts); + } + BinaryLike::Bool(bool) => { + recurse_bool(bool, &[], &[], comments, source, &mut parts); + } + } + + FlatBinaryExpression(parts) + } + + const fn is_bool_op(self) -> bool { + matches!(self, BinaryLike::Bool(_)) + } +} + +impl Format> for BinaryLike<'_> { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { + let comments = f.context().comments().clone(); + let flat_binary = self.flatten(&comments, f.context().source()); + + if self.is_bool_op() { + return in_parentheses_only_group(&&*flat_binary).fmt(f); + } + + let source = f.context().source(); + let mut string_operands = flat_binary + .operands() + .filter_map(|(index, operand)| { + AnyString::from_expression(operand.expression()) + .filter(|string| { + string.is_implicit_concatenated() + && !is_expression_parenthesized(string.into(), source) + }) + .map(|string| (index, string, operand)) + }) + .peekable(); + + // Split the binary expressions by implicit concatenated strings first by creating: + // * One group that encloses the whole binary expression and ensures that all implicit concatenated strings + // break together or fit on the same line + // * Group the left operand and left operator as well as the right operator and right operand + // to give them a lower precedence than the implicit concatenated string parts (the implicit strings should break first) + if let Some((first_index, _, _)) = string_operands.peek() { + // Group all strings in a single group so that they all break together or none of them. + write_in_parentheses_only_group_start_tag(f); + + // Start the group for the left side coming before an implicit concatenated string if it isn't the first + // ```python + // a + "b" "c" + // ^^^- start this group + // ``` + if *first_index != OperandIndex::new(0) { + write_in_parentheses_only_group_start_tag(f); + } + + // The index of the last formatted operator + let mut last_operator_index = None; + + loop { + if let Some((index, string_constant, operand)) = string_operands.next() { + // An implicit concatenated string that isn't the first operand in a binary expression + // ```python + // a + "b" "c" + ddddddd + "e" "d" + // ^^^^^^ this part or ^^^^^^^ this part + // ``` + if let Some(left_operator_index) = index.left_operator() { + // Handles the case where the left and right side of a binary expression are both + // implicit concatenated strings. In this case, the left operator has already been written + // by the preceding implicit concatenated string. It is only necessary to finish the group, + // wrapping the soft line break and operator. + // + // ```python + // "a" "b" + "c" "d" + // ``` + if last_operator_index == Some(left_operator_index) { + write_in_parentheses_only_group_end_tag(f); + } else { + // Everything between the last implicit concatenated string and the left operator + // right before the implicit concatenated string: + // ```python + // a + b + "c" "d" + // ^--- left_operator + // ^^^^^-- left + // ``` + let left = flat_binary + .between_operators(last_operator_index, left_operator_index); + let left_operator = &flat_binary[left_operator_index]; + + if let Some(leading) = left.first_operand().leading_binary_comments() { + leading_comments(leading).fmt(f)?; + } + + // Write the left, the left operator, and the space before the right side + write!( + f, + [ + left, + left.last_operand() + .trailing_binary_comments() + .map(trailing_comments), + in_parentheses_only_soft_line_break_or_space(), + left_operator, + ] + )?; + + // Finish the left-side group (the group was started before the loop or by the + // previous iteration) + write_in_parentheses_only_group_end_tag(f); + + if operand.has_unparenthesized_leading_comments( + f.context().comments(), + f.context().source(), + ) || left_operator.has_trailing_comments() + { + hard_line_break().fmt(f)?; + } else { + space().fmt(f)?; + } + } + + write!( + f, + [ + operand.leading_binary_comments().map(leading_comments), + leading_comments(comments.leading(&string_constant)), + FormatString::new(&string_constant).with_layout( + StringLayout::ImplicitConcatenatedStringInBinaryLike, + ), + trailing_comments(comments.trailing(&string_constant)), + operand.trailing_binary_comments().map(trailing_comments), + line_suffix_boundary(), + ] + )?; + } else { + // Binary expression that starts with an implicit concatenated string: + // ```python + // "a" "b" + c + // ^^^^^^^-- format the first operand of a binary expression + // ``` + write!( + f, + [ + leading_comments(comments.leading(&string_constant)), + FormatString::new(&string_constant).with_layout( + StringLayout::ImplicitConcatenatedStringInBinaryLike + ), + trailing_comments(comments.trailing(&string_constant)), + ] + )?; + } + + // Write the right operator and start the group for the right side (if any) + // ```python + // a + "b" "c" + ddddddd + "e" "d" + // ^^--- write this + // ^^^^^^^^^^^-- start this group + // ``` + let right_operator_index = index.right_operator(); + if let Some(right_operator) = flat_binary.get_operator(index.right_operator()) { + write_in_parentheses_only_group_start_tag(f); + let right_operand = &flat_binary[right_operator_index.right_operand()]; + let right_operand_has_leading_comments = right_operand + .has_unparenthesized_leading_comments( + f.context().comments(), + f.context().source(), + ); + + // Keep the operator on the same line if the right side has leading comments (and thus, breaks) + if right_operand_has_leading_comments { + space().fmt(f)?; + } else { + in_parentheses_only_soft_line_break_or_space().fmt(f)?; + } + + right_operator.fmt(f)?; + + if (right_operand_has_leading_comments + && !is_expression_parenthesized( + right_operand.expression().into(), + f.context().source(), + )) + || right_operator.has_trailing_comments() + { + hard_line_break().fmt(f)?; + } else { + space().fmt(f)?; + } + + last_operator_index = Some(right_operator_index); + } else { + break; + } + } else { + if let Some(last_operator_index) = last_operator_index { + let end = flat_binary.after_operator(last_operator_index); + + end.fmt(f)?; + + write_in_parentheses_only_group_end_tag(f); + } + + break; + } + } + + // Finish the group that wraps all implicit concatenated strings + write_in_parentheses_only_group_end_tag(f); + } else { + in_parentheses_only_group(&&*flat_binary).fmt(f)?; + } + + Ok(()) + } +} + +const fn is_simple_power_expression(left: &Expr, right: &Expr) -> bool { + is_simple_power_operand(left) && is_simple_power_operand(right) +} + +/// Return `true` if an [`Expr`] adheres to [Black's definition](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-breaks-binary-operators) +/// of a non-complex expression, in the context of a power operation. +const fn is_simple_power_operand(expr: &Expr) -> bool { + match expr { + Expr::UnaryOp(ExprUnaryOp { + op: UnaryOp::Not, .. + }) => false, + Expr::Constant(ExprConstant { + value: Constant::Complex { .. } | Constant::Float(_) | Constant::Int(_), + .. + }) => true, + Expr::Name(_) => true, + Expr::UnaryOp(ExprUnaryOp { operand, .. }) => is_simple_power_operand(operand), + Expr::Attribute(ExprAttribute { value, .. }) => is_simple_power_operand(value), + _ => false, + } +} + +/// Owned [`FlatBinaryExpressionSlice`]. Read the [`FlatBinaryExpressionSlice`] documentation for more details about the data structure. +#[derive(Debug)] +struct FlatBinaryExpression<'a>(SmallVec<[OperandOrOperator<'a>; 8]>); + +impl<'a> Deref for FlatBinaryExpression<'a> { + type Target = FlatBinaryExpressionSlice<'a>; + + fn deref(&self) -> &Self::Target { + FlatBinaryExpressionSlice::from_slice(&self.0) + } +} + +/// Binary chain represented as a flat vector where operands are stored at even indices and operators +/// add odd indices. +/// +/// ```python +/// a + 5 * 3 + 2 +/// ``` +/// +/// Gets parsed as: +/// +/// ```text +/// graph +/// + +/// ├──a +/// ├──* +/// │ ├──b +/// │ └──c +/// └──d +/// ``` +/// +/// The slice representation of the above is closer to what you have in source. It's a simple sequence of operands and operators, +/// entirely ignoring operator precedence (doesn't flatten parenthesized expressions): +/// +/// ```text +/// ----------------------------- +/// | a | + | 5 | * | 3 | + | 2 | +/// ----------------------------- +/// ``` +/// +/// The advantage of a flat structure are: +/// * It becomes possible to adjust the operator / operand precedence. E.g splitting implicit concatenated strings before `+` operations. +/// * It allows arbitrary slicing of binary expressions for as long as a slice always starts and ends with an operand. +/// +/// A slice is guaranteed to always start and end with an operand. The smallest valid slice is a slice containing a single operand. +/// Operands in multi-operand slices are separated by operators. +#[repr(transparent)] +struct FlatBinaryExpressionSlice<'a>([OperandOrOperator<'a>]); + +impl<'a> FlatBinaryExpressionSlice<'a> { + fn from_slice<'slice>(slice: &'slice [OperandOrOperator<'a>]) -> &'slice Self { + debug_assert!( + !slice.is_empty(), + "Operand slice must contain at least one operand" + ); + + #[allow(unsafe_code)] + unsafe { + // SAFETY: `BinaryChainSlice` has the same layout as a slice because it uses `repr(transparent)` + &*(slice as *const [OperandOrOperator<'a>] as *const FlatBinaryExpressionSlice<'a>) + } + } + + fn operators(&self) -> impl Iterator)> { + self.0.iter().enumerate().filter_map(|(index, part)| { + if let OperandOrOperator::Operator(operator) = part { + Some((OperatorIndex::new(index), operator)) + } else { + None + } + }) + } + + fn operands(&self) -> impl Iterator)> { + self.0.iter().enumerate().filter_map(|(index, part)| { + if let OperandOrOperator::Operand(operand) = part { + Some((OperandIndex::new(index), operand)) + } else { + None + } + }) + } + + /// Creates a subslice that contains the operands coming after `last_operator` and up to, but not including the `end` operator. + fn between_operators(&self, last_operator: Option, end: OperatorIndex) -> &Self { + let start = last_operator.map_or(0usize, |operator| operator.right_operand().0); + Self::from_slice(&self.0[start..end.value()]) + } + + /// Creates a slice starting at the right operand of `index`. + fn after_operator(&self, index: OperatorIndex) -> &Self { + Self::from_slice(&self.0[index.right_operand().0..]) + } + + /// Returns the lowest precedence of any operator in this binary chain. + fn lowest_precedence(&self) -> OperatorPrecedence { + self.operators() + .map(|(_, operator)| operator.precedence()) + .max() + .unwrap_or(OperatorPrecedence::None) + } + + /// Returns the first operand in the slice. + fn first_operand(&self) -> &Operand<'a> { + match self.0.first() { + Some(OperandOrOperator::Operand(operand)) => operand, + _ => unreachable!("Expected an operand"), + } + } + + /// Returns the last operand (the right most operand). + fn last_operand(&self) -> &Operand<'a> { + match self.0.last() { + Some(OperandOrOperator::Operand(operand)) => operand, + _ => unreachable!("Expected an operand"), + } + } + + /// Returns the operator at the given index or `None` if it is out of bounds. + fn get_operator(&self, index: OperatorIndex) -> Option<&Operator<'a>> { + self.0 + .get(index.value()) + .map(OperandOrOperator::unwrap_operator) + } +} + +/// Formats a binary chain slice by inserting soft line breaks before the lowest-precedence operators. +/// In other words: It splits the line before by the lowest precedence operators (and it either splits +/// all of them or none). For example, the lowest precedence operator for `a + b * c + d` is the `+` operator. +/// The expression either gets formatted as `a + b * c + d` if it fits on the line or as +/// ```python +/// a +/// + b * c +/// + d +/// ``` +/// +/// Notice how the formatting first splits by the lower precedence operator `+` but tries to keep the `*` operation +/// on a single line. +/// +/// The formatting is recursive (with a depth of `O(operators)` where `operators` are operators with different precedences). +/// +/// Comments before or after the first operand must be formatted by the caller because they shouldn't be part of the group +/// wrapping the whole binary chain. This is to avoid that `b * c` expands in the following example because of its trailing comemnt: +/// +/// ```python +/// +/// ( a +/// + b * c # comment +/// + d +/// ) +/// ``` +/// +/// +impl Format> for FlatBinaryExpressionSlice<'_> { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + // Single operand slice + if let [OperandOrOperator::Operand(operand)] = &self.0 { + return operand.fmt(f); + } + + let mut last_operator: Option = None; + + let lowest_precedence = self.lowest_precedence(); + + for (index, operator_part) in self.operators() { + if operator_part.precedence() == lowest_precedence { + let left = self.between_operators(last_operator, index); + let right = self.after_operator(index); + + let is_pow = operator_part.symbol.is_pow() + && is_simple_power_expression( + left.last_operand().expression(), + right.first_operand().expression(), + ); + + if let Some(leading) = left.first_operand().leading_binary_comments() { + leading_comments(leading).fmt(f)?; + } + + in_parentheses_only_group(&left).fmt(f)?; + + if let Some(trailing) = left.last_operand().trailing_binary_comments() { + trailing_comments(trailing).fmt(f)?; + } + + if is_pow { + in_parentheses_only_soft_line_break().fmt(f)?; + } else { + in_parentheses_only_soft_line_break_or_space().fmt(f)?; + } + + operator_part.fmt(f)?; + + // Format the operator on its own line if the right side has any leading comments. + if operator_part.has_trailing_comments() + || right.first_operand().has_unparenthesized_leading_comments( + f.context().comments(), + f.context().source(), + ) + { + hard_line_break().fmt(f)?; + } else if !is_pow { + space().fmt(f)?; + } + + last_operator = Some(index); + } + } + + // Format the last right side + // SAFETY: It is guaranteed that the slice contains at least a operand, operator, operand sequence or: + // * the slice contains only a single operand in which case the function exits early above. + // * the slice is empty, which isn't a valid slice + // * the slice violates the operand, operator, operand constraint, in which case the error already happened earlier. + let right = self.after_operator(last_operator.unwrap()); + + if let Some(leading) = right.first_operand().leading_binary_comments() { + leading_comments(leading).fmt(f)?; + } + + in_parentheses_only_group(&right).fmt(f) + } +} + +/// Either an [`Operand`] or [`Operator`] +#[derive(Debug)] +enum OperandOrOperator<'a> { + Operand(Operand<'a>), + Operator(Operator<'a>), +} + +impl<'a> OperandOrOperator<'a> { + fn unwrap_operand(&self) -> &Operand<'a> { + match self { + OperandOrOperator::Operand(operand) => operand, + OperandOrOperator::Operator(operator) => { + panic!("Expected operand but found operator {operator:?}.") + } + } + } + + fn unwrap_operator(&self) -> &Operator<'a> { + match self { + OperandOrOperator::Operator(operator) => operator, + OperandOrOperator::Operand(operand) => { + panic!("Expected operator but found operand {operand:?}.") + } + } + } +} + +#[derive(Debug)] +enum Operand<'a> { + /// Operand that used to be on the left side of a binary operation. + /// + /// For example `a` in the following code + /// + /// ```python + /// a + b + c + /// ``` + Left { + expression: &'a Expr, + /// Leading comments of the outer most binary expression that starts at this node. + leading_comments: &'a [SourceComment], + }, + /// Operand that is neither at the start nor the end of a binary like expression. + /// Only applies to compare expression. + /// + /// `b` and `c` are *middle* operands whereas `a` is a left and `d` a right operand. + /// + /// ```python + /// a > b > c > d + /// ``` + /// + /// Middle have no leading or trailing comments from the enclosing binary like expression. + Middle { expression: &'a Expr }, + + /// Operand that is on the right side of a binary operation. + /// + /// For example `b` and `c` are right sides of the binary expressions. + /// + /// ```python + /// a + b + c + /// ``` + Right { + expression: &'a Expr, + /// Trailing comments of the outer most binary expression that ends at this operand. + trailing_comments: &'a [SourceComment], + }, +} + +impl<'a> Operand<'a> { + fn expression(&self) -> &'a Expr { + match self { + Operand::Left { expression, .. } => expression, + Operand::Right { expression, .. } => expression, + Operand::Middle { expression } => expression, + } + } + + /// Returns `true` if the operand has any leading comments that are not parenthesized. + fn has_unparenthesized_leading_comments(&self, comments: &Comments, source: &str) -> bool { + match self { + Operand::Left { + leading_comments, .. + } => !leading_comments.is_empty(), + Operand::Middle { expression } | Operand::Right { expression, .. } => { + let leading = comments.leading(*expression); + if is_expression_parenthesized((*expression).into(), source) { + leading.iter().any(|comment| { + !comment.is_formatted() + && matches!( + SimpleTokenizer::new( + source, + TextRange::new(comment.end(), expression.start()), + ) + .skip_trivia() + .next(), + Some(SimpleToken { + kind: SimpleTokenKind::LParen, + .. + }) + ) + }) + } else { + !leading.is_empty() + } + } + } + } + + /// Comments of the outer-most enclosing binary expression. + fn leading_binary_comments(&self) -> Option<&'a [SourceComment]> { + match self { + Operand::Left { + leading_comments, .. + } => Some(leading_comments), + Operand::Middle { .. } | Operand::Right { .. } => None, + } + } + + fn trailing_binary_comments(&self) -> Option<&'a [SourceComment]> { + match self { + Operand::Middle { .. } | Operand::Left { .. } => None, + Operand::Right { + trailing_comments, .. + } => Some(trailing_comments), + } + } +} + +impl Format> for Operand<'_> { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { + let expression = self.expression(); + + return if is_expression_parenthesized(expression.into(), f.context().source()) { + let comments = f.context().comments().clone(); + let expression_comments = comments.leading_dangling_trailing(expression); + + // Format leading comments that are before the inner most `(` outside of the expression's parentheses. + // ```python + // z = ( + // a + // + + // # a: extracts this comment + // ( + // # b: and this comment + // ( + // # c: formats it as part of the expression + // x and y + // ) + // ) + // ) + // ``` + // + // Gets formatted as + // ```python + // z = ( + // a + // + + // # a: extracts this comment + // # b: and this comment + // ( + // # c: formats it as part of the expression + // x and y + // ) + // ) + // ``` + let leading = expression_comments.leading; + let leading_before_parentheses_end = leading + .iter() + .rposition(|comment| { + comment.is_unformatted() + && matches!( + SimpleTokenizer::new( + f.context().source(), + TextRange::new(comment.end(), expression.start()), + ) + .skip_trivia() + .next(), + Some(SimpleToken { + kind: SimpleTokenKind::LParen, + .. + }) + ) + }) + .map_or(0, |position| position + 1); + + let leading_before_parentheses = &leading[..leading_before_parentheses_end]; + + // Format trailing comments that are outside of the inner most `)` outside of the parentheses. + // ```python + // z = ( + // ( + // + // ( + // + // x and y + // # a: extracts this comment + // ) + // # b: and this comment + // ) + // # c: formats it as part of the expression + // + a + // ) + // ``` + // Gets formatted as + // ```python + // z = ( + // ( + // x and y + // # a: extracts this comment + // ) + // # b: and this comment + // # c: formats it as part of the expression + // + a + // ) + // ``` + let trailing = expression_comments.trailing; + + let trailing_after_parentheses_start = trailing + .iter() + .position(|comment| { + comment.is_unformatted() + && matches!( + SimpleTokenizer::new( + f.context().source(), + TextRange::new(expression.end(), comment.start()), + ) + .skip_trivia() + .next(), + Some(SimpleToken { + kind: SimpleTokenKind::RParen, + .. + }) + ) + }) + .unwrap_or(trailing.len()); + + let trailing_after_parentheses = &trailing[trailing_after_parentheses_start..]; + + // Mark the comment as formatted to avoid that the formatting of the expression + // formats the trailing comment inside of the parentheses. + for comment in trailing_after_parentheses { + comment.mark_formatted(); + } + + if !leading_before_parentheses.is_empty() { + leading_comments(leading_before_parentheses).fmt(f)?; + } + + expression + .format() + .with_options(Parentheses::Always) + .fmt(f)?; + + for comment in trailing_after_parentheses { + comment.mark_unformatted(); + } + + if !trailing_after_parentheses.is_empty() { + trailing_comments(trailing_after_parentheses).fmt(f)?; + } + + Ok(()) + } else { + expression.format().with_options(Parentheses::Never).fmt(f) + }; + } +} + +#[derive(Debug)] +struct Operator<'a> { + symbol: OperatorSymbol, + trailing_comments: &'a [SourceComment], +} + +impl Operator<'_> { + fn precedence(&self) -> OperatorPrecedence { + self.symbol.precedence() + } + + fn has_trailing_comments(&self) -> bool { + !self.trailing_comments.is_empty() + } +} + +impl Format> for Operator<'_> { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { + write!(f, [self.symbol, trailing_comments(self.trailing_comments)]) + } +} + +#[derive(Copy, Clone, Debug)] +enum OperatorSymbol { + Binary(ruff_python_ast::Operator), + Comparator(ruff_python_ast::CmpOp), + Bool(ruff_python_ast::BoolOp), +} + +impl OperatorSymbol { + const fn is_pow(self) -> bool { + matches!(self, OperatorSymbol::Binary(ruff_python_ast::Operator::Pow)) + } + + fn precedence(self) -> OperatorPrecedence { + match self { + OperatorSymbol::Binary(operator) => OperatorPrecedence::from(operator), + OperatorSymbol::Comparator(_) => OperatorPrecedence::Comparator, + OperatorSymbol::Bool(_) => OperatorPrecedence::BooleanOperation, + } + } +} + +impl Format> for OperatorSymbol { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { + match self { + OperatorSymbol::Binary(operator) => operator.format().fmt(f), + OperatorSymbol::Comparator(operator) => operator.format().fmt(f), + OperatorSymbol::Bool(bool) => bool.format().fmt(f), + } + } +} + +/// Index of an Operand in the [`FlatBinaryExpressionSlice`]. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] +struct OperandIndex(usize); + +impl OperandIndex { + fn new(index: usize) -> Self { + debug_assert_eq!(index % 2, 0, "Operand indices must be even positions"); + + Self(index) + } + + /// Returns the index of the operator directly left to this operand. Returns [`None`] if + /// this is the first operand in the call chain. + fn left_operator(self) -> Option { + if self.0 == 0 { + None + } else { + Some(OperatorIndex::new(self.0 - 1)) + } + } + + /// Returns the index of the operand's right operator. The method always returns an index + /// even if the operand has no right operator. Use [`BinaryCallChain::get_operator`] to test if + /// the operand has a right operator. + fn right_operator(self) -> OperatorIndex { + OperatorIndex::new(self.0 + 1) + } +} + +/// Index of an Operator in the [`FlatBinaryExpressionSlice`]. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] +struct OperatorIndex(NonZeroUsize); + +impl OperatorIndex { + fn new(index: usize) -> Self { + assert_eq!(index % 2, 1, "Operator indices must be odd positions"); + + // SAFETY A value with a module 0 is guaranteed to never equal 0 + #[allow(unsafe_code)] + Self(unsafe { NonZeroUsize::new_unchecked(index) }) + } + + const fn value(self) -> usize { + self.0.get() + } + + fn right_operand(self) -> OperandIndex { + OperandIndex::new(self.value() + 1) + } +} + +impl<'a> Index for FlatBinaryExpressionSlice<'a> { + type Output = Operator<'a>; + + fn index(&self, index: OperatorIndex) -> &Self::Output { + self.0[index.value()].unwrap_operator() + } +} + +impl<'a> Index for FlatBinaryExpressionSlice<'a> { + type Output = Operand<'a>; + + fn index(&self, index: OperandIndex) -> &Self::Output { + self.0[index.0].unwrap_operand() + } +} + +mod size_assertion { + use super::{FlatBinaryExpressionSlice, OperandOrOperator, OperatorIndex}; + + static_assertions::assert_eq_size!(Option, OperatorIndex); + + static_assertions::assert_eq_size!(&FlatBinaryExpressionSlice, &[OperandOrOperator]); + static_assertions::assert_eq_align!(&FlatBinaryExpressionSlice, &[OperandOrOperator]); +} diff --git a/crates/ruff_python_formatter/src/expression/expr_attribute.rs b/crates/ruff_python_formatter/src/expression/expr_attribute.rs index b2566242cb..3b11cde300 100644 --- a/crates/ruff_python_formatter/src/expression/expr_attribute.rs +++ b/crates/ruff_python_formatter/src/expression/expr_attribute.rs @@ -37,49 +37,45 @@ impl FormatNodeRule for FormatExprAttribute { let call_chain_layout = self.call_chain_layout.apply_in_node(item, f); let format_inner = format_with(|f: &mut PyFormatter| { - let needs_parentheses = matches!( - value.as_ref(), - Expr::Constant(ExprConstant { - value: Constant::Int(_) | Constant::Float(_), - .. - }) - ); + let parenthesize_value = + // If the value is an integer, we need to parenthesize it to avoid a syntax error. + matches!( + value.as_ref(), + Expr::Constant(ExprConstant { + value: Constant::Int(_) | Constant::Float(_), + .. + }) + ) || is_expression_parenthesized(value.into(), f.context().source()); - if needs_parentheses { - value.format().with_options(Parentheses::Always).fmt(f)?; - } else if call_chain_layout == CallChainLayout::Fluent { - match value.as_ref() { - Expr::Attribute(expr) => { - expr.format().with_options(call_chain_layout).fmt(f)?; - } - Expr::Call(expr) => { - expr.format().with_options(call_chain_layout).fmt(f)?; - if call_chain_layout == CallChainLayout::Fluent { - // Format the dot on its own line + if call_chain_layout == CallChainLayout::Fluent { + if parenthesize_value { + // Don't propagate the call chain layout. + value.format().with_options(Parentheses::Always).fmt(f)?; + + // Format the dot on its own line. + soft_line_break().fmt(f)?; + } else { + match value.as_ref() { + Expr::Attribute(expr) => { + expr.format().with_options(call_chain_layout).fmt(f)?; + } + Expr::Call(expr) => { + expr.format().with_options(call_chain_layout).fmt(f)?; soft_line_break().fmt(f)?; } - } - Expr::Subscript(expr) => { - expr.format().with_options(call_chain_layout).fmt(f)?; - if call_chain_layout == CallChainLayout::Fluent { - // Format the dot on its own line + Expr::Subscript(expr) => { + expr.format().with_options(call_chain_layout).fmt(f)?; soft_line_break().fmt(f)?; } - } - _ => { - // This matches [`CallChainLayout::from_expression`] - if is_expression_parenthesized(value.as_ref().into(), f.context().source()) - { - value.format().with_options(Parentheses::Always).fmt(f)?; - // Format the dot on its own line - soft_line_break().fmt(f)?; - } else { - value.format().fmt(f)?; + _ => { + value.format().with_options(Parentheses::Never).fmt(f)?; } } } + } else if parenthesize_value { + value.format().with_options(Parentheses::Always).fmt(f)?; } else { - value.format().fmt(f)?; + value.format().with_options(Parentheses::Never).fmt(f)?; } // Identify dangling comments before and after the dot: @@ -113,7 +109,7 @@ impl FormatNodeRule for FormatExprAttribute { f, [ dangling_comments(before_dot), - text("."), + token("."), dangling_comments(after_dot), attr.format() ] diff --git a/crates/ruff_python_formatter/src/expression/expr_await.rs b/crates/ruff_python_formatter/src/expression/expr_await.rs index 25fd244e75..665fec2489 100644 --- a/crates/ruff_python_formatter/src/expression/expr_await.rs +++ b/crates/ruff_python_formatter/src/expression/expr_await.rs @@ -16,7 +16,7 @@ impl FormatNodeRule for FormatExprAwait { write!( f, [ - text("await"), + token("await"), space(), maybe_parenthesize_expression(value, item, Parenthesize::IfBreaks) ] diff --git a/crates/ruff_python_formatter/src/expression/expr_bin_op.rs b/crates/ruff_python_formatter/src/expression/expr_bin_op.rs index 8c1f823f43..8601f6b1df 100644 --- a/crates/ruff_python_formatter/src/expression/expr_bin_op.rs +++ b/crates/ruff_python_formatter/src/expression/expr_bin_op.rs @@ -1,141 +1,20 @@ -use std::iter; - -use smallvec::SmallVec; - -use ruff_formatter::{format_args, write, FormatOwnedWithRule, FormatRefWithRule}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{ - Constant, Expr, ExprAttribute, ExprBinOp, ExprConstant, ExprUnaryOp, Operator, StringConstant, - UnaryOp, -}; +use ruff_python_ast::{Expr, ExprBinOp}; -use crate::comments::{trailing_comments, trailing_node_comments, SourceComment}; -use crate::expression::expr_constant::ExprConstantLayout; -use crate::expression::parentheses::{ - in_parentheses_only_group, in_parentheses_only_soft_line_break, - in_parentheses_only_soft_line_break_or_space, is_expression_parenthesized, parenthesized, - NeedsParentheses, OptionalParentheses, -}; -use crate::expression::string::StringLayout; +use crate::comments::SourceComment; +use crate::expression::binary_like::BinaryLike; +use crate::expression::expr_constant::is_multiline_string; +use crate::expression::has_parentheses; +use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; use crate::prelude::*; #[derive(Default)] pub struct FormatExprBinOp; impl FormatNodeRule for FormatExprBinOp { + #[inline] fn fmt_fields(&self, item: &ExprBinOp, f: &mut PyFormatter) -> FormatResult<()> { - let comments = f.context().comments().clone(); - - match Self::layout(item, f.context()) { - BinOpLayout::LeftString(expression) => { - let right_has_leading_comment = comments.has_leading(item.right.as_ref()); - - let format_right_and_op = format_with(|f| { - if right_has_leading_comment { - space().fmt(f)?; - } else { - soft_line_break_or_space().fmt(f)?; - } - - item.op.format().fmt(f)?; - - if right_has_leading_comment { - hard_line_break().fmt(f)?; - } else { - space().fmt(f)?; - } - - group(&item.right.format()).fmt(f) - }); - - let format_left = format_with(|f: &mut PyFormatter| { - let format_string = - expression.format().with_options(ExprConstantLayout::String( - StringLayout::ImplicitConcatenatedBinaryLeftSide, - )); - - if is_expression_parenthesized(expression.into(), f.context().source()) { - parenthesized("(", &format_string, ")").fmt(f) - } else { - format_string.fmt(f) - } - }); - - group(&format_args![format_left, group(&format_right_and_op)]).fmt(f) - } - BinOpLayout::Default => { - let format_inner = format_with(|f: &mut PyFormatter| { - let source = f.context().source(); - let binary_chain: SmallVec<[&ExprBinOp; 4]> = - iter::successors(Some(item), |parent| { - parent.left.as_bin_op_expr().and_then(|bin_expression| { - if is_expression_parenthesized(bin_expression.into(), source) { - None - } else { - Some(bin_expression) - } - }) - }) - .collect(); - - // SAFETY: `binary_chain` is guaranteed not to be empty because it always contains the current expression. - let left_most = binary_chain.last().unwrap(); - - // Format the left most expression - in_parentheses_only_group(&left_most.left.format()).fmt(f)?; - - // Iterate upwards in the binary expression tree and, for each level, format the operator - // and the right expression. - for current in binary_chain.into_iter().rev() { - let ExprBinOp { - range: _, - left: _, - op, - right, - } = current; - - let operator_comments = comments.dangling(current); - let needs_space = !is_simple_power_expression(current); - - let before_operator_space = if needs_space { - in_parentheses_only_soft_line_break_or_space() - } else { - in_parentheses_only_soft_line_break() - }; - - write!( - f, - [ - before_operator_space, - op.format(), - trailing_comments(operator_comments), - ] - )?; - - // Format the operator on its own line if the right side has any leading comments. - if comments.has_leading(right.as_ref()) || !operator_comments.is_empty() { - hard_line_break().fmt(f)?; - } else if needs_space { - space().fmt(f)?; - } - - in_parentheses_only_group(&right.format()).fmt(f)?; - - // It's necessary to format the trailing comments because the code bypasses - // `FormatNodeRule::fmt` for the nested binary expressions. - // Don't call the formatting function for the most outer binary expression because - // these comments have already been formatted. - if current != item { - trailing_node_comments(current).fmt(f)?; - } - } - - Ok(()) - }); - - in_parentheses_only_group(&format_inner).fmt(f) - } - } + BinaryLike::Binary(item).fmt(f) } fn fmt_dangling_comments( @@ -148,125 +27,27 @@ impl FormatNodeRule for FormatExprBinOp { } } -impl FormatExprBinOp { - fn layout<'a>(bin_op: &'a ExprBinOp, context: &PyFormatContext) -> BinOpLayout<'a> { - if let Some( - constant @ ExprConstant { - value: - Constant::Str(StringConstant { - implicit_concatenated: true, - .. - }), - .. - }, - ) = bin_op.left.as_constant_expr() - { - let comments = context.comments(); - - if bin_op.op == Operator::Mod - && context.node_level().is_parenthesized() - && !comments.has_dangling(constant) - && !comments.has_dangling(bin_op) - { - BinOpLayout::LeftString(constant) - } else { - BinOpLayout::Default - } - } else { - BinOpLayout::Default - } - } -} - -const fn is_simple_power_expression(expr: &ExprBinOp) -> bool { - expr.op.is_pow() && is_simple_power_operand(&expr.left) && is_simple_power_operand(&expr.right) -} - -/// Return `true` if an [`Expr`] adheres to [Black's definition](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-breaks-binary-operators) -/// of a non-complex expression, in the context of a power operation. -const fn is_simple_power_operand(expr: &Expr) -> bool { - match expr { - Expr::UnaryOp(ExprUnaryOp { - op: UnaryOp::Not, .. - }) => false, - Expr::Constant(ExprConstant { - value: Constant::Complex { .. } | Constant::Float(_) | Constant::Int(_), - .. - }) => true, - Expr::Name(_) => true, - Expr::UnaryOp(ExprUnaryOp { operand, .. }) => is_simple_power_operand(operand), - Expr::Attribute(ExprAttribute { value, .. }) => is_simple_power_operand(value), - _ => false, - } -} - -#[derive(Copy, Clone, Debug)] -enum BinOpLayout<'a> { - Default, - - /// Specific layout for an implicit concatenated string using the "old" c-style formatting. - /// - /// ```python - /// ( - /// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa %s" - /// "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb %s" % (a, b) - /// ) - /// ``` - /// - /// Prefers breaking the string parts over breaking in front of the `%` because it looks better if it - /// is kept on the same line. - LeftString(&'a ExprConstant), -} - -#[derive(Copy, Clone)] -pub struct FormatOperator; - -impl<'ast> AsFormat> for Operator { - type Format<'a> = FormatRefWithRule<'a, Operator, FormatOperator, PyFormatContext<'ast>>; - - fn format(&self) -> Self::Format<'_> { - FormatRefWithRule::new(self, FormatOperator) - } -} - -impl<'ast> IntoFormat> for Operator { - type Format = FormatOwnedWithRule>; - - fn into_format(self) -> Self::Format { - FormatOwnedWithRule::new(self, FormatOperator) - } -} - -impl FormatRule> for FormatOperator { - fn fmt(&self, item: &Operator, f: &mut PyFormatter) -> FormatResult<()> { - let operator = match item { - Operator::Add => "+", - Operator::Sub => "-", - Operator::Mult => "*", - Operator::MatMult => "@", - Operator::Div => "/", - Operator::Mod => "%", - Operator::Pow => "**", - Operator::LShift => "<<", - Operator::RShift => ">>", - Operator::BitOr => "|", - Operator::BitXor => "^", - Operator::BitAnd => "&", - Operator::FloorDiv => "//", - }; - - text(operator).fmt(f) - } -} - impl NeedsParentheses for ExprBinOp { fn needs_parentheses( &self, parent: AnyNodeRef, - _context: &PyFormatContext, + context: &PyFormatContext, ) -> OptionalParentheses { if parent.is_expr_await() && !self.op.is_pow() { OptionalParentheses::Always + } else if let Expr::Constant(constant) = self.left.as_ref() { + // Multiline strings are guaranteed to never fit, avoid adding unnecessary parentheses + if !constant.value.is_implicit_concatenated() + && is_multiline_string(constant, context.source()) + && has_parentheses(&self.right, context).is_some() + && !context.comments().has_dangling(self) + && !context.comments().has(self.left.as_ref()) + && !context.comments().has(self.right.as_ref()) + { + OptionalParentheses::Never + } else { + OptionalParentheses::Multiline + } } else { OptionalParentheses::Multiline } diff --git a/crates/ruff_python_formatter/src/expression/expr_bool_op.rs b/crates/ruff_python_formatter/src/expression/expr_bool_op.rs index 8b2f9feeda..27e511dd96 100644 --- a/crates/ruff_python_formatter/src/expression/expr_bool_op.rs +++ b/crates/ruff_python_formatter/src/expression/expr_bool_op.rs @@ -1,80 +1,18 @@ -use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWithOptions}; +use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{BoolOp, Expr, ExprBoolOp}; +use ruff_python_ast::{BoolOp, ExprBoolOp}; -use crate::comments::leading_comments; -use crate::expression::parentheses::{ - in_parentheses_only_group, in_parentheses_only_soft_line_break_or_space, NeedsParentheses, - OptionalParentheses, -}; +use crate::expression::binary_like::BinaryLike; +use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; use crate::prelude::*; -use super::parentheses::is_expression_parenthesized; - #[derive(Default)] -pub struct FormatExprBoolOp { - layout: BoolOpLayout, -} - -#[derive(Default, Copy, Clone)] -pub enum BoolOpLayout { - #[default] - Default, - Chained, -} - -impl FormatRuleWithOptions> for FormatExprBoolOp { - type Options = BoolOpLayout; - fn with_options(mut self, options: Self::Options) -> Self { - self.layout = options; - self - } -} +pub struct FormatExprBoolOp; impl FormatNodeRule for FormatExprBoolOp { + #[inline] fn fmt_fields(&self, item: &ExprBoolOp, f: &mut PyFormatter) -> FormatResult<()> { - let ExprBoolOp { - range: _, - op, - values, - } = item; - - let inner = format_with(|f: &mut PyFormatter| { - let mut values = values.iter(); - let comments = f.context().comments().clone(); - - let Some(first) = values.next() else { - return Ok(()); - }; - - FormatValue { value: first }.fmt(f)?; - - for value in values { - let leading_value_comments = comments.leading(value); - // Format the expressions leading comments **before** the operator - if leading_value_comments.is_empty() { - write!(f, [in_parentheses_only_soft_line_break_or_space()])?; - } else { - write!( - f, - [hard_line_break(), leading_comments(leading_value_comments)] - )?; - } - - write!(f, [op.format(), space()])?; - - FormatValue { value }.fmt(f)?; - } - - Ok(()) - }); - - if matches!(self.layout, BoolOpLayout::Chained) { - // Chained boolean operations should not be given a new group - inner.fmt(f) - } else { - in_parentheses_only_group(&inner).fmt(f) - } + BinaryLike::Bool(item).fmt(f) } } @@ -88,24 +26,6 @@ impl NeedsParentheses for ExprBoolOp { } } -struct FormatValue<'a> { - value: &'a Expr, -} - -impl Format> for FormatValue<'_> { - fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { - match self.value { - Expr::BoolOp(bool_op) - if !is_expression_parenthesized(bool_op.into(), f.context().source()) => - { - // Mark chained boolean operations e.g. `x and y or z` and avoid creating a new group - write!(f, [bool_op.format().with_options(BoolOpLayout::Chained)]) - } - _ => write!(f, [in_parentheses_only_group(&self.value.format())]), - } - } -} - #[derive(Copy, Clone)] pub struct FormatBoolOp; @@ -132,6 +52,6 @@ impl FormatRule> for FormatBoolOp { BoolOp::Or => "or", }; - text(operator).fmt(f) + token(operator).fmt(f) } } diff --git a/crates/ruff_python_formatter/src/expression/expr_compare.rs b/crates/ruff_python_formatter/src/expression/expr_compare.rs index 2dd82e497b..8ca05d864a 100644 --- a/crates/ruff_python_formatter/src/expression/expr_compare.rs +++ b/crates/ruff_python_formatter/src/expression/expr_compare.rs @@ -1,62 +1,21 @@ -use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule}; +use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{CmpOp, ExprCompare}; +use ruff_python_ast::{CmpOp, Expr, ExprCompare}; -use crate::comments::{leading_comments, SourceComment}; -use crate::expression::parentheses::{ - in_parentheses_only_group, in_parentheses_only_soft_line_break_or_space, NeedsParentheses, - OptionalParentheses, -}; +use crate::comments::SourceComment; +use crate::expression::binary_like::BinaryLike; +use crate::expression::expr_constant::is_multiline_string; +use crate::expression::has_parentheses; +use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; use crate::prelude::*; #[derive(Default)] pub struct FormatExprCompare; impl FormatNodeRule for FormatExprCompare { + #[inline] fn fmt_fields(&self, item: &ExprCompare, f: &mut PyFormatter) -> FormatResult<()> { - let ExprCompare { - range: _, - left, - ops, - comparators, - } = item; - - let comments = f.context().comments().clone(); - - let inner = format_with(|f| { - write!(f, [in_parentheses_only_group(&left.format())])?; - - assert_eq!(comparators.len(), ops.len()); - - for (operator, comparator) in ops.iter().zip(comparators) { - let leading_comparator_comments = comments.leading(comparator); - if leading_comparator_comments.is_empty() { - write!(f, [in_parentheses_only_soft_line_break_or_space()])?; - } else { - // Format the expressions leading comments **before** the operator - write!( - f, - [ - hard_line_break(), - leading_comments(leading_comparator_comments) - ] - )?; - } - - write!( - f, - [ - operator.format(), - space(), - in_parentheses_only_group(&comparator.format()) - ] - )?; - } - - Ok(()) - }); - - in_parentheses_only_group(&inner).fmt(f) + BinaryLike::Compare(item).fmt(f) } fn fmt_dangling_comments( @@ -73,9 +32,24 @@ impl NeedsParentheses for ExprCompare { fn needs_parentheses( &self, _parent: AnyNodeRef, - _context: &PyFormatContext, + context: &PyFormatContext, ) -> OptionalParentheses { - OptionalParentheses::Multiline + if let Expr::Constant(constant) = self.left.as_ref() { + // Multiline strings are guaranteed to never fit, avoid adding unnecessary parentheses + if !constant.value.is_implicit_concatenated() + && is_multiline_string(constant, context.source()) + && !context.comments().has(self.left.as_ref()) + && self.comparators.first().is_some_and(|right| { + has_parentheses(right, context).is_some() && !context.comments().has(right) + }) + { + OptionalParentheses::Never + } else { + OptionalParentheses::Multiline + } + } else { + OptionalParentheses::Multiline + } } } @@ -113,6 +87,6 @@ impl FormatRule> for FormatCmpOp { CmpOp::NotIn => "not in", }; - text(operator).fmt(f) + token(operator).fmt(f) } } diff --git a/crates/ruff_python_formatter/src/expression/expr_constant.rs b/crates/ruff_python_formatter/src/expression/expr_constant.rs index 8f3de76916..0a86ecc114 100644 --- a/crates/ruff_python_formatter/src/expression/expr_constant.rs +++ b/crates/ruff_python_formatter/src/expression/expr_constant.rs @@ -35,18 +35,14 @@ impl FormatRuleWithOptions> for FormatExprCons impl FormatNodeRule for FormatExprConstant { fn fmt_fields(&self, item: &ExprConstant, f: &mut PyFormatter) -> FormatResult<()> { - let ExprConstant { - range: _, - value, - kind: _, - } = item; + let ExprConstant { range: _, value } = item; match value { - Constant::Ellipsis => text("...").fmt(f), - Constant::None => text("None").fmt(f), + Constant::Ellipsis => token("...").fmt(f), + Constant::None => token("None").fmt(f), Constant::Bool(value) => match value { - true => text("True").fmt(f), - false => text("False").fmt(f), + true => token("True").fmt(f), + false => token("False").fmt(f), }, Constant::Int(_) => FormatInt::new(item).fmt(f), Constant::Float(_) => FormatFloat::new(item).fmt(f), diff --git a/crates/ruff_python_formatter/src/expression/expr_dict.rs b/crates/ruff_python_formatter/src/expression/expr_dict.rs index 851898ee87..66630dac7c 100644 --- a/crates/ruff_python_formatter/src/expression/expr_dict.rs +++ b/crates/ruff_python_formatter/src/expression/expr_dict.rs @@ -34,12 +34,14 @@ impl Format> for KeyValuePair<'_> { f, [group(&format_args![ key.format(), - text(":"), + token(":"), space(), self.value.format() ])] ) } else { + // TODO(charlie): Make these dangling comments on the `ExprDict`, and identify them + // dynamically, so as to avoid the parent rendering its child's comments. let comments = f.context().comments().clone(); let leading_value_comments = comments.leading(self.value); write!( @@ -47,7 +49,7 @@ impl Format> for KeyValuePair<'_> { [ // make sure the leading comments are hoisted past the `**` leading_comments(leading_value_comments), - group(&format_args![text("**"), self.value.format()]) + group(&format_args![token("**"), self.value.format()]) ] ) } diff --git a/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs b/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs index 9b615d0461..4fcbbe35e9 100644 --- a/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs +++ b/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs @@ -1,5 +1,5 @@ use ruff_formatter::prelude::{ - format_args, format_with, group, soft_line_break_or_space, space, text, + format_args, format_with, group, soft_line_break_or_space, space, token, }; use ruff_formatter::write; use ruff_python_ast::node::AnyNodeRef; @@ -35,7 +35,7 @@ impl FormatNodeRule for FormatExprDictComp { "{", &group(&format_args!( group(&key.format()), - text(":"), + token(":"), space(), value.format(), soft_line_break_or_space(), diff --git a/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs b/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs index 706102df39..75d2ba2e84 100644 --- a/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs +++ b/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs @@ -1,9 +1,10 @@ -use ruff_formatter::{format_args, write, Buffer, FormatResult, FormatRuleWithOptions}; +use ruff_formatter::{format_args, write, FormatRuleWithOptions}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::ExprGeneratorExp; +use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::SourceComment; - use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses}; use crate::prelude::*; @@ -12,12 +13,13 @@ pub enum GeneratorExpParentheses { #[default] Default, - /// Skip parens if the generator is the only argument to a function and doesn't contain any - /// dangling comments. For example: + /// Skips the parentheses if they aren't present in the source code. Used when formatting call expressions + /// because the parentheses are optional if the generator is the **only** argument: + /// /// ```python /// all(x for y in z)` /// ``` - StripIfOnlyFunctionArg, + Preserve, } impl FormatRuleWithOptions> for FormatExprGeneratorExp { @@ -51,8 +53,9 @@ impl FormatNodeRule for FormatExprGeneratorExp { let comments = f.context().comments().clone(); let dangling = comments.dangling(item); - if self.parentheses == GeneratorExpParentheses::StripIfOnlyFunctionArg + if self.parentheses == GeneratorExpParentheses::Preserve && dangling.is_empty() + && !is_generator_parenthesized(item, f.context().source()) { write!( f, @@ -94,3 +97,36 @@ impl NeedsParentheses for ExprGeneratorExp { OptionalParentheses::Never } } + +fn is_generator_parenthesized(generator: &ExprGeneratorExp, source: &str) -> bool { + // / Count the number of open parentheses between the start of the tuple and the first element. + let open_parentheses_count = SimpleTokenizer::new( + source, + TextRange::new(generator.start(), generator.elt.start()), + ) + .skip_trivia() + .filter(|token| token.kind() == SimpleTokenKind::LParen) + .count(); + if open_parentheses_count == 0 { + return false; + } + + // Count the number of parentheses between the end of the first element and its trailing comma. + let close_parentheses_count = SimpleTokenizer::new( + source, + TextRange::new( + generator.elt.end(), + generator + .generators + .first() + .map_or(generator.end(), Ranged::start), + ), + ) + .skip_trivia() + .filter(|token| token.kind() == SimpleTokenKind::RParen) + .count(); + + // If the number of open parentheses is greater than the number of close parentheses, the generator + // is parenthesized. + open_parentheses_count > close_parentheses_count +} diff --git a/crates/ruff_python_formatter/src/expression/expr_if_exp.rs b/crates/ruff_python_formatter/src/expression/expr_if_exp.rs index e774b6d0b3..1b22fb568c 100644 --- a/crates/ruff_python_formatter/src/expression/expr_if_exp.rs +++ b/crates/ruff_python_formatter/src/expression/expr_if_exp.rs @@ -1,16 +1,46 @@ -use ruff_formatter::{format_args, write}; +use ruff_formatter::{write, FormatRuleWithOptions}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::ExprIfExp; +use ruff_python_ast::{Expr, ExprIfExp}; use crate::comments::leading_comments; use crate::expression::parentheses::{ - in_parentheses_only_group, in_parentheses_only_soft_line_break_or_space, NeedsParentheses, - OptionalParentheses, + in_parentheses_only_group, in_parentheses_only_soft_line_break_or_space, + is_expression_parenthesized, NeedsParentheses, OptionalParentheses, }; use crate::prelude::*; +#[derive(Default, Copy, Clone)] +pub enum ExprIfExpLayout { + #[default] + Default, + + /// The [`ExprIfExp`] is nested inside another [`ExprIfExp`], so it should not be given a new + /// group. For example, avoid grouping the `else` clause in: + /// ```python + /// clone._iterable_class = ( + /// NamedValuesListIterable + /// if named + /// else FlatValuesListIterable + /// if flat + /// else ValuesListIterable + /// ) + /// ``` + Nested, +} + #[derive(Default)] -pub struct FormatExprIfExp; +pub struct FormatExprIfExp { + layout: ExprIfExpLayout, +} + +impl FormatRuleWithOptions> for FormatExprIfExp { + type Options = ExprIfExpLayout; + + fn with_options(mut self, options: Self::Options) -> Self { + self.layout = options; + self + } +} impl FormatNodeRule for FormatExprIfExp { fn fmt_fields(&self, item: &ExprIfExp, f: &mut PyFormatter) -> FormatResult<()> { @@ -22,25 +52,33 @@ impl FormatNodeRule for FormatExprIfExp { } = item; let comments = f.context().comments().clone(); - // We place `if test` and `else orelse` on a single line, so the `test` and `orelse` leading - // comments go on the line before the `if` or `else` instead of directly ahead `test` or - // `orelse` - write!( - f, - [in_parentheses_only_group(&format_args![ - body.format(), - in_parentheses_only_soft_line_break_or_space(), - leading_comments(comments.leading(test.as_ref())), - text("if"), - space(), - test.format(), - in_parentheses_only_soft_line_break_or_space(), - leading_comments(comments.leading(orelse.as_ref())), - text("else"), - space(), - orelse.format() - ])] - ) + let inner = format_with(|f: &mut PyFormatter| { + // We place `if test` and `else orelse` on a single line, so the `test` and `orelse` leading + // comments go on the line before the `if` or `else` instead of directly ahead `test` or + // `orelse` + write!( + f, + [ + body.format(), + in_parentheses_only_soft_line_break_or_space(), + leading_comments(comments.leading(test.as_ref())), + token("if"), + space(), + test.format(), + in_parentheses_only_soft_line_break_or_space(), + leading_comments(comments.leading(orelse.as_ref())), + token("else"), + space(), + ] + )?; + + FormatOrElse { orelse }.fmt(f) + }); + + match self.layout { + ExprIfExpLayout::Default => in_parentheses_only_group(&inner).fmt(f), + ExprIfExpLayout::Nested => inner.fmt(f), + } } } @@ -53,3 +91,21 @@ impl NeedsParentheses for ExprIfExp { OptionalParentheses::Multiline } } + +#[derive(Debug)] +struct FormatOrElse<'a> { + orelse: &'a Expr, +} + +impl Format> for FormatOrElse<'_> { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { + match self.orelse { + Expr::IfExp(expr) + if !is_expression_parenthesized(expr.into(), f.context().source()) => + { + write!(f, [expr.format().with_options(ExprIfExpLayout::Nested)]) + } + _ => write!(f, [in_parentheses_only_group(&self.orelse.format())]), + } + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs b/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs index e225a8eaae..7e084055ac 100644 --- a/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs +++ b/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs @@ -8,6 +8,6 @@ pub struct FormatExprIpyEscapeCommand; impl FormatNodeRule for FormatExprIpyEscapeCommand { fn fmt_fields(&self, item: &ExprIpyEscapeCommand, f: &mut PyFormatter) -> FormatResult<()> { - source_text_slice(item.range(), ContainsNewlines::No).fmt(f) + source_text_slice(item.range()).fmt(f) } } diff --git a/crates/ruff_python_formatter/src/expression/expr_lambda.rs b/crates/ruff_python_formatter/src/expression/expr_lambda.rs index 3498325222..d2244596e0 100644 --- a/crates/ruff_python_formatter/src/expression/expr_lambda.rs +++ b/crates/ruff_python_formatter/src/expression/expr_lambda.rs @@ -21,7 +21,7 @@ impl FormatNodeRule for FormatExprLambda { let comments = f.context().comments().clone(); let dangling = comments.dangling(item); - write!(f, [text("lambda")])?; + write!(f, [token("lambda")])?; if let Some(parameters) = parameters { write!( @@ -35,7 +35,7 @@ impl FormatNodeRule for FormatExprLambda { )?; } - write!(f, [text(":")])?; + write!(f, [token(":")])?; if dangling.is_empty() { write!(f, [space()])?; @@ -43,6 +43,11 @@ impl FormatNodeRule for FormatExprLambda { write!(f, [dangling_comments(dangling)])?; } + // Insert hard line break if body has leading comment to ensure consistent formatting + if comments.has_leading(body.as_ref()) { + write!(f, [hard_line_break()])?; + } + write!(f, [body.format()]) } diff --git a/crates/ruff_python_formatter/src/expression/expr_name.rs b/crates/ruff_python_formatter/src/expression/expr_name.rs index e0585f55ab..b47021cf54 100644 --- a/crates/ruff_python_formatter/src/expression/expr_name.rs +++ b/crates/ruff_python_formatter/src/expression/expr_name.rs @@ -21,7 +21,7 @@ impl FormatNodeRule for FormatExprName { .text(f.context().source_code()) ); - write!(f, [source_text_slice(*range, ContainsNewlines::No)]) + write!(f, [source_text_slice(*range)]) } fn fmt_dangling_comments( diff --git a/crates/ruff_python_formatter/src/expression/expr_named_expr.rs b/crates/ruff_python_formatter/src/expression/expr_named_expr.rs index 01371565eb..2ec759ab5f 100644 --- a/crates/ruff_python_formatter/src/expression/expr_named_expr.rs +++ b/crates/ruff_python_formatter/src/expression/expr_named_expr.rs @@ -25,7 +25,7 @@ impl FormatNodeRule for FormatExprNamedExpr { f, [ group(&format_args!(target.format(), soft_line_break_or_space())), - text(":=") + token(":=") ] )?; diff --git a/crates/ruff_python_formatter/src/expression/expr_slice.rs b/crates/ruff_python_formatter/src/expression/expr_slice.rs index 01a49f852f..c8177e9f80 100644 --- a/crates/ruff_python_formatter/src/expression/expr_slice.rs +++ b/crates/ruff_python_formatter/src/expression/expr_slice.rs @@ -39,13 +39,13 @@ impl FormatNodeRule for FormatExprSlice { let slice_dangling_comments = comments.dangling(item.as_any_node_ref()); // Put the dangling comments (where the nodes are missing) into buckets let first_colon_partition_index = - slice_dangling_comments.partition_point(|x| x.slice().start() < first_colon.start()); + slice_dangling_comments.partition_point(|x| x.start() < first_colon.start()); let (dangling_lower_comments, dangling_upper_step_comments) = slice_dangling_comments.split_at(first_colon_partition_index); let (dangling_upper_comments, dangling_step_comments) = if let Some(second_colon) = &second_colon { let second_colon_partition_index = dangling_upper_step_comments - .partition_point(|x| x.slice().start() < second_colon.start()); + .partition_point(|x| x.start() < second_colon.start()); dangling_upper_step_comments.split_at(second_colon_partition_index) } else { // Without a second colon they remaining dangling comments belong between the first @@ -91,7 +91,7 @@ impl FormatNodeRule for FormatExprSlice { if !all_simple && lower.is_some() { space().fmt(f)?; } - text(":").fmt(f)?; + token(":").fmt(f)?; // No upper node, no need for a space, e.g. `x[a() :]` if !all_simple && upper.is_some() { space().fmt(f)?; @@ -125,7 +125,7 @@ impl FormatNodeRule for FormatExprSlice { if !all_simple && (upper.is_some() || step.is_none()) { space().fmt(f)?; } - text(":").fmt(f)?; + token(":").fmt(f)?; // No step node, no need for a space if !all_simple && step.is_some() { space().fmt(f)?; diff --git a/crates/ruff_python_formatter/src/expression/expr_starred.rs b/crates/ruff_python_formatter/src/expression/expr_starred.rs index 9bea9e6e87..da3e5e208c 100644 --- a/crates/ruff_python_formatter/src/expression/expr_starred.rs +++ b/crates/ruff_python_formatter/src/expression/expr_starred.rs @@ -21,7 +21,7 @@ impl FormatNodeRule for FormatExprStarred { let comments = f.context().comments().clone(); let dangling = comments.dangling(item); - write!(f, [text("*"), dangling_comments(dangling), value.format()]) + write!(f, [token("*"), dangling_comments(dangling), value.format()]) } fn fmt_dangling_comments( diff --git a/crates/ruff_python_formatter/src/expression/expr_subscript.rs b/crates/ruff_python_formatter/src/expression/expr_subscript.rs index 5eadfeb4d0..1e2a5c3d94 100644 --- a/crates/ruff_python_formatter/src/expression/expr_subscript.rs +++ b/crates/ruff_python_formatter/src/expression/expr_subscript.rs @@ -1,12 +1,11 @@ -use ruff_formatter::{format_args, write, FormatRuleWithOptions}; +use ruff_formatter::{write, FormatRuleWithOptions}; use ruff_python_ast::node::{AnyNodeRef, AstNode}; use ruff_python_ast::{Expr, ExprSubscript}; -use crate::comments::{trailing_comments, SourceComment}; - +use crate::comments::SourceComment; use crate::context::{NodeLevel, WithNodeLevel}; use crate::expression::expr_tuple::TupleParentheses; -use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; +use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses}; use crate::expression::CallChainLayout; use crate::prelude::*; @@ -67,15 +66,9 @@ impl FormatNodeRule for FormatExprSubscript { } }); - write!( - f, - [group(&format_args![ - text("["), - trailing_comments(dangling_comments), - soft_block_indent(&format_slice), - text("]") - ])] - ) + parenthesized("[", &format_slice, "]") + .with_dangling_comments(dangling_comments) + .fmt(f) } fn fmt_dangling_comments( diff --git a/crates/ruff_python_formatter/src/expression/expr_tuple.rs b/crates/ruff_python_formatter/src/expression/expr_tuple.rs index f62d40f138..cb3f848f2d 100644 --- a/crates/ruff_python_formatter/src/expression/expr_tuple.rs +++ b/crates/ruff_python_formatter/src/expression/expr_tuple.rs @@ -140,12 +140,12 @@ impl FormatNodeRule for FormatExprTuple { TupleParentheses::Preserve if !is_tuple_parenthesized(item, f.context().source()) => { - write!(f, [single.format(), text(",")]) + write!(f, [single.format(), token(",")]) } _ => // A single element tuple always needs parentheses and a trailing comma, except when inside of a subscript { - parenthesized("(", &format_args![single.format(), text(",")], ")") + parenthesized("(", &format_args![single.format(), token(",")], ")") .with_dangling_comments(dangling) .fmt(f) } @@ -166,7 +166,7 @@ impl FormatNodeRule for FormatExprTuple { _ => match self.parentheses { TupleParentheses::Never => { let separator = - format_with(|f| group(&format_args![text(","), space()]).fmt(f)); + format_with(|f| group(&format_args![token(","), space()]).fmt(f)); f.join_with(separator) .entries(elts.iter().formatted()) .finish() diff --git a/crates/ruff_python_formatter/src/expression/expr_unary_op.rs b/crates/ruff_python_formatter/src/expression/expr_unary_op.rs index f83ac33a4c..2a75c243a4 100644 --- a/crates/ruff_python_formatter/src/expression/expr_unary_op.rs +++ b/crates/ruff_python_formatter/src/expression/expr_unary_op.rs @@ -26,7 +26,7 @@ impl FormatNodeRule for FormatExprUnaryOp { UnaryOp::USub => "-", }; - text(operator).fmt(f)?; + token(operator).fmt(f)?; let comments = f.context().comments().clone(); diff --git a/crates/ruff_python_formatter/src/expression/expr_yield.rs b/crates/ruff_python_formatter/src/expression/expr_yield.rs index 4d8334c64f..a0d9526dc6 100644 --- a/crates/ruff_python_formatter/src/expression/expr_yield.rs +++ b/crates/ruff_python_formatter/src/expression/expr_yield.rs @@ -87,14 +87,14 @@ impl Format> for AnyExpressionYield<'_> { write!( f, [ - text(keyword), + token(keyword), space(), maybe_parenthesize_expression(val, self, Parenthesize::Optional) ] )?; } else { // ExprYieldFrom always has Some(value) so we should never get a bare `yield from` - write!(f, [&text(keyword)])?; + write!(f, [&token(keyword)])?; } Ok(()) } diff --git a/crates/ruff_python_formatter/src/expression/mod.rs b/crates/ruff_python_formatter/src/expression/mod.rs index 4e525bebc9..413b732a53 100644 --- a/crates/ruff_python_formatter/src/expression/mod.rs +++ b/crates/ruff_python_formatter/src/expression/mod.rs @@ -19,6 +19,7 @@ use crate::expression::parentheses::{ }; use crate::prelude::*; +mod binary_like; pub(crate) mod expr_attribute; pub(crate) mod expr_await; pub(crate) mod expr_bin_op; @@ -48,6 +49,7 @@ pub(crate) mod expr_unary_op; pub(crate) mod expr_yield; pub(crate) mod expr_yield_from; pub(crate) mod number; +mod operator; pub(crate) mod parentheses; pub(crate) mod string; @@ -247,10 +249,13 @@ impl Format> for MaybeParenthesizeExpression<'_> { if format_expression.inspect(f)?.will_break() { // The group here is necessary because `format_expression` may contain IR elements // that refer to the group id - group(&format_expression) - .with_group_id(Some(group_id)) - .should_expand(true) - .fmt(f) + group(&format_args![ + token("("), + soft_block_indent(&format_expression), + token(")") + ]) + .with_group_id(Some(group_id)) + .fmt(f) } else { // Only add parentheses if it makes the expression fit on the line. // Using the flat version as the most expanded version gives a left-to-right splitting behavior @@ -264,9 +269,9 @@ impl Format> for MaybeParenthesizeExpression<'_> { // Variant 2: // Try to fit the expression by adding parentheses and indenting the expression. group(&format_args![ - text("("), + token("("), soft_block_indent(&format_expression), - text(")") + token(")") ]) .with_group_id(Some(group_id)) .should_expand(true), @@ -360,9 +365,9 @@ impl<'ast> IntoFormat> for Expr { /// Tests if it is safe to omit the optional parentheses. /// /// We prefer parentheses at least in the following cases: -/// * The expression contains more than one unparenthesized expression with the same priority. For example, +/// * The expression contains more than one unparenthesized expression with the same precedence. For example, /// the expression `a * b * c` contains two multiply operations. We prefer parentheses in that case. -/// `(a * b) * c` or `a * b + c` are okay, because the subexpression is parenthesized, or the expression uses operands with a lower priority +/// `(a * b) * c` or `a * b + c` are okay, because the subexpression is parenthesized, or the expression uses operands with a lower precedence /// * The expression contains at least one parenthesized sub expression (optimization to avoid unnecessary work) /// /// This mimics Black's [`_maybe_split_omitting_optional_parens`](https://github.com/psf/black/blob/d1248ca9beaf0ba526d265f4108836d89cf551b7/src/black/linegen.py#L746-L820) @@ -370,11 +375,11 @@ fn can_omit_optional_parentheses(expr: &Expr, context: &PyFormatContext) -> bool let mut visitor = CanOmitOptionalParenthesesVisitor::new(context); visitor.visit_subexpression(expr); - if visitor.max_priority == OperatorPriority::None { + if visitor.max_precedence == OperatorPrecedence::None { true - } else if visitor.max_priority_count > 1 { + } else if visitor.pax_precedence_count > 1 { false - } else if visitor.max_priority == OperatorPriority::Attribute { + } else if visitor.max_precedence == OperatorPrecedence::Attribute { true } else if !visitor.any_parenthesized_expressions { // Only use the more complex IR when there is any expression that we can possibly split by @@ -383,10 +388,10 @@ fn can_omit_optional_parentheses(expr: &Expr, context: &PyFormatContext) -> bool // Only use the layout if the first or last expression has parentheses of some sort, and // those parentheses are non-empty. let first_parenthesized = visitor.first.is_some_and(|first| { - has_parentheses(first, context).is_some_and(|parentheses| parentheses.is_non_empty()) + has_parentheses(first, context).is_some_and(OwnParentheses::is_non_empty) }); let last_parenthesized = visitor.last.is_some_and(|last| { - has_parentheses(last, context).is_some_and(|parentheses| parentheses.is_non_empty()) + has_parentheses(last, context).is_some_and(OwnParentheses::is_non_empty) }); first_parenthesized || last_parenthesized } @@ -394,8 +399,8 @@ fn can_omit_optional_parentheses(expr: &Expr, context: &PyFormatContext) -> bool #[derive(Clone, Debug)] struct CanOmitOptionalParenthesesVisitor<'input> { - max_priority: OperatorPriority, - max_priority_count: u32, + max_precedence: OperatorPrecedence, + pax_precedence_count: u32, any_parenthesized_expressions: bool, last: Option<&'input Expr>, first: Option<&'input Expr>, @@ -406,26 +411,26 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { fn new(context: &'input PyFormatContext) -> Self { Self { context, - max_priority: OperatorPriority::None, - max_priority_count: 0, + max_precedence: OperatorPrecedence::None, + pax_precedence_count: 0, any_parenthesized_expressions: false, last: None, first: None, } } - fn update_max_priority(&mut self, current_priority: OperatorPriority) { - self.update_max_priority_with_count(current_priority, 1); + fn update_max_precedence(&mut self, precedence: OperatorPrecedence) { + self.update_max_precedence_with_count(precedence, 1); } - fn update_max_priority_with_count(&mut self, current_priority: OperatorPriority, count: u32) { - match self.max_priority.cmp(¤t_priority) { + fn update_max_precedence_with_count(&mut self, precedence: OperatorPrecedence, count: u32) { + match self.max_precedence.cmp(&precedence) { Ordering::Less => { - self.max_priority_count = count; - self.max_priority = current_priority; + self.pax_precedence_count = count; + self.max_precedence = precedence; } Ordering::Equal => { - self.max_priority_count += count; + self.pax_precedence_count += count; } Ordering::Greater => {} } @@ -452,8 +457,8 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { range: _, op: _, values, - }) => self.update_max_priority_with_count( - OperatorPriority::BooleanOperation, + }) => self.update_max_precedence_with_count( + OperatorPrecedence::BooleanOperation, values.len().saturating_sub(1) as u32, ), Expr::BinOp(ast::ExprBinOp { @@ -461,11 +466,11 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { left: _, right: _, range: _, - }) => self.update_max_priority(OperatorPriority::from(*op)), + }) => self.update_max_precedence(OperatorPrecedence::from(*op)), Expr::IfExp(_) => { // + 1 for the if and one for the else - self.update_max_priority_with_count(OperatorPriority::Conditional, 2); + self.update_max_precedence_with_count(OperatorPrecedence::Conditional, 2); } // It's impossible for a file smaller or equal to 4GB to contain more than 2^32 comparisons @@ -477,7 +482,10 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { ops, comparators: _, }) => { - self.update_max_priority_with_count(OperatorPriority::Comparator, ops.len() as u32); + self.update_max_precedence_with_count( + OperatorPrecedence::Comparator, + ops.len() as u32, + ); } Expr::Call(ast::ExprCall { range: _, @@ -503,7 +511,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { operand: _, }) => { if op.is_invert() { - self.update_max_priority(OperatorPriority::BitwiseInversion); + self.update_max_precedence(OperatorPrecedence::BitwiseInversion); } } @@ -516,7 +524,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { }) => { self.visit_expr(value); if has_parentheses(value, self.context).is_some() { - self.update_max_priority(OperatorPriority::Attribute); + self.update_max_precedence(OperatorPrecedence::Attribute); } self.last = Some(expr); return; @@ -538,7 +546,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> { implicit_concatenated: true, .. }) => { - self.update_max_priority(OperatorPriority::String); + self.update_max_precedence(OperatorPrecedence::String); } Expr::NamedExpr(_) @@ -624,20 +632,21 @@ impl CallChainLayout { loop { match expr { ExpressionRef::Attribute(ast::ExprAttribute { value, .. }) => { - expr = ExpressionRef::from(value.as_ref()); // ``` // f().g // ^^^ value // data[:100].T // ^^^^^^^^^^ value // ``` - if matches!(value.as_ref(), Expr::Call(_) | Expr::Subscript(_)) { - attributes_after_parentheses += 1; - } else if is_expression_parenthesized(expr, source) { + if is_expression_parenthesized(value.into(), source) { // `(a).b`. We preserve these parentheses so don't recurse attributes_after_parentheses += 1; break; + } else if matches!(value.as_ref(), Expr::Call(_) | Expr::Subscript(_)) { + attributes_after_parentheses += 1; } + + expr = ExpressionRef::from(value.as_ref()); } // ``` // f() @@ -660,9 +669,11 @@ impl CallChainLayout { if is_expression_parenthesized(expr, source) { attributes_after_parentheses += 1; } + break; } } + // We preserve these parentheses so don't recurse if is_expression_parenthesized(expr, source) { break; @@ -695,7 +706,7 @@ impl CallChainLayout { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, is_macro::Is)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub(crate) enum OwnParentheses { /// The node has parentheses, but they are empty (e.g., `[]` or `f()`). Empty, @@ -703,6 +714,12 @@ pub(crate) enum OwnParentheses { NonEmpty, } +impl OwnParentheses { + const fn is_non_empty(self) -> bool { + matches!(self, OwnParentheses::NonEmpty) + } +} + /// Returns the [`OwnParentheses`] value for a given [`Expr`], to indicate whether it has its /// own parentheses or is itself parenthesized. /// @@ -774,38 +791,45 @@ pub(crate) fn has_own_parentheses( } } +/// The precedence of [python operators](https://docs.python.org/3/reference/expressions.html#operator-precedence) from +/// highest to lowest priority. +/// +/// Ruff uses the operator precedence to decide in which order to split operators: +/// Operators with a lower precedence split before higher-precedence operators. +/// Splitting by precedence ensures that the visual grouping reflects the precedence. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] -enum OperatorPriority { +enum OperatorPrecedence { None, Attribute, - Comparator, Exponential, BitwiseInversion, Multiplicative, Additive, Shift, BitwiseAnd, - BitwiseOr, BitwiseXor, + BitwiseOr, + Comparator, + // Implicit string concatenation String, BooleanOperation, Conditional, } -impl From for OperatorPriority { +impl From for OperatorPrecedence { fn from(value: Operator) -> Self { match value { - Operator::Add | Operator::Sub => OperatorPriority::Additive, + Operator::Add | Operator::Sub => OperatorPrecedence::Additive, Operator::Mult | Operator::MatMult | Operator::Div | Operator::Mod - | Operator::FloorDiv => OperatorPriority::Multiplicative, - Operator::Pow => OperatorPriority::Exponential, - Operator::LShift | Operator::RShift => OperatorPriority::Shift, - Operator::BitOr => OperatorPriority::BitwiseOr, - Operator::BitXor => OperatorPriority::BitwiseXor, - Operator::BitAnd => OperatorPriority::BitwiseAnd, + | Operator::FloorDiv => OperatorPrecedence::Multiplicative, + Operator::Pow => OperatorPrecedence::Exponential, + Operator::LShift | Operator::RShift => OperatorPrecedence::Shift, + Operator::BitOr => OperatorPrecedence::BitwiseOr, + Operator::BitXor => OperatorPrecedence::BitwiseXor, + Operator::BitAnd => OperatorPrecedence::BitwiseAnd, } } } diff --git a/crates/ruff_python_formatter/src/expression/number.rs b/crates/ruff_python_formatter/src/expression/number.rs index bef3b476e0..130640f48f 100644 --- a/crates/ruff_python_formatter/src/expression/number.rs +++ b/crates/ruff_python_formatter/src/expression/number.rs @@ -24,8 +24,8 @@ impl Format> for FormatInt<'_> { let normalized = normalize_integer(content); match normalized { - Cow::Borrowed(_) => source_text_slice(range, ContainsNewlines::No).fmt(f), - Cow::Owned(normalized) => dynamic_text(&normalized, Some(range.start())).fmt(f), + Cow::Borrowed(_) => source_text_slice(range).fmt(f), + Cow::Owned(normalized) => text(&normalized, Some(range.start())).fmt(f), } } } @@ -49,8 +49,8 @@ impl Format> for FormatFloat<'_> { let normalized = normalize_floating_number(content); match normalized { - Cow::Borrowed(_) => source_text_slice(range, ContainsNewlines::No).fmt(f), - Cow::Owned(normalized) => dynamic_text(&normalized, Some(range.start())).fmt(f), + Cow::Borrowed(_) => source_text_slice(range).fmt(f), + Cow::Owned(normalized) => text(&normalized, Some(range.start())).fmt(f), } } } @@ -75,14 +75,14 @@ impl Format> for FormatComplex<'_> { match normalized { Cow::Borrowed(_) => { - source_text_slice(range.sub_end(TextSize::from(1)), ContainsNewlines::No).fmt(f)?; + source_text_slice(range.sub_end(TextSize::from(1))).fmt(f)?; } Cow::Owned(normalized) => { - dynamic_text(&normalized, Some(range.start())).fmt(f)?; + text(&normalized, Some(range.start())).fmt(f)?; } } - text("j").fmt(f) + token("j").fmt(f) } } diff --git a/crates/ruff_python_formatter/src/expression/operator.rs b/crates/ruff_python_formatter/src/expression/operator.rs new file mode 100644 index 0000000000..791de6e6e7 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/operator.rs @@ -0,0 +1,44 @@ +use crate::prelude::*; +use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule}; +use ruff_python_ast::Operator; + +#[derive(Copy, Clone)] +pub struct FormatOperator; + +impl<'ast> AsFormat> for Operator { + type Format<'a> = FormatRefWithRule<'a, Operator, FormatOperator, PyFormatContext<'ast>>; + + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, FormatOperator) + } +} + +impl<'ast> IntoFormat> for Operator { + type Format = FormatOwnedWithRule>; + + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, FormatOperator) + } +} + +impl FormatRule> for FormatOperator { + fn fmt(&self, item: &Operator, f: &mut PyFormatter) -> FormatResult<()> { + let operator = match item { + Operator::Add => "+", + Operator::Sub => "-", + Operator::Mult => "*", + Operator::MatMult => "@", + Operator::Div => "/", + Operator::Mod => "%", + Operator::Pow => "**", + Operator::LShift => "<<", + Operator::RShift => ">>", + Operator::BitOr => "|", + Operator::BitXor => "^", + Operator::BitAnd => "&", + Operator::FloorDiv => "//", + }; + + token(operator).fmt(f) + } +} diff --git a/crates/ruff_python_formatter/src/expression/parentheses.rs b/crates/ruff_python_formatter/src/expression/parentheses.rs index 0a0b85a864..c048046683 100644 --- a/crates/ruff_python_formatter/src/expression/parentheses.rs +++ b/crates/ruff_python_formatter/src/expression/parentheses.rs @@ -47,7 +47,7 @@ where text_len > 5 && text_len <= context.options().line_width().value() as usize - - context.options().indent_width() as usize + - context.options().indent_width().value() as usize } pub(crate) trait NeedsParentheses { @@ -172,10 +172,10 @@ impl<'ast> Format> for FormatParenthesized<'_, 'ast> { fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { let inner = format_with(|f| { group(&format_args![ - text(self.left), + token(self.left), dangling_open_parenthesis_comments(self.comments), soft_block_indent(&Arguments::from(&self.content)), - text(self.right) + token(self.right) ]) .fmt(f) }); @@ -232,13 +232,13 @@ impl<'ast> Format> for FormatOptionalParentheses<'_, 'ast> write!( f, [group(&format_args![ - if_group_breaks(&text("(")), + if_group_breaks(&token("(")), indent_if_group_breaks( &format_args![soft_line_break(), Arguments::from(&self.content)], parens_id ), soft_line_break(), - if_group_breaks(&text(")")) + if_group_breaks(&token(")")) ]) .with_group_id(Some(parens_id))] ) @@ -314,23 +314,41 @@ pub(crate) struct FormatInParenthesesOnlyGroup<'content, 'ast> { impl<'ast> Format> for FormatInParenthesesOnlyGroup<'_, 'ast> { fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { - match f.context().node_level() { - NodeLevel::Expression(Some(parentheses_id)) => { - // If this content is enclosed by a group that adds the optional parentheses, then *disable* - // this group *except* if the optional parentheses are shown. - conditional_group( - &Arguments::from(&self.content), - Condition::if_group_breaks(parentheses_id), - ) - .fmt(f) - } - NodeLevel::ParenthesizedExpression => { - // Unconditionally group the content if it is not enclosed by an optional parentheses group. - group(&Arguments::from(&self.content)).fmt(f) - } - NodeLevel::Expression(None) | NodeLevel::TopLevel | NodeLevel::CompoundStatement => { - Arguments::from(&self.content).fmt(f) - } + write_in_parentheses_only_group_start_tag(f); + Arguments::from(&self.content).fmt(f)?; + write_in_parentheses_only_group_end_tag(f); + Ok(()) + } +} + +pub(super) fn write_in_parentheses_only_group_start_tag(f: &mut PyFormatter) { + match f.context().node_level() { + NodeLevel::Expression(Some(parentheses_id)) => { + f.write_element(FormatElement::Tag(tag::Tag::StartConditionalGroup( + tag::ConditionalGroup::new(Condition::if_group_breaks(parentheses_id)), + ))); + } + NodeLevel::ParenthesizedExpression => { + // Unconditionally group the content if it is not enclosed by an optional parentheses group. + f.write_element(FormatElement::Tag(tag::Tag::StartGroup(tag::Group::new()))); + } + NodeLevel::Expression(None) | NodeLevel::TopLevel | NodeLevel::CompoundStatement => { + // No group + } + } +} + +pub(super) fn write_in_parentheses_only_group_end_tag(f: &mut PyFormatter) { + match f.context().node_level() { + NodeLevel::Expression(Some(_)) => { + f.write_element(FormatElement::Tag(tag::Tag::EndConditionalGroup)); + } + NodeLevel::ParenthesizedExpression => { + // Unconditionally group the content if it is not enclosed by an optional parentheses group. + f.write_element(FormatElement::Tag(tag::Tag::EndGroup)); + } + NodeLevel::Expression(None) | NodeLevel::TopLevel | NodeLevel::CompoundStatement => { + // No group } } } @@ -375,7 +393,7 @@ impl Format> for FormatEmptyParenthesized<'_> { write!( f, [group(&format_args![ - text(self.left), + token(self.left), // end-of-line comments trailing_comments(&self.comments[..end_of_line_split]), // Avoid unstable formatting with @@ -390,7 +408,7 @@ impl Format> for FormatEmptyParenthesized<'_> { (!self.comments[..end_of_line_split].is_empty()).then_some(hard_line_break()), // own line comments, which need to be indented soft_block_indent(&dangling_comments(&self.comments[end_of_line_split..])), - text(self.right) + token(self.right) ])] ) } diff --git a/crates/ruff_python_formatter/src/expression/string.rs b/crates/ruff_python_formatter/src/expression/string.rs index e6178ef0c3..98546335a7 100644 --- a/crates/ruff_python_formatter/src/expression/string.rs +++ b/crates/ruff_python_formatter/src/expression/string.rs @@ -2,9 +2,9 @@ use std::borrow::Cow; use bitflags::bitflags; -use ruff_formatter::{format_args, write, FormatError, FormatOptions, TabWidth}; +use ruff_formatter::{format_args, write, FormatError}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{self as ast, ExprConstant, ExprFString}; +use ruff_python_ast::{self as ast, Constant, ExprConstant, ExprFString, ExpressionRef}; use ruff_python_parser::lexer::{lex_starts_at, LexicalError, LexicalErrorType}; use ruff_python_parser::{Mode, Tok}; use ruff_source_file::Locator; @@ -24,12 +24,26 @@ enum Quoting { Preserve, } +#[derive(Clone, Debug)] pub(super) enum AnyString<'a> { Constant(&'a ExprConstant), FString(&'a ExprFString), } impl<'a> AnyString<'a> { + pub(crate) fn from_expression(expression: &'a Expr) -> Option> { + match expression { + Expr::Constant( + constant @ ExprConstant { + value: Constant::Str(_) | Constant::Bytes(_), + .. + }, + ) => Some(AnyString::Constant(constant)), + Expr::FString(fstring) => Some(AnyString::FString(fstring)), + _ => None, + } + } + fn quoting(&self, locator: &Locator) -> Quoting { match self { Self::Constant(_) => Quoting::CanChange, @@ -50,7 +64,7 @@ impl<'a> AnyString<'a> { } /// Returns `true` if the string is implicitly concatenated. - fn implicit_concatenated(&self) -> bool { + pub(super) fn is_implicit_concatenated(&self) -> bool { match self { Self::Constant(ExprConstant { value, .. }) => value.is_implicit_concatenated(), Self::FString(ExprFString { @@ -79,6 +93,15 @@ impl<'a> From<&AnyString<'a>> for AnyNodeRef<'a> { } } +impl<'a> From<&AnyString<'a>> for ExpressionRef<'a> { + fn from(value: &AnyString<'a>) -> Self { + match value { + AnyString::Constant(expr) => ExpressionRef::Constant(expr), + AnyString::FString(expr) => ExpressionRef::FString(expr), + } + } +} + pub(super) struct FormatString<'a> { string: &'a AnyString<'a>, layout: StringLayout, @@ -89,11 +112,15 @@ pub enum StringLayout { #[default] Default, DocString, - ImplicitConcatenatedBinaryLeftSide, + /// An implicit concatenated string in a binary like (e.g. `a + b` or `a < b`) expression. + /// + /// Formats the implicit concatenated string parts without the enclosing group because the group + /// is added by the binary like formatting. + ImplicitConcatenatedStringInBinaryLike, } impl<'a> FormatString<'a> { - pub(super) fn new(string: &'a AnyString) -> Self { + pub(super) fn new(string: &'a AnyString<'a>) -> Self { if let AnyString::Constant(constant) = string { debug_assert!(constant.value.is_str() || constant.value.is_bytes()); } @@ -111,31 +138,28 @@ impl<'a> FormatString<'a> { impl<'a> Format> for FormatString<'a> { fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { + let locator = f.context().locator(); match self.layout { StringLayout::Default => { - if self.string.implicit_concatenated() { + if self.string.is_implicit_concatenated() { in_parentheses_only_group(&FormatStringContinuation::new(self.string)).fmt(f) } else { - FormatStringPart::new( - self.string.range(), - self.string.quoting(&f.context().locator()), - &f.context().locator(), - f.options().quote_style(), - ) - .fmt(f) + StringPart::from_source(self.string.range(), &locator) + .normalize( + self.string.quoting(&locator), + &locator, + f.options().quote_style(), + ) + .fmt(f) } } StringLayout::DocString => { - let string_part = FormatStringPart::new( - self.string.range(), - // f-strings can't be docstrings - Quoting::CanChange, - &f.context().locator(), - f.options().quote_style(), - ); - format_docstring(&string_part, f) + let string_part = StringPart::from_source(self.string.range(), &locator); + let normalized = + string_part.normalize(Quoting::CanChange, &locator, f.options().quote_style()); + format_docstring(&normalized, f) } - StringLayout::ImplicitConcatenatedBinaryLeftSide => { + StringLayout::ImplicitConcatenatedStringInBinaryLike => { FormatStringContinuation::new(self.string).fmt(f) } } @@ -212,7 +236,7 @@ impl Format> for FormatStringContinuation<'_> { // ) // ``` let leading_comments_end = dangling_comments - .partition_point(|comment| comment.slice().start() <= token_range.start()); + .partition_point(|comment| comment.start() <= token_range.start()); let (leading_part_comments, rest) = dangling_comments.split_at(leading_comments_end); @@ -227,21 +251,19 @@ impl Format> for FormatStringContinuation<'_> { comment.line_position().is_end_of_line() && !locator.contains_line_break(TextRange::new( token_range.end(), - comment.slice().start(), + comment.start(), )) }); let (trailing_part_comments, rest) = rest.split_at(trailing_comments_end); + let part = StringPart::from_source(token_range, &locator); + let normalized = + part.normalize(self.string.quoting(&locator), &locator, quote_style); joiner.entry(&format_args![ line_suffix_boundary(), leading_comments(leading_part_comments), - FormatStringPart::new( - token_range, - self.string.quoting(&locator), - &locator, - quote_style, - ), + normalized, trailing_comments(trailing_part_comments) ]); @@ -262,21 +284,20 @@ impl Format> for FormatStringContinuation<'_> { } } -struct FormatStringPart { +#[derive(Debug)] +struct StringPart { + /// The prefix. prefix: StringPrefix, - preferred_quotes: StringQuotes, - range: TextRange, - is_raw_string: bool, + + /// The actual quotes of the string in the source + quotes: StringQuotes, + + /// The range of the string's content (full range minus quotes and prefix) + content_range: TextRange, } -impl Ranged for FormatStringPart { - fn range(&self) -> TextRange { - self.range - } -} - -impl FormatStringPart { - fn new(range: TextRange, quoting: Quoting, locator: &Locator, quote_style: QuoteStyle) -> Self { +impl StringPart { + fn from_source(range: TextRange, locator: &Locator) -> Self { let string_content = locator.slice(range); let prefix = StringPrefix::parse(string_content); @@ -290,46 +311,80 @@ impl FormatStringPart { ); let raw_content_range = relative_raw_content_range + range.start(); - let raw_content = &string_content[relative_raw_content_range]; - let is_raw_string = prefix.is_raw_string(); + Self { + prefix, + content_range: raw_content_range, + quotes, + } + } + + /// Computes the strings preferred quotes and normalizes its content. + fn normalize<'a>( + self, + quoting: Quoting, + locator: &'a Locator, + quote_style: QuoteStyle, + ) -> NormalizedString<'a> { + let raw_content = locator.slice(self.content_range); + let preferred_quotes = match quoting { - Quoting::Preserve => quotes, + Quoting::Preserve => self.quotes, Quoting::CanChange => { - if is_raw_string { - preferred_quotes_raw(raw_content, quotes, quote_style) + if self.prefix.is_raw_string() { + preferred_quotes_raw(raw_content, self.quotes, quote_style) } else { - preferred_quotes(raw_content, quotes, quote_style) + preferred_quotes(raw_content, self.quotes, quote_style) } } }; - Self { - prefix, - range: raw_content_range, + let normalized = normalize_string( + locator.slice(self.content_range), preferred_quotes, - is_raw_string, + self.prefix.is_raw_string(), + ); + + NormalizedString { + prefix: self.prefix, + content_range: self.content_range, + text: normalized, + quotes: preferred_quotes, } } } -impl Format> for FormatStringPart { - fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { - let (normalized, contains_newlines) = normalize_string( - f.context().locator().slice(self.range), - self.preferred_quotes, - self.is_raw_string, - ); +#[derive(Debug)] +struct NormalizedString<'a> { + prefix: StringPrefix, - write!(f, [self.prefix, self.preferred_quotes])?; - match normalized { + /// The quotes of the normalized string (preferred quotes) + quotes: StringQuotes, + + /// The range of the string's content in the source (minus prefix and quotes). + content_range: TextRange, + + /// The normalized text + text: Cow<'a, str>, +} + +impl Ranged for NormalizedString<'_> { + fn range(&self) -> TextRange { + self.content_range + } +} + +impl Format> for NormalizedString<'_> { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { + write!(f, [self.prefix, self.quotes])?; + match &self.text { Cow::Borrowed(_) => { - source_text_slice(self.range(), contains_newlines).fmt(f)?; + source_text_slice(self.range()).fmt(f)?; } Cow::Owned(normalized) => { - dynamic_text(&normalized, Some(self.start())).fmt(f)?; + text(normalized, Some(self.start())).fmt(f)?; } } - self.preferred_quotes.fmt(f) + self.quotes.fmt(f) } } @@ -386,17 +441,17 @@ impl Format> for StringPrefix { // Retain the casing for the raw prefix: // https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#r-strings-and-r-strings if self.contains(StringPrefix::RAW) { - text("r").fmt(f)?; + token("r").fmt(f)?; } else if self.contains(StringPrefix::RAW_UPPER) { - text("R").fmt(f)?; + token("R").fmt(f)?; } if self.contains(StringPrefix::BYTE) { - text("b").fmt(f)?; + token("b").fmt(f)?; } if self.contains(StringPrefix::F_STRING) { - text("f").fmt(f)?; + token("f").fmt(f)?; } // Remove the unicode prefix `u` if any because it is meaningless in Python 3+. @@ -596,7 +651,7 @@ impl Format> for StringQuotes { (QuoteStyle::Double, true) => "\"\"\"", }; - text(quotes).fmt(f) + token(quotes).fmt(f) } } @@ -604,11 +659,7 @@ impl Format> for StringQuotes { /// with the provided `style`. /// /// Returns the normalized string and whether it contains new lines. -fn normalize_string( - input: &str, - quotes: StringQuotes, - is_raw: bool, -) -> (Cow, ContainsNewlines) { +fn normalize_string(input: &str, quotes: StringQuotes, is_raw: bool) -> Cow { // The normalized string if `input` is not yet normalized. // `output` must remain empty if `input` is already normalized. let mut output = String::new(); @@ -616,8 +667,6 @@ fn normalize_string( // If `last_index` is `0` at the end, then the input is already normalized and can be returned as is. let mut last_index = 0; - let mut newlines = ContainsNewlines::No; - let style = quotes.style; let preferred_quote = style.as_char(); let opposite_quote = style.invert().as_char(); @@ -638,9 +687,6 @@ fn normalize_string( } last_index = index + '\r'.len_utf8(); - newlines = ContainsNewlines::Yes; - } else if c == '\n' { - newlines = ContainsNewlines::Yes; } else if !quotes.triple && !is_raw { if c == '\\' { if let Some(next) = input.as_bytes().get(index + 1).copied().map(char::from) { @@ -675,28 +721,26 @@ fn normalize_string( Cow::Owned(output) }; - (normalized, newlines) + normalized } /// For docstring indentation, black counts spaces as 1 and tabs by increasing the indentation up /// to the next multiple of 8. This is effectively a port of /// [`str.expandtabs`](https://docs.python.org/3/library/stdtypes.html#str.expandtabs), -/// which black [calls with the default tab width of 8](https://github.com/psf/black/blob/c36e468794f9256d5e922c399240d49782ba04f1/src/black/strings.py#L61) -fn count_indentation_like_black(line: &str, tab_width: TabWidth) -> TextSize { - let mut indentation = TextSize::default(); +/// which black [calls with the default tab width of 8](https://github.com/psf/black/blob/c36e468794f9256d5e922c399240d49782ba04f1/src/black/strings.py#L61). +fn indentation_length(line: &str) -> TextSize { + let mut indentation = 0u32; for char in line.chars() { if char == '\t' { // Pad to the next multiple of tab_width - indentation += TextSize::from( - tab_width.value() - (indentation.to_u32().rem_euclid(tab_width.value())), - ); + indentation += 8 - (indentation.rem_euclid(8)); } else if char.is_whitespace() { - indentation += char.text_len(); + indentation += u32::from(char.text_len()); } else { - return indentation; + break; } } - indentation + TextSize::new(indentation) } /// Format a docstring by trimming whitespace and adjusting the indentation. @@ -784,35 +828,30 @@ fn count_indentation_like_black(line: &str, tab_width: TabWidth) -> TextSize { /// line c /// """ /// ``` -fn format_docstring(string_part: &FormatStringPart, f: &mut PyFormatter) -> FormatResult<()> { - let locator = f.context().locator(); +fn format_docstring(normalized: &NormalizedString, f: &mut PyFormatter) -> FormatResult<()> { + let docstring = &normalized.text; // Black doesn't change the indentation of docstrings that contain an escaped newline - if locator.slice(string_part).contains("\\\n") { - return string_part.fmt(f); + if docstring.contains("\\\n") { + return normalized.fmt(f); } - let (normalized, _) = normalize_string( - locator.slice(string_part), - string_part.preferred_quotes, - string_part.is_raw_string, - ); // is_borrowed is unstable :/ - let already_normalized = matches!(normalized, Cow::Borrowed(_)); + let already_normalized = matches!(docstring, Cow::Borrowed(_)); - let mut lines = normalized.lines().peekable(); + let mut lines = docstring.lines().peekable(); // Start the string write!( f, [ - source_position(string_part.start()), - string_part.prefix, - string_part.preferred_quotes + normalized.prefix, + normalized.quotes, + source_position(normalized.start()), ] )?; // We track where in the source docstring we are (in source code byte offsets) - let mut offset = string_part.start(); + let mut offset = normalized.start(); // The first line directly after the opening quotes has different rules than the rest, mainly // that we remove all leading whitespace as there's no indentation @@ -826,7 +865,7 @@ fn format_docstring(string_part: &FormatStringPart, f: &mut PyFormatter) -> Form // Edge case: The first line is `""" "content`, so we need to insert chaperone space that keep // inner quotes and closing quotes from getting to close to avoid `""""content` - if trim_both.starts_with(string_part.preferred_quotes.style.as_char()) { + if trim_both.starts_with(normalized.quotes.style.as_char()) { space().fmt(f)?; } @@ -837,23 +876,23 @@ fn format_docstring(string_part: &FormatStringPart, f: &mut PyFormatter) -> Form let trimmed_line_range = TextRange::at(offset, trim_end.text_len()).add_start(leading_whitespace); if already_normalized { - source_text_slice(trimmed_line_range, ContainsNewlines::No).fmt(f)?; + source_text_slice(trimmed_line_range).fmt(f)?; } else { - dynamic_text(trim_both, Some(trimmed_line_range.start())).fmt(f)?; + text(trim_both, Some(trimmed_line_range.start())).fmt(f)?; } } offset += first.text_len(); // Check if we have a single line (or empty) docstring - if normalized[first.len()..].trim().is_empty() { + if docstring[first.len()..].trim().is_empty() { // For `"""\n"""` or other whitespace between the quotes, black keeps a single whitespace, // but `""""""` doesn't get one inserted. - if needs_chaperone_space(string_part, trim_end) - || (trim_end.is_empty() && !normalized.is_empty()) + if needs_chaperone_space(normalized, trim_end) + || (trim_end.is_empty() && !docstring.is_empty()) { space().fmt(f)?; } - string_part.preferred_quotes.fmt(f)?; + normalized.quotes.fmt(f)?; return Ok(()); } @@ -869,7 +908,7 @@ fn format_docstring(string_part: &FormatStringPart, f: &mut PyFormatter) -> Form .clone() // We don't want to count whitespace-only lines as miss-indented .filter(|line| !line.trim().is_empty()) - .map(|line| count_indentation_like_black(line, f.options().tab_width())) + .map(indentation_length) .min() .unwrap_or_default(); @@ -888,27 +927,21 @@ fn format_docstring(string_part: &FormatStringPart, f: &mut PyFormatter) -> Form } // Same special case in the last line as for the first line - let trim_end = normalized + let trim_end = docstring .as_ref() .trim_end_matches(|c: char| c.is_whitespace() && c != '\n'); - if needs_chaperone_space(string_part, trim_end) { + if needs_chaperone_space(normalized, trim_end) { space().fmt(f)?; } - write!( - f, - [ - string_part.preferred_quotes, - source_position(string_part.end()) - ] - ) + write!(f, [source_position(normalized.end()), normalized.quotes]) } /// If the last line of the docstring is `content" """` or `content\ """`, we need a chaperone space /// that avoids `content""""` and `content\"""`. This does only applies to un-escaped backslashes, /// so `content\\ """` doesn't need a space while `content\\\ """` does. -fn needs_chaperone_space(string_part: &FormatStringPart, trim_end: &str) -> bool { - trim_end.ends_with(string_part.preferred_quotes.style.as_char()) +fn needs_chaperone_space(normalized: &NormalizedString, trim_end: &str) -> bool { + trim_end.ends_with(normalized.quotes.style.as_char()) || trim_end.chars().rev().take_while(|c| *c == '\\').count() % 2 == 1 } @@ -917,7 +950,7 @@ fn format_docstring_line( line: &str, is_last: bool, offset: TextSize, - stripped_indentation: TextSize, + stripped_indentation_length: TextSize, already_normalized: bool, f: &mut PyFormatter, ) -> FormatResult<()> { @@ -944,21 +977,20 @@ fn format_docstring_line( // overindented, in which case we strip the additional whitespace (see example in // [`format_docstring`] doc comment). We then prepend the in-docstring indentation to the // string. - let indent_len = - count_indentation_like_black(trim_end, f.options().tab_width()) - stripped_indentation; - let in_docstring_indent = " ".repeat(indent_len.to_usize()) + trim_end.trim_start(); - dynamic_text(&in_docstring_indent, Some(offset)).fmt(f)?; + let indent_len = indentation_length(trim_end) - stripped_indentation_length; + let in_docstring_indent = " ".repeat(usize::from(indent_len)) + trim_end.trim_start(); + text(&in_docstring_indent, Some(offset)).fmt(f)?; } else { // Take the string with the trailing whitespace removed, then also skip the leading // whitespace let trimmed_line_range = - TextRange::at(offset, trim_end.text_len()).add_start(stripped_indentation); + TextRange::at(offset, trim_end.text_len()).add_start(stripped_indentation_length); if already_normalized { - source_text_slice(trimmed_line_range, ContainsNewlines::No).fmt(f)?; + source_text_slice(trimmed_line_range).fmt(f)?; } else { // All indents are ascii spaces, so the slicing is correct - dynamic_text( - &trim_end[stripped_indentation.to_usize()..], + text( + &trim_end[usize::from(stripped_indentation_length)..], Some(trimmed_line_range.start()), ) .fmt(f)?; @@ -977,24 +1009,14 @@ fn format_docstring_line( #[cfg(test)] mod tests { - use crate::expression::string::count_indentation_like_black; - use ruff_formatter::TabWidth; + use crate::expression::string::indentation_length; + use ruff_text_size::TextSize; #[test] fn test_indentation_like_black() { - let tab_width = TabWidth::try_from(8).unwrap(); - assert_eq!( - count_indentation_like_black("\t \t \t", tab_width).to_u32(), - 24 - ); - assert_eq!( - count_indentation_like_black("\t \t", tab_width).to_u32(), - 24 - ); - assert_eq!( - count_indentation_like_black("\t\t\t", tab_width).to_u32(), - 24 - ); - assert_eq!(count_indentation_like_black(" ", tab_width).to_u32(), 4); + assert_eq!(indentation_length("\t \t \t"), TextSize::new(24)); + assert_eq!(indentation_length("\t \t"), TextSize::new(24)); + assert_eq!(indentation_length("\t\t\t"), TextSize::new(24)); + assert_eq!(indentation_length(" "), TextSize::new(4)); } } diff --git a/crates/ruff_python_formatter/src/lib.rs b/crates/ruff_python_formatter/src/lib.rs index 17193b8444..4d96a9374e 100644 --- a/crates/ruff_python_formatter/src/lib.rs +++ b/crates/ruff_python_formatter/src/lib.rs @@ -1,4 +1,5 @@ use thiserror::Error; +use tracing::Level; use ruff_formatter::prelude::*; use ruff_formatter::{format, FormatError, Formatted, PrintError, Printed, SourceCode}; @@ -13,7 +14,7 @@ use crate::comments::{ dangling_comments, leading_comments, trailing_comments, Comments, SourceComment, }; pub use crate::context::PyFormatContext; -pub use crate::options::{MagicTrailingComma, PyFormatOptions, QuoteStyle}; +pub use crate::options::{MagicTrailingComma, PreviewMode, PyFormatOptions, QuoteStyle}; use crate::verbatim::suppressed_node; pub(crate) mod builders; @@ -119,6 +120,7 @@ impl From for FormatModuleError { } } +#[tracing::instrument(level=Level::TRACE, skip_all, err)] pub fn format_module( contents: &str, options: PyFormatOptions, @@ -166,10 +168,9 @@ pub fn format_node<'a>( } /// Public function for generating a printable string of the debug comments. -pub fn pretty_comments(formatted: &Formatted, source: &str) -> String { - let comments = formatted.context().comments(); +pub fn pretty_comments(root: &Mod, comment_ranges: &CommentRanges, source: &str) -> String { + let comments = Comments::from_ast(root, SourceCode::new(source), comment_ranges); - // When comments are empty we'd display an empty map '{}' std::format!( "{comments:#?}", comments = comments.debug(SourceCode::new(source)) @@ -215,10 +216,12 @@ if True: #[test] fn quick_test() { let src = r#" -for converter in connection.ops.get_db_converters( - expression -) + expression.get_db_converters(connection): - ... +(header.timecnt * 5 # Transition times and types + + header.typecnt * 6 # Local time type records + + header.charcnt # Time zone designations + + header.leapcnt * 8 # Leap second records + + header.isstdcnt # Standard/wall indicators + + header.isutcnt) # UT/local indicators "#; // Tokenize once let mut tokens = Vec::new(); @@ -242,9 +245,9 @@ for converter in connection.ops.get_db_converters( // Use `dbg_write!(f, []) instead of `write!(f, [])` in your formatting code to print some IR // inside of a `Format` implementation // use ruff_formatter::FormatContext; - // formatted + // dbg!(formatted // .document() - // .display(formatted.context().source_code()); + // .display(formatted.context().source_code())); // // dbg!(formatted // .context() @@ -271,21 +274,18 @@ for converter in connection.ops.get_db_converters( struct FormatString<'a>(&'a str); impl Format for FormatString<'_> { - fn fmt( - &self, - f: &mut ruff_formatter::formatter::Formatter, - ) -> FormatResult<()> { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { let format_str = format_with(|f| { - write!(f, [text("\"")])?; + write!(f, [token("\"")])?; let mut words = self.0.split_whitespace().peekable(); let mut fill = f.fill(); let separator = format_with(|f| { group(&format_args![ - if_group_breaks(&text("\"")), + if_group_breaks(&token("\"")), soft_line_break_or_space(), - if_group_breaks(&text("\" ")) + if_group_breaks(&token("\" ")) ]) .fmt(f) }); @@ -293,10 +293,10 @@ for converter in connection.ops.get_db_converters( while let Some(word) = words.next() { let is_last = words.peek().is_none(); let format_word = format_with(|f| { - write!(f, [dynamic_text(word, None)])?; + write!(f, [text(word, None)])?; if is_last { - write!(f, [text("\"")])?; + write!(f, [token("\"")])?; } Ok(()) @@ -311,9 +311,9 @@ for converter in connection.ops.get_db_converters( write!( f, [group(&format_args![ - if_group_breaks(&text("(")), + if_group_breaks(&token("(")), soft_block_indent(&format_str), - if_group_breaks(&text(")")) + if_group_breaks(&token(")")) ])] ) } diff --git a/crates/ruff_python_formatter/src/module/mod_module.rs b/crates/ruff_python_formatter/src/module/mod_module.rs index 145ad8a61b..54b1dbd51d 100644 --- a/crates/ruff_python_formatter/src/module/mod_module.rs +++ b/crates/ruff_python_formatter/src/module/mod_module.rs @@ -1,9 +1,10 @@ use ruff_formatter::prelude::hard_line_break; -use ruff_formatter::write; +use ruff_formatter::{Buffer, FormatResult}; use ruff_python_ast::ModModule; -use crate::prelude::*; +use crate::comments::{trailing_comments, SourceComment}; use crate::statement::suite::SuiteKind; +use crate::{write, AsFormat, FormatNodeRule, PyFormatter}; #[derive(Default)] pub struct FormatModModule; @@ -11,13 +12,25 @@ pub struct FormatModModule; impl FormatNodeRule for FormatModModule { fn fmt_fields(&self, item: &ModModule, f: &mut PyFormatter) -> FormatResult<()> { let ModModule { range: _, body } = item; + let comments = f.context().comments().clone(); + write!( f, [ body.format().with_options(SuiteKind::TopLevel), + trailing_comments(comments.dangling(item)), // Trailing newline at the end of the file hard_line_break() ] ) } + + fn fmt_dangling_comments( + &self, + _dangling_comments: &[SourceComment], + _f: &mut PyFormatter, + ) -> FormatResult<()> { + // Handled as part of `fmt_fields` + Ok(()) + } } diff --git a/crates/ruff_python_formatter/src/options.rs b/crates/ruff_python_formatter/src/options.rs index fe7c7a9e86..66567898e1 100644 --- a/crates/ruff_python_formatter/src/options.rs +++ b/crates/ruff_python_formatter/src/options.rs @@ -1,5 +1,5 @@ use ruff_formatter::printer::{LineEnding, PrinterOptions, SourceMapGeneration}; -use ruff_formatter::{FormatOptions, IndentStyle, LineWidth, TabWidth}; +use ruff_formatter::{FormatOptions, IndentStyle, IndentWidth, LineWidth}; use ruff_python_ast::PySourceType; use std::path::Path; use std::str::FromStr; @@ -25,8 +25,10 @@ pub struct PyFormatOptions { line_width: LineWidth, /// The visual width of a tab character. - #[cfg_attr(feature = "serde", serde(default = "default_tab_width"))] - tab_width: TabWidth, + #[cfg_attr(feature = "serde", serde(default = "default_indent_width"))] + indent_width: IndentWidth, + + line_ending: LineEnding, /// The preferred quote style to use (single vs double quotes). quote_style: QuoteStyle, @@ -37,6 +39,9 @@ pub struct PyFormatOptions { /// Should the formatter generate a source map that allows mapping source positions to positions /// in the formatted document. source_map_generation: SourceMapGeneration, + + /// Whether preview style formatting is enabled or not + preview: PreviewMode, } fn default_line_width() -> LineWidth { @@ -44,11 +49,11 @@ fn default_line_width() -> LineWidth { } fn default_indent_style() -> IndentStyle { - IndentStyle::Space(4) + IndentStyle::Space } -fn default_tab_width() -> TabWidth { - TabWidth::try_from(4).unwrap() +fn default_indent_width() -> IndentWidth { + IndentWidth::try_from(4).unwrap() } impl Default for PyFormatOptions { @@ -57,10 +62,12 @@ impl Default for PyFormatOptions { source_type: PySourceType::default(), indent_style: default_indent_style(), line_width: default_line_width(), - tab_width: default_tab_width(), + indent_width: default_indent_width(), quote_style: QuoteStyle::default(), + line_ending: LineEnding::default(), magic_trailing_comma: MagicTrailingComma::default(), source_map_generation: SourceMapGeneration::default(), + preview: PreviewMode::default(), } } } @@ -94,6 +101,20 @@ impl PyFormatOptions { self.source_map_generation } + pub fn line_ending(&self) -> LineEnding { + self.line_ending + } + + pub fn preview(&self) -> PreviewMode { + self.preview + } + + #[must_use] + pub fn with_indent_width(mut self, indent_width: IndentWidth) -> Self { + self.indent_width = indent_width; + self + } + #[must_use] pub fn with_quote_style(mut self, style: QuoteStyle) -> Self { self.quote_style = style; @@ -117,6 +138,18 @@ impl PyFormatOptions { self.line_width = line_width; self } + + #[must_use] + pub fn with_line_ending(mut self, line_ending: LineEnding) -> Self { + self.line_ending = line_ending; + self + } + + #[must_use] + pub fn with_preview(mut self, preview: PreviewMode) -> Self { + self.preview = preview; + self + } } impl FormatOptions for PyFormatOptions { @@ -124,8 +157,8 @@ impl FormatOptions for PyFormatOptions { self.indent_style } - fn tab_width(&self) -> TabWidth { - self.tab_width + fn indent_width(&self) -> IndentWidth { + self.indent_width } fn line_width(&self) -> LineWidth { @@ -134,9 +167,9 @@ impl FormatOptions for PyFormatOptions { fn as_print_options(&self) -> PrinterOptions { PrinterOptions { - tab_width: self.tab_width, + indent_width: self.indent_width, line_width: self.line_width, - line_ending: LineEnding::LineFeed, + line_ending: self.line_ending, indent_style: self.indent_style, source_map_generation: self.source_map_generation, } @@ -227,3 +260,18 @@ impl FromStr for MagicTrailingComma { } } } + +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum PreviewMode { + #[default] + Disabled, + + Enabled, +} + +impl PreviewMode { + pub const fn is_enabled(self) -> bool { + matches!(self, PreviewMode::Enabled) + } +} diff --git a/crates/ruff_python_formatter/src/other/alias.rs b/crates/ruff_python_formatter/src/other/alias.rs index 020c0d77fd..0020c872cc 100644 --- a/crates/ruff_python_formatter/src/other/alias.rs +++ b/crates/ruff_python_formatter/src/other/alias.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatAlias { } = item; name.format().fmt(f)?; if let Some(asname) = asname { - write!(f, [space(), text("as"), space(), asname.format()])?; + write!(f, [space(), token("as"), space(), asname.format()])?; } Ok(()) } diff --git a/crates/ruff_python_formatter/src/other/arguments.rs b/crates/ruff_python_formatter/src/other/arguments.rs index f0c2651361..5baa9fa741 100644 --- a/crates/ruff_python_formatter/src/other/arguments.rs +++ b/crates/ruff_python_formatter/src/other/arguments.rs @@ -1,6 +1,5 @@ use ruff_formatter::write; -use ruff_python_ast::node::AstNode; -use ruff_python_ast::{Arguments, Expr}; +use ruff_python_ast::{ArgOrKeyword, Arguments, Expr}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; use ruff_text_size::{Ranged, TextRange, TextSize}; @@ -14,6 +13,11 @@ pub struct FormatArguments; impl FormatNodeRule for FormatArguments { fn fmt_fields(&self, item: &Arguments, f: &mut PyFormatter) -> FormatResult<()> { + let Arguments { + range, + args, + keywords, + } = item; // We have a case with `f()` without any argument, which is a special case because we can // have a comment with no node attachment inside: // ```python @@ -21,7 +25,7 @@ impl FormatNodeRule for FormatArguments { // # This call has a dangling comment. // ) // ``` - if item.args.is_empty() && item.keywords.is_empty() { + if args.is_empty() && keywords.is_empty() { let comments = f.context().comments().clone(); let dangling = comments.dangling(item); return write!(f, [empty_parenthesized("(", dangling, ")")]); @@ -29,19 +33,19 @@ impl FormatNodeRule for FormatArguments { let all_arguments = format_with(|f: &mut PyFormatter| { let source = f.context().source(); - let mut joiner = f.join_comma_separated(item.end()); - match item.args.as_slice() { - [arg] if item.keywords.is_empty() => { + let mut joiner = f.join_comma_separated(range.end()); + match args.as_slice() { + [arg] if keywords.is_empty() => { match arg { Expr::GeneratorExp(generator_exp) => joiner.entry( generator_exp, &generator_exp .format() - .with_options(GeneratorExpParentheses::StripIfOnlyFunctionArg), + .with_options(GeneratorExpParentheses::Preserve), ), other => { let parentheses = - if is_single_argument_parenthesized(arg, item.end(), source) { + if is_single_argument_parenthesized(arg, range.end(), source) { Parentheses::Always } else { // Note: no need to handle opening-parenthesis comments, since @@ -53,14 +57,17 @@ impl FormatNodeRule for FormatArguments { } }; } - args => { - joiner - .entries( - // We have the parentheses from the call so the item never need any - args.iter() - .map(|arg| (arg, arg.format().with_options(Parentheses::Preserve))), - ) - .nodes(item.keywords.iter()); + _ => { + for arg_or_keyword in item.arguments_source_order() { + match arg_or_keyword { + ArgOrKeyword::Arg(arg) => { + joiner.entry(arg, &arg.format()); + } + ArgOrKeyword::Keyword(keyword) => { + joiner.entry(keyword, &keyword.format()); + } + } + } } } @@ -76,7 +83,7 @@ impl FormatNodeRule for FormatArguments { // c, // ) let comments = f.context().comments().clone(); - let dangling_comments = comments.dangling(item.as_any_node_ref()); + let dangling_comments = comments.dangling(item); write!( f, diff --git a/crates/ruff_python_formatter/src/other/comprehension.rs b/crates/ruff_python_formatter/src/other/comprehension.rs index 0a58fbfc38..d5f439a676 100644 --- a/crates/ruff_python_formatter/src/other/comprehension.rs +++ b/crates/ruff_python_formatter/src/other/comprehension.rs @@ -32,14 +32,13 @@ impl FormatNodeRule for FormatComprehension { } = item; if *is_async { - write!(f, [text("async"), space()])?; + write!(f, [token("async"), space()])?; } let comments = f.context().comments().clone(); let dangling_item_comments = comments.dangling(item); let (before_target_comments, before_in_comments) = dangling_item_comments.split_at( - dangling_item_comments - .partition_point(|comment| comment.slice().end() < target.start()), + dangling_item_comments.partition_point(|comment| comment.end() < target.start()), ); let trailing_in_comments = comments.dangling(iter); @@ -55,14 +54,14 @@ impl FormatNodeRule for FormatComprehension { write!( f, [ - text("for"), + token("for"), trailing_comments(before_target_comments), group(&format_args!( Spacer(target), ExprTupleWithoutParentheses(target), in_spacer, leading_comments(before_in_comments), - text("in"), + token("in"), trailing_comments(trailing_in_comments), Spacer(iter), iter.format(), @@ -82,7 +81,7 @@ impl FormatNodeRule for FormatComprehension { ); joiner.entry(&group(&format_args!( leading_comments(own_line_if_comments), - text("if"), + token("if"), trailing_comments(end_of_line_if_comments), Spacer(if_case), if_case.format(), diff --git a/crates/ruff_python_formatter/src/other/decorator.rs b/crates/ruff_python_formatter/src/other/decorator.rs index 241afcd125..9754ac4b4a 100644 --- a/crates/ruff_python_formatter/src/other/decorator.rs +++ b/crates/ruff_python_formatter/src/other/decorator.rs @@ -19,7 +19,7 @@ impl FormatNodeRule for FormatDecorator { write!( f, [ - text("@"), + token("@"), maybe_parenthesize_expression(expression, item, Parenthesize::Optional) ] ) diff --git a/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs b/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs index 73d4a08195..387628af1d 100644 --- a/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs +++ b/crates/ruff_python_formatter/src/other/except_handler_except_handler.rs @@ -57,10 +57,10 @@ impl FormatNodeRule for FormatExceptHandlerExceptHan write!( f, [ - text("except"), + token("except"), match self.except_handler_kind { ExceptHandlerKind::Regular => None, - ExceptHandlerKind::Starred => Some(text("*")), + ExceptHandlerKind::Starred => Some(token("*")), } ] )?; @@ -78,7 +78,7 @@ impl FormatNodeRule for FormatExceptHandlerExceptHan ] )?; if let Some(name) = name { - write!(f, [space(), text("as"), space(), name.format()])?; + write!(f, [space(), token("as"), space(), name.format()])?; } } diff --git a/crates/ruff_python_formatter/src/other/identifier.rs b/crates/ruff_python_formatter/src/other/identifier.rs index b889589302..ae3dd98f67 100644 --- a/crates/ruff_python_formatter/src/other/identifier.rs +++ b/crates/ruff_python_formatter/src/other/identifier.rs @@ -8,7 +8,7 @@ pub struct FormatIdentifier; impl FormatRule> for FormatIdentifier { fn fmt(&self, item: &Identifier, f: &mut PyFormatter) -> FormatResult<()> { - source_text_slice(item.range(), ContainsNewlines::No).fmt(f) + source_text_slice(item.range()).fmt(f) } } diff --git a/crates/ruff_python_formatter/src/other/keyword.rs b/crates/ruff_python_formatter/src/other/keyword.rs index ed5ef0cca6..6c56883242 100644 --- a/crates/ruff_python_formatter/src/other/keyword.rs +++ b/crates/ruff_python_formatter/src/other/keyword.rs @@ -13,11 +13,11 @@ impl FormatNodeRule for FormatKeyword { arg, value, } = item; + // Comments after the `=` or `**` are reassigned as leading comments on the value. if let Some(arg) = arg { - write!(f, [arg.format(), text("="), value.format()]) + write!(f, [arg.format(), token("="), value.format()]) } else { - // Comments after the stars are reassigned as trailing value comments - write!(f, [text("**"), value.format()]) + write!(f, [token("**"), value.format()]) } } } diff --git a/crates/ruff_python_formatter/src/other/match_case.rs b/crates/ruff_python_formatter/src/other/match_case.rs index 10b60921ca..0b965583d5 100644 --- a/crates/ruff_python_formatter/src/other/match_case.rs +++ b/crates/ruff_python_formatter/src/other/match_case.rs @@ -30,7 +30,7 @@ impl FormatNodeRule for FormatMatchCase { ClauseHeader::MatchCase(item), dangling_item_comments, &format_with(|f| { - write!(f, [text("case"), space()])?; + write!(f, [token("case"), space()])?; let has_comments = comments.has_leading(pattern) || comments.has_trailing_own_line(pattern); @@ -58,7 +58,7 @@ impl FormatNodeRule for FormatMatchCase { } if let Some(guard) = guard { - write!(f, [space(), text("if"), space(), guard.format()])?; + write!(f, [space(), token("if"), space(), guard.format()])?; } Ok(()) diff --git a/crates/ruff_python_formatter/src/other/parameter.rs b/crates/ruff_python_formatter/src/other/parameter.rs index a204e3e8a4..fb0e84fbcd 100644 --- a/crates/ruff_python_formatter/src/other/parameter.rs +++ b/crates/ruff_python_formatter/src/other/parameter.rs @@ -17,7 +17,7 @@ impl FormatNodeRule for FormatParameter { name.format().fmt(f)?; if let Some(annotation) = annotation { - write!(f, [text(":"), space(), annotation.format()])?; + write!(f, [token(":"), space(), annotation.format()])?; } Ok(()) diff --git a/crates/ruff_python_formatter/src/other/parameter_with_default.rs b/crates/ruff_python_formatter/src/other/parameter_with_default.rs index 40e7508d8d..7afcb1b31a 100644 --- a/crates/ruff_python_formatter/src/other/parameter_with_default.rs +++ b/crates/ruff_python_formatter/src/other/parameter_with_default.rs @@ -18,7 +18,7 @@ impl FormatNodeRule for FormatParameterWithDefault { if let Some(default) = default { let space = parameter.annotation.is_some().then_some(space()); - write!(f, [space, text("="), space, group(&default.format())])?; + write!(f, [space, token("="), space, group(&default.format())])?; } Ok(()) diff --git a/crates/ruff_python_formatter/src/other/parameters.rs b/crates/ruff_python_formatter/src/other/parameters.rs index 2e6c451ae4..2194a579f4 100644 --- a/crates/ruff_python_formatter/src/other/parameters.rs +++ b/crates/ruff_python_formatter/src/other/parameters.rs @@ -102,7 +102,7 @@ impl FormatNodeRule for FormatParameters { dangling.split_at(parenthesis_comments_end); let format_inner = format_with(|f: &mut PyFormatter| { - let separator = format_with(|f| write!(f, [text(","), soft_line_break_or_space()])); + let separator = format_with(|f| write!(f, [token(","), soft_line_break_or_space()])); let mut joiner = f.join_with(separator); let mut last_node: Option = None; @@ -127,7 +127,7 @@ impl FormatNodeRule for FormatParameters { let assignment = assign_argument_separator_comment_placement( slash.as_ref(), star.as_ref(), - comment.slice().range(), + comment.range(), comment.line_position(), ) .expect("Unexpected dangling comment type in function parameters"); @@ -156,7 +156,7 @@ impl FormatNodeRule for FormatParameters { if let Some(vararg) = vararg { joiner.entry(&format_args![ leading_node_comments(vararg.as_ref()), - text("*"), + token("*"), vararg.format() ]); last_node = Some(vararg.as_any_node_ref()); @@ -192,7 +192,7 @@ impl FormatNodeRule for FormatParameters { if let Some(kwarg) = kwarg { joiner.entry(&format_args![ leading_node_comments(kwarg.as_ref()), - text("**"), + token("**"), kwarg.format() ]); last_node = Some(kwarg.as_any_node_ref()); @@ -216,10 +216,10 @@ impl FormatNodeRule for FormatParameters { // For lambdas (no parentheses), preserve the trailing comma. It doesn't // behave like a magic trailing comma, it's just preserved if has_trailing_comma(item, last_node, f.context().source()) { - write!(f, [text(",")])?; + write!(f, [token(",")])?; } } else { - write!(f, [if_group_breaks(&text(","))])?; + write!(f, [if_group_breaks(&token(","))])?; if f.options().magic_trailing_comma().is_respect() && has_trailing_comma(item, last_node, f.context().source()) @@ -252,10 +252,10 @@ impl FormatNodeRule for FormatParameters { write!( f, [ - text("("), + token("("), dangling_open_parenthesis_comments(parenthesis_dangling), soft_block_indent(&group(&format_inner)), - text(")") + token(")") ] ) } @@ -279,7 +279,7 @@ struct CommentsAroundText<'a> { impl Format> for CommentsAroundText<'_> { fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> { if self.comments.is_empty() { - text(self.text).fmt(f) + token(self.text).fmt(f) } else { // There might be own line comments in trailing, but those are weird and we can kinda // ignore them @@ -301,7 +301,7 @@ impl Format> for CommentsAroundText<'_> { f, [ leading_comments(leading), - text(self.text), + token(self.text), trailing_comments(trailing) ] ) diff --git a/crates/ruff_python_formatter/src/other/with_item.rs b/crates/ruff_python_formatter/src/other/with_item.rs index fd91501c06..0559e4a993 100644 --- a/crates/ruff_python_formatter/src/other/with_item.rs +++ b/crates/ruff_python_formatter/src/other/with_item.rs @@ -30,7 +30,7 @@ impl FormatNodeRule for FormatWithItem { )?; if let Some(optional_vars) = optional_vars { - write!(f, [space(), text("as"), space()])?; + write!(f, [space(), token("as"), space()])?; if trailing_as_comments.is_empty() { write!(f, [optional_vars.format()])?; diff --git a/crates/ruff_python_formatter/src/pattern/pattern_keyword.rs b/crates/ruff_python_formatter/src/pattern/pattern_keyword.rs index 35bae9ddf4..974e653474 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_keyword.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_keyword.rs @@ -12,6 +12,6 @@ impl FormatNodeRule for FormatPatternKeyword { attr, pattern, } = item; - write!(f, [attr.format(), text("="), pattern.format()]) + write!(f, [attr.format(), token("="), pattern.format()]) } } diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs index d16f4884d3..921e548ac0 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs @@ -29,7 +29,7 @@ impl FormatNodeRule for FormatPatternMatchAs { write!(f, [space()])?; } - write!(f, [text("as")])?; + write!(f, [token("as")])?; let trailing_as_comments = comments.dangling(item); if trailing_as_comments.is_empty() { @@ -45,7 +45,7 @@ impl FormatNodeRule for FormatPatternMatchAs { name.format().fmt(f) } else { debug_assert!(pattern.is_none()); - text("_").fmt(f) + token("_").fmt(f) } } diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs index f6584be7a7..1145f64bdd 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs @@ -130,7 +130,7 @@ impl Format> for RestPattern<'_> { f, [ leading_comments(self.comments), - text("**"), + token("**"), self.identifier.format() ] ) @@ -156,7 +156,7 @@ impl Format> for KeyPatternPair<'_> { f, [group(&format_args![ self.key.format(), - text(":"), + token(":"), space(), self.pattern.format() ])] diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs index 8d84a240e9..4de2af6c3e 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs @@ -35,7 +35,7 @@ impl FormatNodeRule for FormatPatternMatchOr { [hard_line_break(), leading_comments(leading_value_comments)] )?; } - write!(f, [text("|"), space(), pattern.format()])?; + write!(f, [token("|"), space(), pattern.format()])?; } Ok(()) diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs index 56b0c223da..f1aabfddc3 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs @@ -10,9 +10,9 @@ pub struct FormatPatternMatchSingleton; impl FormatNodeRule for FormatPatternMatchSingleton { fn fmt_fields(&self, item: &PatternMatchSingleton, f: &mut PyFormatter) -> FormatResult<()> { match item.value { - Constant::None => text("None").fmt(f), - Constant::Bool(true) => text("True").fmt(f), - Constant::Bool(false) => text("False").fmt(f), + Constant::None => token("None").fmt(f), + Constant::Bool(true) => token("True").fmt(f), + Constant::Bool(false) => token("False").fmt(f), _ => unreachable!(), } } diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs index 8b93d2b81c..c8a88fe773 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs @@ -16,11 +16,11 @@ impl FormatNodeRule for FormatPatternMatchStar { let comments = f.context().comments().clone(); let dangling = comments.dangling(item); - write!(f, [text("*"), dangling_comments(dangling)])?; + write!(f, [token("*"), dangling_comments(dangling)])?; match name { Some(name) => write!(f, [name.format()]), - None => write!(f, [text("_")]), + None => write!(f, [token("_")]), } } diff --git a/crates/ruff_python_formatter/src/statement/clause.rs b/crates/ruff_python_formatter/src/statement/clause.rs index 348de0e4fa..449b64e299 100644 --- a/crates/ruff_python_formatter/src/statement/clause.rs +++ b/crates/ruff_python_formatter/src/statement/clause.rs @@ -349,7 +349,7 @@ impl<'ast> Format> for FormatClauseHeader<'_, 'ast> { write_suppressed_clause_header(self.header, f)?; } else { f.write_fmt(Arguments::from(&self.formatter))?; - text(":").fmt(f)?; + token(":").fmt(f)?; } trailing_comments(self.trailing_colon_comment).fmt(f) diff --git a/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs index 6edc0a1320..a29798d4c3 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs @@ -23,7 +23,7 @@ impl FormatNodeRule for FormatStmtAnnAssign { f, [ target.format(), - text(":"), + token(":"), space(), maybe_parenthesize_expression(annotation, item, Parenthesize::IfBreaks) ] @@ -34,7 +34,7 @@ impl FormatNodeRule for FormatStmtAnnAssign { f, [ space(), - text("="), + token("="), space(), maybe_parenthesize_expression(value, item, Parenthesize::IfBreaks) ] diff --git a/crates/ruff_python_formatter/src/statement/stmt_assert.rs b/crates/ruff_python_formatter/src/statement/stmt_assert.rs index ae47813283..7b3930d252 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_assert.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_assert.rs @@ -1,4 +1,4 @@ -use ruff_formatter::prelude::{space, text}; +use ruff_formatter::prelude::{space, token}; use ruff_formatter::write; use ruff_python_ast::StmtAssert; @@ -22,7 +22,7 @@ impl FormatNodeRule for FormatStmtAssert { write!( f, [ - text("assert"), + token("assert"), space(), maybe_parenthesize_expression(test, item, Parenthesize::IfBreaks) ] @@ -32,7 +32,7 @@ impl FormatNodeRule for FormatStmtAssert { write!( f, [ - text(","), + token(","), space(), maybe_parenthesize_expression(msg, item, Parenthesize::IfBreaks), ] diff --git a/crates/ruff_python_formatter/src/statement/stmt_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_assign.rs index 3f9b36aa0a..475a21a58b 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_assign.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_assign.rs @@ -27,7 +27,7 @@ impl FormatNodeRule for FormatStmtAssign { [ first.format(), space(), - text("="), + token("="), space(), FormatTargets { targets: rest } ] @@ -89,9 +89,9 @@ impl Format> for FormatTargets<'_> { write!( f, [ - if_group_breaks(&text("(")), + if_group_breaks(&token("(")), soft_block_indent(&first.format().with_options(Parentheses::Never)), - if_group_breaks(&text(")")) + if_group_breaks(&token(")")) ] ) } @@ -103,7 +103,7 @@ impl Format> for FormatTargets<'_> { [group(&format_args![ format_first, space(), - text("="), + token("="), space(), FormatTargets { targets: rest } ]) diff --git a/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs index 652247db46..df15aaa121 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs @@ -24,7 +24,7 @@ impl FormatNodeRule for FormatStmtAugAssign { target.format(), space(), op.format(), - text("="), + token("="), space(), maybe_parenthesize_expression(value, item, Parenthesize::IfBreaks) ] diff --git a/crates/ruff_python_formatter/src/statement/stmt_break.rs b/crates/ruff_python_formatter/src/statement/stmt_break.rs index 394cd03f74..67926e0a0e 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_break.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_break.rs @@ -8,7 +8,7 @@ pub struct FormatStmtBreak; impl FormatNodeRule for FormatStmtBreak { fn fmt_fields(&self, _item: &StmtBreak, f: &mut PyFormatter) -> FormatResult<()> { - text("break").fmt(f) + token("break").fmt(f) } fn is_suppressed( diff --git a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs index 4ac84c26f0..231320eac7 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs @@ -3,6 +3,7 @@ use ruff_python_ast::{Decorator, StmtClassDef}; use ruff_python_trivia::lines_after_ignoring_trivia; use ruff_text_size::Ranged; +use crate::comments::format::empty_lines_before_trailing_comments; use crate::comments::{leading_comments, trailing_comments, SourceComment}; use crate::prelude::*; use crate::statement::clause::{clause_body, clause_header, ClauseHeader}; @@ -42,7 +43,7 @@ impl FormatNodeRule for FormatStmtClassDef { ClauseHeader::Class(item), trailing_definition_comments, &format_with(|f| { - write!(f, [text("class"), space(), name.format()])?; + write!(f, [token("class"), space(), name.format()])?; if let Some(type_params) = type_params.as_deref() { write!(f, [type_params.format()])?; @@ -108,7 +109,25 @@ impl FormatNodeRule for FormatStmtClassDef { ), clause_body(body, trailing_definition_comments).with_kind(SuiteKind::Class), ] - ) + )?; + + // If the class contains trailing comments, insert newlines before them. + // For example, given: + // ```python + // class Class: + // ... + // # comment + // ``` + // + // At the top-level in a non-stub file, reformat as: + // ```python + // class Class: + // ... + // + // + // # comment + // ``` + empty_lines_before_trailing_comments(f, comments.trailing(item)).fmt(f) } fn fmt_dangling_comments( diff --git a/crates/ruff_python_formatter/src/statement/stmt_continue.rs b/crates/ruff_python_formatter/src/statement/stmt_continue.rs index 625f2d8fce..af045d2418 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_continue.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_continue.rs @@ -8,7 +8,7 @@ pub struct FormatStmtContinue; impl FormatNodeRule for FormatStmtContinue { fn fmt_fields(&self, _item: &StmtContinue, f: &mut PyFormatter) -> FormatResult<()> { - text("continue").fmt(f) + token("continue").fmt(f) } fn is_suppressed( diff --git a/crates/ruff_python_formatter/src/statement/stmt_delete.rs b/crates/ruff_python_formatter/src/statement/stmt_delete.rs index 485a317ae3..4af373c801 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_delete.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_delete.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatStmtDelete { fn fmt_fields(&self, item: &StmtDelete, f: &mut PyFormatter) -> FormatResult<()> { let StmtDelete { range: _, targets } = item; - write!(f, [text("del"), space()])?; + write!(f, [token("del"), space()])?; match targets.as_slice() { [] => { @@ -27,9 +27,9 @@ impl FormatNodeRule for FormatStmtDelete { // del ( // # Dangling comment // ) - text("("), + token("("), block_indent(&dangling_node_comments(item)), - text(")"), + token(")"), ] ) } diff --git a/crates/ruff_python_formatter/src/statement/stmt_for.rs b/crates/ruff_python_formatter/src/statement/stmt_for.rs index 66a3012e81..f70ca9269d 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_for.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_for.rs @@ -42,7 +42,7 @@ impl FormatNodeRule for FormatStmtFor { let dangling_comments = comments.dangling(item); let body_start = body.first().map_or(iter.end(), Stmt::start); let or_else_comments_start = - dangling_comments.partition_point(|comment| comment.slice().end() < body_start); + dangling_comments.partition_point(|comment| comment.end() < body_start); let (trailing_condition_comments, or_else_comments) = dangling_comments.split_at(or_else_comments_start); @@ -54,12 +54,12 @@ impl FormatNodeRule for FormatStmtFor { ClauseHeader::For(item), trailing_condition_comments, &format_args![ - is_async.then_some(format_args![text("async"), space()]), - text("for"), + is_async.then_some(format_args![token("async"), space()]), + token("for"), space(), ExprTupleWithoutParentheses(target), space(), - text("in"), + token("in"), space(), maybe_parenthesize_expression(iter, item, Parenthesize::IfBreaks), ], @@ -83,7 +83,7 @@ impl FormatNodeRule for FormatStmtFor { clause_header( ClauseHeader::OrElse(ElseClause::For(item)), trailing, - &text("else"), + &token("else"), ) .with_leading_comments(leading, body.last()), clause_body(orelse, trailing), diff --git a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs index 10c47ca8af..9d1d3280a1 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs @@ -1,3 +1,4 @@ +use crate::comments::format::empty_lines_before_trailing_comments; use ruff_formatter::write; use ruff_python_ast::{Parameters, StmtFunctionDef}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; @@ -17,14 +18,9 @@ pub struct FormatStmtFunctionDef; impl FormatNodeRule for FormatStmtFunctionDef { fn fmt_fields(&self, item: &StmtFunctionDef, f: &mut PyFormatter) -> FormatResult<()> { let StmtFunctionDef { - range: _, - is_async, decorator_list, - name, - type_params, - parameters, - returns, body, + .. } = item; let comments = f.context().comments().clone(); @@ -46,105 +42,29 @@ impl FormatNodeRule for FormatStmtFunctionDef { clause_header( ClauseHeader::Function(item), trailing_definition_comments, - &format_with(|f| { - if *is_async { - write!(f, [text("async"), space()])?; - } - - write!(f, [text("def"), space(), name.format()])?; - - if let Some(type_params) = type_params.as_ref() { - write!(f, [type_params.format()])?; - } - - let format_inner = format_with(|f: &mut PyFormatter| { - write!(f, [parameters.format()])?; - - if let Some(return_annotation) = returns.as_ref() { - write!(f, [space(), text("->"), space()])?; - - if return_annotation.is_tuple_expr() { - let parentheses = - if comments.has_leading(return_annotation.as_ref()) { - Parentheses::Always - } else { - Parentheses::Never - }; - write!( - f, - [return_annotation.format().with_options(parentheses)] - )?; - } else if comments.has_trailing(return_annotation.as_ref()) { - // Intentionally parenthesize any return annotations with trailing comments. - // This avoids an instability in cases like: - // ```python - // def double( - // a: int - // ) -> ( - // int # Hello - // ): - // pass - // ``` - // If we allow this to break, it will be formatted as follows: - // ```python - // def double( - // a: int - // ) -> int: # Hello - // pass - // ``` - // On subsequent formats, the `# Hello` will be interpreted as a dangling - // comment on a function, yielding: - // ```python - // def double(a: int) -> int: # Hello - // pass - // ``` - // Ideally, we'd reach that final formatting in a single pass, but doing so - // requires that the parent be aware of how the child is formatted, which - // is challenging. As a compromise, we break those expressions to avoid an - // instability. - write!( - f, - [return_annotation - .format() - .with_options(Parentheses::Always)] - )?; - } else { - write!( - f, - [maybe_parenthesize_expression( - return_annotation, - item, - if empty_parameters(parameters, f.context().source()) { - // If the parameters are empty, add parentheses if the return annotation - // breaks at all. - Parenthesize::IfBreaksOrIfRequired - } else { - // Otherwise, use our normal rules for parentheses, which allows us to break - // like: - // ```python - // def f( - // x, - // ) -> Tuple[ - // int, - // int, - // ]: - // ... - // ``` - Parenthesize::IfBreaks - }, - )] - )?; - } - } - Ok(()) - }); - - group(&format_inner).fmt(f) - }), + &format_with(|f| format_function_header(f, item)), ), clause_body(body, trailing_definition_comments).with_kind(SuiteKind::Function), ] - ) + )?; + + // If the function contains trailing comments, insert newlines before them. + // For example, given: + // ```python + // def func(): + // ... + // # comment + // ``` + // + // At the top-level in a non-stub file, reformat as: + // ```python + // def func(): + // ... + // + // + // # comment + // ``` + empty_lines_before_trailing_comments(f, comments.trailing(item)).fmt(f) } fn fmt_dangling_comments( @@ -157,6 +77,109 @@ impl FormatNodeRule for FormatStmtFunctionDef { } } +fn format_function_header(f: &mut PyFormatter, item: &StmtFunctionDef) -> FormatResult<()> { + let StmtFunctionDef { + range: _, + is_async, + decorator_list: _, + name, + type_params, + parameters, + returns, + body: _, + } = item; + + let comments = f.context().comments().clone(); + + if *is_async { + write!(f, [token("async"), space()])?; + } + + write!(f, [token("def"), space(), name.format()])?; + + if let Some(type_params) = type_params.as_ref() { + write!(f, [type_params.format()])?; + } + + let format_inner = format_with(|f: &mut PyFormatter| { + write!(f, [parameters.format()])?; + + if let Some(return_annotation) = returns.as_ref() { + write!(f, [space(), token("->"), space()])?; + + if return_annotation.is_tuple_expr() { + let parentheses = if comments.has_leading(return_annotation.as_ref()) { + Parentheses::Always + } else { + Parentheses::Never + }; + write!(f, [return_annotation.format().with_options(parentheses)])?; + } else if comments.has_trailing(return_annotation.as_ref()) { + // Intentionally parenthesize any return annotations with trailing comments. + // This avoids an instability in cases like: + // ```python + // def double( + // a: int + // ) -> ( + // int # Hello + // ): + // pass + // ``` + // If we allow this to break, it will be formatted as follows: + // ```python + // def double( + // a: int + // ) -> int: # Hello + // pass + // ``` + // On subsequent formats, the `# Hello` will be interpreted as a dangling + // comment on a function, yielding: + // ```python + // def double(a: int) -> int: # Hello + // pass + // ``` + // Ideally, we'd reach that final formatting in a single pass, but doing so + // requires that the parent be aware of how the child is formatted, which + // is challenging. As a compromise, we break those expressions to avoid an + // instability. + write!( + f, + [return_annotation.format().with_options(Parentheses::Always)] + )?; + } else { + write!( + f, + [maybe_parenthesize_expression( + return_annotation, + item, + if empty_parameters(parameters, f.context().source()) { + // If the parameters are empty, add parentheses if the return annotation + // breaks at all. + Parenthesize::IfBreaksOrIfRequired + } else { + // Otherwise, use our normal rules for parentheses, which allows us to break + // like: + // ```python + // def f( + // x, + // ) -> Tuple[ + // int, + // int, + // ]: + // ... + // ``` + Parenthesize::IfBreaks + }, + )] + )?; + } + } + Ok(()) + }); + + group(&format_inner).fmt(f) +} + /// Returns `true` if [`Parameters`] is empty (no parameters, no comments, etc.). fn empty_parameters(parameters: &Parameters, source: &str) -> bool { let mut tokenizer = SimpleTokenizer::new(source, parameters.range()) diff --git a/crates/ruff_python_formatter/src/statement/stmt_global.rs b/crates/ruff_python_formatter/src/statement/stmt_global.rs index c837daff08..731630a3d8 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_global.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_global.rs @@ -15,18 +15,18 @@ impl FormatNodeRule for FormatStmtGlobal { // move the comment "off" of the `global` statement. if f.context().comments().has_trailing(item.as_any_node_ref()) { let joined = format_with(|f| { - f.join_with(format_args![text(","), space()]) + f.join_with(format_args![token(","), space()]) .entries(item.names.iter().formatted()) .finish() }); - write!(f, [text("global"), space(), &joined]) + write!(f, [token("global"), space(), &joined]) } else { let joined = format_with(|f| { f.join_with(&format_args![ - text(","), + token(","), space(), - if_group_breaks(&text("\\")), + if_group_breaks(&token("\\")), soft_line_break(), ]) .entries(item.names.iter().formatted()) @@ -36,10 +36,10 @@ impl FormatNodeRule for FormatStmtGlobal { write!( f, [ - text("global"), + token("global"), space(), group(&format_args!( - if_group_breaks(&text("\\")), + if_group_breaks(&token("\\")), soft_line_break(), soft_block_indent(&joined) )) diff --git a/crates/ruff_python_formatter/src/statement/stmt_if.rs b/crates/ruff_python_formatter/src/statement/stmt_if.rs index a842ddf53f..e5852db8d0 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_if.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_if.rs @@ -30,7 +30,7 @@ impl FormatNodeRule for FormatStmtIf { ClauseHeader::If(item), trailing_colon_comment, &format_args![ - text("if"), + token("if"), space(), maybe_parenthesize_expression(test, item, Parenthesize::IfBreaks), ], @@ -86,13 +86,13 @@ pub(crate) fn format_elif_else_clause( write!( f, [ - text("elif"), + token("elif"), space(), maybe_parenthesize_expression(test, item, Parenthesize::IfBreaks), ] ) } else { - text("else").fmt(f) + token("else").fmt(f) } }), ) diff --git a/crates/ruff_python_formatter/src/statement/stmt_import.rs b/crates/ruff_python_formatter/src/statement/stmt_import.rs index d4c10af939..97dc4fe830 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_import.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_import.rs @@ -11,11 +11,11 @@ impl FormatNodeRule for FormatStmtImport { fn fmt_fields(&self, item: &StmtImport, f: &mut PyFormatter) -> FormatResult<()> { let StmtImport { names, range: _ } = item; let names = format_with(|f| { - f.join_with(&format_args![text(","), space()]) + f.join_with(&format_args![token(","), space()]) .entries(names.iter().formatted()) .finish() }); - write!(f, [text("import"), space(), names]) + write!(f, [token("import"), space(), names]) } fn is_suppressed( diff --git a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs index 5881d6e412..6f6c87fb8a 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs @@ -27,12 +27,12 @@ impl FormatNodeRule for FormatStmtImportFrom { write!( f, [ - text("from"), + token("from"), space(), - dynamic_text(&level_str, None), + text(&level_str, None), module.as_ref().map(AsFormat::format), space(), - text("import"), + token("import"), space(), ] )?; @@ -40,7 +40,7 @@ impl FormatNodeRule for FormatStmtImportFrom { if let [name] = names.as_slice() { // star can't be surrounded by parentheses if name.name.as_str() == "*" { - return text("*").fmt(f); + return token("*").fmt(f); } } diff --git a/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs b/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs index 50add1990f..b41305f42a 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs @@ -9,7 +9,7 @@ pub struct FormatStmtIpyEscapeCommand; impl FormatNodeRule for FormatStmtIpyEscapeCommand { fn fmt_fields(&self, item: &StmtIpyEscapeCommand, f: &mut PyFormatter) -> FormatResult<()> { - source_text_slice(item.range(), ContainsNewlines::No).fmt(f) + source_text_slice(item.range()).fmt(f) } fn is_suppressed( diff --git a/crates/ruff_python_formatter/src/statement/stmt_match.rs b/crates/ruff_python_formatter/src/statement/stmt_match.rs index b89c6018a3..672cf7bce7 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_match.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_match.rs @@ -29,7 +29,7 @@ impl FormatNodeRule for FormatStmtMatch { ClauseHeader::Match(item), dangling_item_comments, &format_args![ - text("match"), + token("match"), space(), maybe_parenthesize_expression(subject, item, Parenthesize::IfBreaks), ], diff --git a/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs b/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs index 53884c6f40..5be0c7c9eb 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs @@ -15,18 +15,18 @@ impl FormatNodeRule for FormatStmtNonlocal { // move the comment "off" of the `nonlocal` statement. if f.context().comments().has_trailing(item.as_any_node_ref()) { let joined = format_with(|f| { - f.join_with(format_args![text(","), space()]) + f.join_with(format_args![token(","), space()]) .entries(item.names.iter().formatted()) .finish() }); - write!(f, [text("nonlocal"), space(), &joined]) + write!(f, [token("nonlocal"), space(), &joined]) } else { let joined = format_with(|f| { f.join_with(&format_args![ - text(","), + token(","), space(), - if_group_breaks(&text("\\")), + if_group_breaks(&token("\\")), soft_line_break(), ]) .entries(item.names.iter().formatted()) @@ -36,10 +36,10 @@ impl FormatNodeRule for FormatStmtNonlocal { write!( f, [ - text("nonlocal"), + token("nonlocal"), space(), group(&format_args!( - if_group_breaks(&text("\\")), + if_group_breaks(&token("\\")), soft_line_break(), soft_block_indent(&joined) )) diff --git a/crates/ruff_python_formatter/src/statement/stmt_pass.rs b/crates/ruff_python_formatter/src/statement/stmt_pass.rs index 9a5c5249e2..d6a1e74564 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_pass.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_pass.rs @@ -8,7 +8,7 @@ pub struct FormatStmtPass; impl FormatNodeRule for FormatStmtPass { fn fmt_fields(&self, _item: &StmtPass, f: &mut PyFormatter) -> FormatResult<()> { - text("pass").fmt(f) + token("pass").fmt(f) } fn is_suppressed( diff --git a/crates/ruff_python_formatter/src/statement/stmt_raise.rs b/crates/ruff_python_formatter/src/statement/stmt_raise.rs index e8c11228de..18c72e7672 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_raise.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_raise.rs @@ -17,7 +17,7 @@ impl FormatNodeRule for FormatStmtRaise { cause, } = item; - text("raise").fmt(f)?; + token("raise").fmt(f)?; if let Some(value) = exc { write!( @@ -34,7 +34,7 @@ impl FormatNodeRule for FormatStmtRaise { f, [ space(), - text("from"), + token("from"), space(), maybe_parenthesize_expression(value, item, Parenthesize::Optional) ] diff --git a/crates/ruff_python_formatter/src/statement/stmt_return.rs b/crates/ruff_python_formatter/src/statement/stmt_return.rs index c6379b5a79..be63db2e73 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_return.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_return.rs @@ -14,7 +14,7 @@ impl FormatNodeRule for FormatStmtReturn { fn fmt_fields(&self, item: &StmtReturn, f: &mut PyFormatter) -> FormatResult<()> { let StmtReturn { range: _, value } = item; - text("return").fmt(f)?; + token("return").fmt(f)?; match value.as_deref() { Some(Expr::Tuple(tuple)) if !f.context().comments().has_leading(tuple) => { diff --git a/crates/ruff_python_formatter/src/statement/stmt_try.rs b/crates/ruff_python_formatter/src/statement/stmt_try.rs index 63bbcd4096..4b40ab4549 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_try.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_try.rs @@ -119,7 +119,7 @@ fn format_case<'a>( Ok(if let Some(last) = body.last() { let case_comments_start = - dangling_comments.partition_point(|comment| comment.slice().end() <= last.end()); + dangling_comments.partition_point(|comment| comment.end() <= last.end()); let (case_comments, rest) = dangling_comments.split_at(case_comments_start); let partition_point = case_comments.partition_point(|comment| comment.line_position().is_own_line()); @@ -136,7 +136,7 @@ fn format_case<'a>( write!( f, [ - clause_header(header, trailing_case_comments, &text(kind.keyword())) + clause_header(header, trailing_case_comments, &token(kind.keyword())) .with_leading_comments(leading_case_comments, previous_node), clause_body(body, trailing_case_comments), ] diff --git a/crates/ruff_python_formatter/src/statement/stmt_type_alias.rs b/crates/ruff_python_formatter/src/statement/stmt_type_alias.rs index ddb82ebfe7..c2daaf8528 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_type_alias.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_type_alias.rs @@ -18,7 +18,7 @@ impl FormatNodeRule for FormatStmtTypeAlias { range: _, } = item; - write!(f, [text("type"), space(), name.as_ref().format()])?; + write!(f, [token("type"), space(), name.as_ref().format()])?; if let Some(type_params) = type_params { write!(f, [type_params.format()])?; @@ -28,7 +28,7 @@ impl FormatNodeRule for FormatStmtTypeAlias { f, [ space(), - text("="), + token("="), space(), maybe_parenthesize_expression(value, item, Parenthesize::IfBreaks) ] diff --git a/crates/ruff_python_formatter/src/statement/stmt_while.rs b/crates/ruff_python_formatter/src/statement/stmt_while.rs index b9212831dd..88a9af9831 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_while.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_while.rs @@ -26,7 +26,7 @@ impl FormatNodeRule for FormatStmtWhile { let body_start = body.first().map_or(test.end(), Stmt::start); let or_else_comments_start = - dangling_comments.partition_point(|comment| comment.slice().end() < body_start); + dangling_comments.partition_point(|comment| comment.end() < body_start); let (trailing_condition_comments, or_else_comments) = dangling_comments.split_at(or_else_comments_start); @@ -38,7 +38,7 @@ impl FormatNodeRule for FormatStmtWhile { ClauseHeader::While(item), trailing_condition_comments, &format_args![ - text("while"), + token("while"), space(), maybe_parenthesize_expression(test, item, Parenthesize::IfBreaks), ] @@ -60,7 +60,7 @@ impl FormatNodeRule for FormatStmtWhile { clause_header( ClauseHeader::OrElse(ElseClause::While(item)), trailing, - &text("else") + &token("else") ) .with_leading_comments(leading, body.last()), clause_body(orelse, trailing), diff --git a/crates/ruff_python_formatter/src/statement/stmt_with.rs b/crates/ruff_python_formatter/src/statement/stmt_with.rs index 481d3925ae..9aa5e54bda 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_with.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_with.rs @@ -52,8 +52,8 @@ impl FormatNodeRule for FormatStmtWith { f, [ item.is_async - .then_some(format_args![text("async"), space()]), - text("with"), + .then_some(format_args![token("async"), space()]), + token("with"), space() ] )?; @@ -92,7 +92,7 @@ impl FormatNodeRule for FormatStmtWith { item.format().fmt(f)?; } } else { - f.join_with(format_args![text(","), space()]) + f.join_with(format_args![token(","), space()]) .entries(item.items.iter().formatted()) .finish()?; } diff --git a/crates/ruff_python_formatter/src/statement/suite.rs b/crates/ruff_python_formatter/src/statement/suite.rs index bb29230c1e..8ae33eebb3 100644 --- a/crates/ruff_python_formatter/src/statement/suite.rs +++ b/crates/ruff_python_formatter/src/statement/suite.rs @@ -2,10 +2,12 @@ use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWi use ruff_python_ast::helpers::is_compound_statement; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::{self as ast, Constant, Expr, ExprConstant, Stmt, Suite}; -use ruff_python_trivia::{lines_after_ignoring_trivia, lines_before}; +use ruff_python_trivia::{lines_after, lines_after_ignoring_trivia, lines_before}; use ruff_text_size::{Ranged, TextRange}; -use crate::comments::{leading_comments, trailing_comments, Comments}; +use crate::comments::{ + leading_comments, trailing_comments, Comments, LeadingDanglingTrailingComments, +}; use crate::context::{NodeLevel, WithNodeLevel}; use crate::expression::expr_constant::ExprConstantLayout; use crate::expression::string::StringLayout; @@ -69,7 +71,10 @@ impl FormatRule> for FormatSuite { // Format the first statement in the body, which often has special formatting rules. let first = match self.kind { SuiteKind::Other => { - if is_class_or_function_definition(first) && !comments.has_leading(first) { + if is_class_or_function_definition(first) + && !comments.has_leading(first) + && !source_type.is_stub() + { // Add an empty line for any nested functions or classes defined within // non-function or class compound statements, e.g., this is stable formatting: // ```python @@ -94,7 +99,10 @@ impl FormatRule> for FormatSuite { SuiteKind::Class => { if let Some(docstring) = DocstringStmt::try_from_statement(first) { - if !comments.has_leading(first) && lines_before(first.start(), source) > 1 { + if !comments.has_leading(first) + && lines_before(first.start(), source) > 1 + && !source_type.is_stub() + { // Allow up to one empty line before a class docstring, e.g., this is // stable formatting: // ```python @@ -142,58 +150,44 @@ impl FormatRule> for FormatSuite { ) }; + let mut preceding_comments = comments.leading_dangling_trailing(preceding); + while let Some(following) = iter.next() { - if is_class_or_function_definition(preceding) + let following_comments = comments.leading_dangling_trailing(following); + + // Add empty lines before and after a function or class definition. If the preceding + // node is a function or class, and contains trailing comments, then the statement + // itself will add the requisite empty lines when formatting its comments. + if (is_class_or_function_definition(preceding) + && !preceding_comments.has_trailing_own_line()) || is_class_or_function_definition(following) { - match self.kind { - SuiteKind::TopLevel if source_type.is_stub() => { - // Preserve the empty line if the definitions are separated by a comment - if comments.has_trailing(preceding) || comments.has_leading(following) { + if source_type.is_stub() { + stub_file_empty_lines( + self.kind, + preceding, + following, + &preceding_comments, + &following_comments, + f, + )?; + } else { + match self.kind { + SuiteKind::TopLevel => { + write!(f, [empty_line(), empty_line()])?; + } + SuiteKind::Function | SuiteKind::Class | SuiteKind::Other => { empty_line().fmt(f)?; - } else { - // Two subsequent classes that both have an ellipsis only body - // ```python - // class A: ... - // class B: ... - // ``` - let class_sequences_with_ellipsis_only = - preceding.as_class_def_stmt().is_some_and(|class| { - contains_only_an_ellipsis(&class.body, f.context().comments()) - }) && following.as_class_def_stmt().is_some_and(|class| { - contains_only_an_ellipsis(&class.body, f.context().comments()) - }); - - // Two subsequent functions where the preceding has an ellipsis only body - // ```python - // def test(): ... - // def b(): a - // ``` - let function_with_ellipsis = - preceding.as_function_def_stmt().is_some_and(|function| { - contains_only_an_ellipsis( - &function.body, - f.context().comments(), - ) - }) && following.is_function_def_stmt(); - - // Don't add an empty line between two classes that have an `...` body only or after - // a function with an `...` body. Otherwise add an empty line. - if !class_sequences_with_ellipsis_only && !function_with_ellipsis { - empty_line().fmt(f)?; - } } } - SuiteKind::TopLevel => { - write!(f, [empty_line(), empty_line()])?; - } - SuiteKind::Function | SuiteKind::Class | SuiteKind::Other => { - empty_line().fmt(f)?; - } } - } else if is_import_definition(preceding) && !is_import_definition(following) { + } else if is_import_definition(preceding) + && (!is_import_definition(following) || following_comments.has_leading()) + { // Enforce _at least_ one empty line after an import statement (but allow up to - // two at the top-level). + // two at the top-level). In this context, "after an import statement" means that + // that the previous node is an import, and the following node is an import _or_ has + // a leading comment. match self.kind { SuiteKind::TopLevel => { match lines_after_ignoring_trivia(preceding.end(), source) { @@ -222,8 +216,8 @@ impl FormatRule> for FormatSuite { // which is 0 instead of 1, the number of lines between the trailing comment and // the leading comment. This is why the suite handling counts the lines before the // start of the next statement or before the first leading comments for compound statements. - let start = if let Some(first_leading) = comments.leading(following).first() { - first_leading.slice().start() + let start = if let Some(first_leading) = following_comments.leading.first() { + first_leading.start() } else { following.start() }; @@ -255,7 +249,6 @@ impl FormatRule> for FormatSuite { // ... // ``` empty_line().fmt(f)?; - after_class_docstring = false; } else { // Insert the appropriate number of empty lines based on the node level, e.g.: // * [`NodeLevel::Module`]: Up to two empty lines @@ -275,16 +268,21 @@ impl FormatRule> for FormatSuite { // it then counts the lines between the statement and the trailing comment, which is // always 0. This is why it skips any trailing trivia (trivia that's on the same line) // and counts the lines after. - lines_after_ignoring_trivia(offset, source) + lines_after(offset, source) }; + let end = preceding_comments + .trailing + .last() + .map_or(preceding.end(), |comment| comment.slice().end()); + match node_level { - NodeLevel::TopLevel => match count_lines(preceding.end()) { + NodeLevel::TopLevel => match count_lines(end) { 0 | 1 => hard_line_break().fmt(f)?, 2 => empty_line().fmt(f)?, _ => write!(f, [empty_line(), empty_line()])?, }, - NodeLevel::CompoundStatement => match count_lines(preceding.end()) { + NodeLevel::CompoundStatement => match count_lines(end) { 0 | 1 => hard_line_break().fmt(f)?, _ => empty_line().fmt(f)?, }, @@ -294,8 +292,6 @@ impl FormatRule> for FormatSuite { } } - let following_comments = comments.leading_dangling_trailing(following); - if following_comments .leading .iter() @@ -306,6 +302,7 @@ impl FormatRule> for FormatSuite { &mut iter, f, )?; + preceding_comments = comments.leading_dangling_trailing(preceding); } else if following_comments .trailing .iter() @@ -316,16 +313,103 @@ impl FormatRule> for FormatSuite { &mut iter, f, )?; + preceding_comments = comments.leading_dangling_trailing(preceding); } else { following.format().fmt(f)?; preceding = following; + preceding_comments = following_comments; } + + after_class_docstring = false; } Ok(()) } } +/// Stub files have bespoke rules for empty lines. +/// +/// These rules are ported from black (preview mode at time of writing) using the stubs test case: +/// +fn stub_file_empty_lines( + kind: SuiteKind, + preceding: &Stmt, + following: &Stmt, + preceding_comments: &LeadingDanglingTrailingComments, + following_comments: &LeadingDanglingTrailingComments, + f: &mut PyFormatter, +) -> FormatResult<()> { + let source = f.context().source(); + // Preserve the empty line if the definitions are separated by a comment + let empty_line_condition = preceding_comments.has_trailing() + || following_comments.has_leading() + || !stub_suite_can_omit_empty_line(preceding, following, f); + match kind { + SuiteKind::TopLevel => { + if empty_line_condition { + empty_line().fmt(f) + } else { + hard_line_break().fmt(f) + } + } + SuiteKind::Class | SuiteKind::Other | SuiteKind::Function => { + if empty_line_condition && lines_after_ignoring_trivia(preceding.end(), source) > 1 { + empty_line().fmt(f) + } else { + hard_line_break().fmt(f) + } + } + } +} + +/// Only a function to compute it lazily +fn stub_suite_can_omit_empty_line(preceding: &Stmt, following: &Stmt, f: &PyFormatter) -> bool { + // Two subsequent class definitions that both have an ellipsis only body + // ```python + // class A: ... + // class B: ... + // + // @decorator + // class C: ... + // ``` + let class_sequences_with_ellipsis_only = preceding + .as_class_def_stmt() + .is_some_and(|class| contains_only_an_ellipsis(&class.body, f.context().comments())) + && following.as_class_def_stmt().is_some_and(|class| { + contains_only_an_ellipsis(&class.body, f.context().comments()) + && class.decorator_list.is_empty() + }); + + // Black for some reasons accepts decorators in place of empty lines + // ```python + // def _count1(): ... + // @final + // class LockType1: ... + // + // def _count2(): ... + // + // class LockType2: ... + // ``` + let class_decorator_instead_of_empty_line = preceding.is_function_def_stmt() + && following + .as_class_def_stmt() + .is_some_and(|class| !class.decorator_list.is_empty()); + + // A function definition following a stub function definition + // ```python + // def test(): ... + // def b(): a + // ``` + let function_with_ellipsis = preceding + .as_function_def_stmt() + .is_some_and(|function| contains_only_an_ellipsis(&function.body, f.context().comments())) + && following.is_function_def_stmt(); + + class_sequences_with_ellipsis_only + || class_decorator_instead_of_empty_line + || function_with_ellipsis +} + /// Returns `true` if a function or class body contains only an ellipsis with no comments. pub(crate) fn contains_only_an_ellipsis(body: &[Stmt], comments: &Comments) -> bool { match body { diff --git a/crates/ruff_python_formatter/src/type_param/type_param_param_spec.rs b/crates/ruff_python_formatter/src/type_param/type_param_param_spec.rs index f9a3a7ed73..c64545ce84 100644 --- a/crates/ruff_python_formatter/src/type_param/type_param_param_spec.rs +++ b/crates/ruff_python_formatter/src/type_param/type_param_param_spec.rs @@ -9,6 +9,6 @@ pub struct FormatTypeParamParamSpec; impl FormatNodeRule for FormatTypeParamParamSpec { fn fmt_fields(&self, item: &TypeParamParamSpec, f: &mut PyFormatter) -> FormatResult<()> { let TypeParamParamSpec { range: _, name } = item; - write!(f, [text("**"), name.format()]) + write!(f, [token("**"), name.format()]) } } diff --git a/crates/ruff_python_formatter/src/type_param/type_param_type_var.rs b/crates/ruff_python_formatter/src/type_param/type_param_type_var.rs index 8a86f90592..fbd3e78775 100644 --- a/crates/ruff_python_formatter/src/type_param/type_param_type_var.rs +++ b/crates/ruff_python_formatter/src/type_param/type_param_type_var.rs @@ -15,7 +15,7 @@ impl FormatNodeRule for FormatTypeParamTypeVar { } = item; name.format().fmt(f)?; if let Some(bound) = bound { - write!(f, [text(":"), space(), bound.format()])?; + write!(f, [token(":"), space(), bound.format()])?; } Ok(()) } diff --git a/crates/ruff_python_formatter/src/type_param/type_param_type_var_tuple.rs b/crates/ruff_python_formatter/src/type_param/type_param_type_var_tuple.rs index 66d1a5307e..4f7ae7ca9d 100644 --- a/crates/ruff_python_formatter/src/type_param/type_param_type_var_tuple.rs +++ b/crates/ruff_python_formatter/src/type_param/type_param_type_var_tuple.rs @@ -9,6 +9,6 @@ pub struct FormatTypeParamTypeVarTuple; impl FormatNodeRule for FormatTypeParamTypeVarTuple { fn fmt_fields(&self, item: &TypeParamTypeVarTuple, f: &mut PyFormatter) -> FormatResult<()> { let TypeParamTypeVarTuple { range: _, name } = item; - write!(f, [text("*"), name.format()]) + write!(f, [token("*"), name.format()]) } } diff --git a/crates/ruff_python_formatter/src/verbatim.rs b/crates/ruff_python_formatter/src/verbatim.rs index f50aac90a9..deaa8cf4c5 100644 --- a/crates/ruff_python_formatter/src/verbatim.rs +++ b/crates/ruff_python_formatter/src/verbatim.rs @@ -709,7 +709,7 @@ impl Format> for FormatVerbatimStatementRange { } } else { // Non empty line, write the text of the line - verbatim_text(trimmed_line_range, logical_line.contains_newlines).fmt(f)?; + verbatim_text(trimmed_line_range).fmt(f)?; // Write the line separator that terminates the line, except if it is the last line (that isn't separated by a hard line break). if logical_line.has_trailing_newline { @@ -760,7 +760,6 @@ where fn next(&mut self) -> Option { let mut parens = 0u32; - let mut contains_newlines = ContainsNewlines::No; let (content_end, full_end) = loop { match self.lexer.next() { @@ -768,18 +767,12 @@ where Tok::Newline => break (range.start(), range.end()), // Ignore if inside an expression Tok::NonLogicalNewline if parens == 0 => break (range.start(), range.end()), - Tok::NonLogicalNewline => { - contains_newlines = ContainsNewlines::Yes; - } Tok::Lbrace | Tok::Lpar | Tok::Lsqb => { parens = parens.saturating_add(1); } Tok::Rbrace | Tok::Rpar | Tok::Rsqb => { parens = parens.saturating_sub(1); } - Tok::String { value, .. } if value.contains(['\n', '\r']) => { - contains_newlines = ContainsNewlines::Yes; - } _ => {} }, None => { @@ -790,7 +783,6 @@ where self.last_line_end = self.content_end; Some(Ok(LogicalLine { content_range: TextRange::new(content_start, self.content_end), - contains_newlines: ContainsNewlines::No, has_trailing_newline: false, })) } else { @@ -810,7 +802,6 @@ where Some(Ok(LogicalLine { content_range: TextRange::new(line_start, content_end), - contains_newlines, has_trailing_newline: true, })) } @@ -822,8 +813,6 @@ impl FusedIterator for LogicalLinesIter where I: Iterator(item: T, contains_newlines: ContainsNewlines) -> VerbatimText +fn verbatim_text(item: T) -> VerbatimText where T: Ranged, { VerbatimText { verbatim_range: item.range(), - contains_newlines, } } @@ -859,19 +846,13 @@ impl Format> for VerbatimText { match normalize_newlines(f.context().locator().slice(self.verbatim_range), ['\r']) { Cow::Borrowed(_) => { - write!( - f, - [source_text_slice( - self.verbatim_range, - self.contains_newlines - )] - )?; + write!(f, [source_text_slice(self.verbatim_range,)])?; } Cow::Owned(cleaned) => { write!( f, [ - dynamic_text(&cleaned, Some(self.verbatim_range.start())), + text(&cleaned, Some(self.verbatim_range.start())), source_position(self.verbatim_range.end()) ] )?; @@ -924,7 +905,7 @@ impl Format> for FormatSuppressedNode<'_> { f, [ leading_comments(node_comments.leading), - verbatim_text(self.node, ContainsNewlines::Detect), + verbatim_text(self.node), trailing_comments(node_comments.trailing) ] ) @@ -937,13 +918,7 @@ pub(crate) fn write_suppressed_clause_header( f: &mut PyFormatter, ) -> FormatResult<()> { // Write the outer comments and format the node as verbatim - write!( - f, - [verbatim_text( - header.range(f.context().source())?, - ContainsNewlines::Detect - )] - )?; + write!(f, [verbatim_text(header.range(f.context().source())?)])?; let comments = f.context().comments(); header.visit(&mut |child| { diff --git a/crates/ruff_python_formatter/tests/fixtures.rs b/crates/ruff_python_formatter/tests/fixtures.rs index a14b4c7193..e5c8251e92 100644 --- a/crates/ruff_python_formatter/tests/fixtures.rs +++ b/crates/ruff_python_formatter/tests/fixtures.rs @@ -253,11 +253,11 @@ impl fmt::Display for DisplayPyOptions<'_> { f, r#"indent-style = {indent_style} line-width = {line_width} -tab-width = {tab_width} +indent-width = {indent_width} quote-style = {quote_style:?} magic-trailing-comma = {magic_trailing_comma:?}"#, indent_style = self.0.indent_style(), - tab_width = self.0.tab_width().value(), + indent_width = self.0.indent_width().value(), line_width = self.0.line_width().value(), quote_style = self.0.quote_style(), magic_trailing_comma = self.0.magic_trailing_comma() diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap index 2536898905..f7012d70b5 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@conditional_expression.py.snap @@ -136,6 +136,15 @@ def something(): for some_boolean_variable in some_iterable ) +@@ -86,5 +78,7 @@ + clone._iterable_class = ( + NamedValuesListIterable + if named +- else FlatValuesListIterable if flat else ValuesListIterable ++ else FlatValuesListIterable ++ if flat ++ else ValuesListIterable + ) ``` ## Ruff Output @@ -221,7 +230,9 @@ def something(): clone._iterable_class = ( NamedValuesListIterable if named - else FlatValuesListIterable if flat else ValuesListIterable + else FlatValuesListIterable + if flat + else ValuesListIterable ) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap index 7793a98149..e864b93275 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@miscellaneous__decorators.py.snap @@ -162,7 +162,7 @@ def f(): ```diff --- Black +++ Ruff -@@ -1,29 +1,182 @@ +@@ -1,29 +1,205 @@ +# This file doesn't use the standard decomposition. +# Decorator syntax test cases are separated by double # comments. +# Those before the 'output' comment are valid under the old syntax. @@ -179,6 +179,7 @@ def f(): + +## + ++ +@decorator() +def f(): + ... @@ -186,6 +187,7 @@ def f(): + +## + ++ +@decorator(arg) +def f(): + ... @@ -193,6 +195,7 @@ def f(): + +## + ++ +@decorator(kwarg=0) +def f(): + ... @@ -200,49 +203,50 @@ def f(): + +## + ++ +@decorator(*args) +def f(): + ... + + - ## - --@decorator()() ++## ++ ++ +@decorator(**kwargs) - def f(): - ... - ++def f(): ++ ... ++ ++ ++## ++ + - ## - --@(decorator) +@decorator(*args, **kwargs) - def f(): - ... - ++def f(): ++ ... ++ ++ ++## ++ + - ## - --@sequence["decorator"] +@decorator( + *args, + **kwargs, +) - def f(): - ... - ++def f(): ++ ... ++ ++ ++## ++ + - ## - --@decorator[List[str]] +@dotted.decorator - def f(): - ... - ++def f(): ++ ... ++ ++ ++## ++ + - ## - --@var := decorator +@dotted.decorator(arg) +def f(): + ... @@ -250,43 +254,54 @@ def f(): + +## + ++ +@dotted.decorator(kwarg=0) +def f(): + ... + + -+## + ## + +-@decorator()() + +@dotted.decorator(*args) -+def f(): -+ ... + def f(): + ... + + -+ -+## + ## + +-@(decorator) + +@dotted.decorator(**kwargs) -+def f(): -+ ... + def f(): + ... + + -+ -+## + ## + +-@sequence["decorator"] + +@dotted.decorator(*args, **kwargs) -+def f(): -+ ... + def f(): + ... + + -+ -+## + ## + +-@decorator[List[str]] + +@dotted.decorator( + *args, + **kwargs, +) -+def f(): -+ ... + def f(): + ... + + -+ -+## + ## + +-@var := decorator + +@double.dotted.decorator +def f(): @@ -295,6 +310,7 @@ def f(): + +## + ++ +@double.dotted.decorator(arg) +def f(): + ... @@ -302,6 +318,7 @@ def f(): + +## + ++ +@double.dotted.decorator(kwarg=0) +def f(): + ... @@ -309,6 +326,7 @@ def f(): + +## + ++ +@double.dotted.decorator(*args) +def f(): + ... @@ -316,6 +334,7 @@ def f(): + +## + ++ +@double.dotted.decorator(**kwargs) +def f(): + ... @@ -323,6 +342,7 @@ def f(): + +## + ++ +@double.dotted.decorator(*args, **kwargs) +def f(): + ... @@ -330,6 +350,7 @@ def f(): + +## + ++ +@double.dotted.decorator( + *args, + **kwargs, @@ -340,6 +361,7 @@ def f(): + +## + ++ +@_(sequence["decorator"]) +def f(): + ... @@ -347,6 +369,7 @@ def f(): + +## + ++ +@eval("sequence['decorator']") def f(): ... @@ -371,6 +394,7 @@ def f(): ## + @decorator() def f(): ... @@ -378,6 +402,7 @@ def f(): ## + @decorator(arg) def f(): ... @@ -385,6 +410,7 @@ def f(): ## + @decorator(kwarg=0) def f(): ... @@ -392,6 +418,7 @@ def f(): ## + @decorator(*args) def f(): ... @@ -399,6 +426,7 @@ def f(): ## + @decorator(**kwargs) def f(): ... @@ -406,6 +434,7 @@ def f(): ## + @decorator(*args, **kwargs) def f(): ... @@ -413,6 +442,7 @@ def f(): ## + @decorator( *args, **kwargs, @@ -423,6 +453,7 @@ def f(): ## + @dotted.decorator def f(): ... @@ -430,6 +461,7 @@ def f(): ## + @dotted.decorator(arg) def f(): ... @@ -437,6 +469,7 @@ def f(): ## + @dotted.decorator(kwarg=0) def f(): ... @@ -444,6 +477,7 @@ def f(): ## + @dotted.decorator(*args) def f(): ... @@ -451,6 +485,7 @@ def f(): ## + @dotted.decorator(**kwargs) def f(): ... @@ -458,6 +493,7 @@ def f(): ## + @dotted.decorator(*args, **kwargs) def f(): ... @@ -465,6 +501,7 @@ def f(): ## + @dotted.decorator( *args, **kwargs, @@ -475,6 +512,7 @@ def f(): ## + @double.dotted.decorator def f(): ... @@ -482,6 +520,7 @@ def f(): ## + @double.dotted.decorator(arg) def f(): ... @@ -489,6 +528,7 @@ def f(): ## + @double.dotted.decorator(kwarg=0) def f(): ... @@ -496,6 +536,7 @@ def f(): ## + @double.dotted.decorator(*args) def f(): ... @@ -503,6 +544,7 @@ def f(): ## + @double.dotted.decorator(**kwargs) def f(): ... @@ -510,6 +552,7 @@ def f(): ## + @double.dotted.decorator(*args, **kwargs) def f(): ... @@ -517,6 +560,7 @@ def f(): ## + @double.dotted.decorator( *args, **kwargs, @@ -527,6 +571,7 @@ def f(): ## + @_(sequence["decorator"]) def f(): ... @@ -534,6 +579,7 @@ def f(): ## + @eval("sequence['decorator']") def f(): ... diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap index 25780932c6..fbda66e07b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition.py.snap @@ -227,27 +227,17 @@ class C: assert expected( value, is_going_to_be="too long to fit in a single line", srsly=True -@@ -153,7 +154,8 @@ - " because it's too long" - ) - -- dis_c_instance_method = """\ -+ dis_c_instance_method = ( -+ """\ - %3d 0 LOAD_FAST 1 (x) - 2 LOAD_CONST 1 (1) - 4 COMPARE_OP 2 (==) -@@ -161,8 +163,8 @@ +@@ -161,9 +162,7 @@ 8 STORE_ATTR 0 (x) 10 LOAD_CONST 0 (None) 12 RETURN_VALUE - """ % ( - _C.__init__.__code__.co_firstlineno + 1, -+ """ -+ % (_C.__init__.__code__.co_firstlineno + 1,) - ) +- ) ++ """ % (_C.__init__.__code__.co_firstlineno + 1,) assert ( + expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect ``` ## Ruff Output @@ -409,8 +399,7 @@ class C: " because it's too long" ) - dis_c_instance_method = ( - """\ + dis_c_instance_method = """\ %3d 0 LOAD_FAST 1 (x) 2 LOAD_CONST 1 (1) 4 COMPARE_OP 2 (==) @@ -418,9 +407,7 @@ class C: 8 STORE_ATTR 0 (x) 10 LOAD_CONST 0 (None) 12 RETURN_VALUE - """ - % (_C.__init__.__code__.co_firstlineno + 1,) - ) + """ % (_C.__init__.__code__.co_firstlineno + 1,) assert ( expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap index 48a59144c5..06bcb6b4e7 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__composition_no_trailing_comma.py.snap @@ -227,27 +227,17 @@ class C: assert expected( value, is_going_to_be="too long to fit in a single line", srsly=True -@@ -153,7 +154,8 @@ - " because it's too long" - ) - -- dis_c_instance_method = """\ -+ dis_c_instance_method = ( -+ """\ - %3d 0 LOAD_FAST 1 (x) - 2 LOAD_CONST 1 (1) - 4 COMPARE_OP 2 (==) -@@ -161,8 +163,8 @@ +@@ -161,9 +162,7 @@ 8 STORE_ATTR 0 (x) 10 LOAD_CONST 0 (None) 12 RETURN_VALUE - """ % ( - _C.__init__.__code__.co_firstlineno + 1, -+ """ -+ % (_C.__init__.__code__.co_firstlineno + 1,) - ) +- ) ++ """ % (_C.__init__.__code__.co_firstlineno + 1,) assert ( + expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect ``` ## Ruff Output @@ -409,8 +399,7 @@ class C: " because it's too long" ) - dis_c_instance_method = ( - """\ + dis_c_instance_method = """\ %3d 0 LOAD_FAST 1 (x) 2 LOAD_CONST 1 (1) 4 COMPARE_OP 2 (==) @@ -418,9 +407,7 @@ class C: 8 STORE_ATTR 0 (x) 10 LOAD_CONST 0 (None) 12 RETURN_VALUE - """ - % (_C.__init__.__code__.co_firstlineno + 1,) - ) + """ % (_C.__init__.__code__.co_firstlineno + 1,) assert ( expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__empty_lines.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__empty_lines.py.snap deleted file mode 100644 index 72e8d2306d..0000000000 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__empty_lines.py.snap +++ /dev/null @@ -1,304 +0,0 @@ ---- -source: crates/ruff_python_formatter/tests/fixtures.rs -input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/empty_lines.py ---- -## Input - -```py -"""Docstring.""" - - -# leading comment -def f(): - NO = '' - SPACE = ' ' - DOUBLESPACE = ' ' - - t = leaf.type - p = leaf.parent # trailing comment - v = leaf.value - - if t in ALWAYS_NO_SPACE: - pass - if t == token.COMMENT: # another trailing comment - return DOUBLESPACE - - - assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" - - - prev = leaf.prev_sibling - if not prev: - prevp = preceding_leaf(p) - if not prevp or prevp.type in OPENING_BRACKETS: - - - return NO - - - if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: - return NO - - elif prevp.type == token.DOUBLESTAR: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.dictsetmaker, - }: - return NO - -############################################################################### -# SECTION BECAUSE SECTIONS -############################################################################### - -def g(): - NO = '' - SPACE = ' ' - DOUBLESPACE = ' ' - - t = leaf.type - p = leaf.parent - v = leaf.value - - # Comment because comments - - if t in ALWAYS_NO_SPACE: - pass - if t == token.COMMENT: - return DOUBLESPACE - - # Another comment because more comments - assert p is not None, f'INTERNAL ERROR: hand-made leaf without parent: {leaf!r}' - - prev = leaf.prev_sibling - if not prev: - prevp = preceding_leaf(p) - - if not prevp or prevp.type in OPENING_BRACKETS: - # Start of the line or a bracketed expression. - # More than one line for the comment. - return NO - - if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: - return NO -``` - -## Black Differences - -```diff ---- Black -+++ Ruff -@@ -49,7 +49,6 @@ - # SECTION BECAUSE SECTIONS - ############################################################################### - -- - def g(): - NO = "" - SPACE = " " -``` - -## Ruff Output - -```py -"""Docstring.""" - - -# leading comment -def f(): - NO = "" - SPACE = " " - DOUBLESPACE = " " - - t = leaf.type - p = leaf.parent # trailing comment - v = leaf.value - - if t in ALWAYS_NO_SPACE: - pass - if t == token.COMMENT: # another trailing comment - return DOUBLESPACE - - assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" - - prev = leaf.prev_sibling - if not prev: - prevp = preceding_leaf(p) - if not prevp or prevp.type in OPENING_BRACKETS: - return NO - - if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: - return NO - - elif prevp.type == token.DOUBLESTAR: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.dictsetmaker, - }: - return NO - - -############################################################################### -# SECTION BECAUSE SECTIONS -############################################################################### - -def g(): - NO = "" - SPACE = " " - DOUBLESPACE = " " - - t = leaf.type - p = leaf.parent - v = leaf.value - - # Comment because comments - - if t in ALWAYS_NO_SPACE: - pass - if t == token.COMMENT: - return DOUBLESPACE - - # Another comment because more comments - assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" - - prev = leaf.prev_sibling - if not prev: - prevp = preceding_leaf(p) - - if not prevp or prevp.type in OPENING_BRACKETS: - # Start of the line or a bracketed expression. - # More than one line for the comment. - return NO - - if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: - return NO -``` - -## Black Output - -```py -"""Docstring.""" - - -# leading comment -def f(): - NO = "" - SPACE = " " - DOUBLESPACE = " " - - t = leaf.type - p = leaf.parent # trailing comment - v = leaf.value - - if t in ALWAYS_NO_SPACE: - pass - if t == token.COMMENT: # another trailing comment - return DOUBLESPACE - - assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" - - prev = leaf.prev_sibling - if not prev: - prevp = preceding_leaf(p) - if not prevp or prevp.type in OPENING_BRACKETS: - return NO - - if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: - return NO - - elif prevp.type == token.DOUBLESTAR: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.dictsetmaker, - }: - return NO - - -############################################################################### -# SECTION BECAUSE SECTIONS -############################################################################### - - -def g(): - NO = "" - SPACE = " " - DOUBLESPACE = " " - - t = leaf.type - p = leaf.parent - v = leaf.value - - # Comment because comments - - if t in ALWAYS_NO_SPACE: - pass - if t == token.COMMENT: - return DOUBLESPACE - - # Another comment because more comments - assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}" - - prev = leaf.prev_sibling - if not prev: - prevp = preceding_leaf(p) - - if not prevp or prevp.type in OPENING_BRACKETS: - # Start of the line or a bracketed expression. - # More than one line for the comment. - return NO - - if prevp.type == token.EQUAL: - if prevp.parent and prevp.parent.type in { - syms.typedargslist, - syms.varargslist, - syms.parameters, - syms.arglist, - syms.argument, - }: - return NO -``` - - diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap index 86a5b37df9..0ee2ffdceb 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__expression.py.snap @@ -300,38 +300,6 @@ last_call() ) # note: no trailing comma pre-3.6 call(*gidgets[:2]) call(a, *gidgets[:2]) -@@ -328,13 +329,18 @@ - ): - return True - if ( -- ~aaaa.a + aaaa.b - aaaa.c * aaaa.d / aaaa.e -+ ~aaaa.a -+ + aaaa.b -+ - aaaa.c * aaaa.d / aaaa.e - | aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l**aaaa.m // aaaa.n - ): - return True - if ( -- ~aaaaaaaa.a + aaaaaaaa.b - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e -- | aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h -+ ~aaaaaaaa.a -+ + aaaaaaaa.b -+ - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e -+ | aaaaaaaa.f -+ & aaaaaaaa.g % aaaaaaaa.h - ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n - ): - return True -@@ -342,7 +348,8 @@ - ~aaaaaaaaaaaaaaaa.a - + aaaaaaaaaaaaaaaa.b - - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e -- | aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h -+ | aaaaaaaaaaaaaaaa.f -+ & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h - ^ aaaaaaaaaaaaaaaa.i - << aaaaaaaaaaaaaaaa.k - >> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n ``` ## Ruff Output @@ -668,18 +636,13 @@ if ( ): return True if ( - ~aaaa.a - + aaaa.b - - aaaa.c * aaaa.d / aaaa.e + ~aaaa.a + aaaa.b - aaaa.c * aaaa.d / aaaa.e | aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l**aaaa.m // aaaa.n ): return True if ( - ~aaaaaaaa.a - + aaaaaaaa.b - - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e - | aaaaaaaa.f - & aaaaaaaa.g % aaaaaaaa.h + ~aaaaaaaa.a + aaaaaaaa.b - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e + | aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l**aaaaaaaa.m // aaaaaaaa.n ): return True @@ -687,8 +650,7 @@ if ( ~aaaaaaaaaaaaaaaa.a + aaaaaaaaaaaaaaaa.b - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e - | aaaaaaaaaaaaaaaa.f - & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h + | aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h ^ aaaaaaaaaaaaaaaa.i << aaaaaaaaaaaaaaaa.k >> aaaaaaaaaaaaaaaa.l**aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap index 91f218dcb2..ce417c728b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff.py.snap @@ -198,7 +198,15 @@ d={'a':1, ```diff --- Black +++ Ruff -@@ -63,15 +63,15 @@ +@@ -5,6 +5,7 @@ + from third_party import X, Y, Z + + from library import some_connection, some_decorator ++ + # fmt: off + from third_party import (X, + Y, Z) +@@ -63,15 +64,15 @@ something = { # fmt: off @@ -217,7 +225,7 @@ d={'a':1, # fmt: on goes + here, andhere, -@@ -122,8 +122,10 @@ +@@ -122,8 +123,10 @@ """ # fmt: off @@ -229,7 +237,7 @@ d={'a':1, # fmt: on pass -@@ -138,7 +140,7 @@ +@@ -138,7 +141,7 @@ now . considers . multiple . fmt . directives . within . one . prefix # fmt: on # fmt: off @@ -238,7 +246,7 @@ d={'a':1, # fmt: on -@@ -178,14 +180,18 @@ +@@ -178,14 +181,18 @@ $ """, # fmt: off @@ -271,6 +279,7 @@ import sys from third_party import X, Y, Z from library import some_connection, some_decorator + # fmt: off from third_party import (X, Y, Z) diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap index b28415f3ac..a3b86b9e60 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtonoff5.py.snap @@ -110,15 +110,7 @@ elif unformatted: }, ) -@@ -74,7 +73,6 @@ - class Factory(t.Protocol): - def this_will_be_formatted(self, **kwargs) -> Named: - ... -- - # fmt: on - - -@@ -82,6 +80,6 @@ +@@ -82,6 +81,6 @@ if x: return x # fmt: off @@ -206,6 +198,7 @@ class Named(t.Protocol): class Factory(t.Protocol): def this_will_be_formatted(self, **kwargs) -> Named: ... + # fmt: on diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap new file mode 100644 index 0000000000..7d2474337a --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__fmtpass_imports.py.snap @@ -0,0 +1,93 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_cases/fmtpass_imports.py +--- +## Input + +```py +# Regression test for https://github.com/psf/black/issues/3438 + +import ast +import collections # fmt: skip +import dataclasses +# fmt: off +import os +# fmt: on +import pathlib + +import re # fmt: skip +import secrets + +# fmt: off +import sys +# fmt: on + +import tempfile +import zoneinfo +``` + +## Black Differences + +```diff +--- Black ++++ Ruff +@@ -3,6 +3,7 @@ + import ast + import collections # fmt: skip + import dataclasses ++ + # fmt: off + import os + # fmt: on +``` + +## Ruff Output + +```py +# Regression test for https://github.com/psf/black/issues/3438 + +import ast +import collections # fmt: skip +import dataclasses + +# fmt: off +import os +# fmt: on +import pathlib + +import re # fmt: skip +import secrets + +# fmt: off +import sys +# fmt: on + +import tempfile +import zoneinfo +``` + +## Black Output + +```py +# Regression test for https://github.com/psf/black/issues/3438 + +import ast +import collections # fmt: skip +import dataclasses +# fmt: off +import os +# fmt: on +import pathlib + +import re # fmt: skip +import secrets + +# fmt: off +import sys +# fmt: on + +import tempfile +import zoneinfo +``` + + diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap index 428ca61376..628dbb5c6a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@simple_cases__remove_await_parens.py.snap @@ -93,7 +93,7 @@ async def main(): ```diff --- Black +++ Ruff -@@ -21,7 +21,9 @@ +@@ -21,11 +21,15 @@ # Check comments async def main(): @@ -103,6 +103,13 @@ async def main(): + ) + async def main(): +- await asyncio.sleep(1) # Hello ++ await ( ++ asyncio.sleep(1) # Hello ++ ) + + async def main(): ``` @@ -138,7 +145,9 @@ async def main(): async def main(): - await asyncio.sleep(1) # Hello + await ( + asyncio.sleep(1) # Hello + ) async def main(): diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap index e4916db81d..5f30361102 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap @@ -111,9 +111,9 @@ class TabbedIndent: ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 8 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -224,9 +224,9 @@ class TabbedIndent: ### Output 2 ``` -indent-style = Spaces, size: 2 +indent-style = space line-width = 88 -tab-width = 8 +indent-width = 2 quote-style = Double magic-trailing-comma = Respect ``` @@ -337,9 +337,9 @@ class TabbedIndent: ### Output 3 ``` -indent-style = Tab +indent-style = tab line-width = 88 -tab-width = 8 +indent-width = 8 quote-style = Double magic-trailing-comma = Respect ``` @@ -450,9 +450,9 @@ class TabbedIndent: ### Output 4 ``` -indent-style = Tab +indent-style = tab line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -556,7 +556,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - autor """ ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap index 172b318812..2e8975b248 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary.py.snap @@ -228,6 +228,173 @@ x = ( x = ( () - () # ) + + +# Avoid unnecessary parentheses around multiline strings. +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" % ( + self.base_url, + date.today(), +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + # Needs parentheses + % ( + self.base_url, + date.today(), + ) +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + # Needs parentheses + ( + self.base_url, + date.today(), + ) +) + + +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" + a.call.expression( + self.base_url, + date.today(), +) + +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" + sssssssssssssssssssssssssssssssssssssssssooooo * looooooooooooooooooooooooooooooongggggggggggg + +call(arg1, arg2, """ +short +""", arg3=True) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + ( + self.base_url + ) +) + + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + ( + # Needs parentheses + self.base_url + ) +) + + +rowuses = [(1 << j) | # column ordinal + (1 << (n + i-j + n-1)) | # NW-SE ordinal + (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal + for j in rangen] + +rowuses = [((1 << j) # column ordinal + )| + ( + # comment + (1 << (n + i-j + n-1))) | # NW-SE ordinal + (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal + for j in rangen] + +skip_bytes = ( + header.timecnt * 5 # Transition times and types + + header.typecnt * 6 # Local time type records + + header.charcnt # Time zone designations + + header.leapcnt * 8 # Leap second records + + header.isstdcnt # Standard/wall indicators + + header.isutcnt # UT/local indicators +) + + +if ( + (1 + 2) # test + or (3 + 4) # other + or (4 + 5) # more +): + pass + + +if ( + (1 and 2) # test + + (3 and 4) # other + + (4 and 5) # more +): + pass + + +if ( + (1 + 2) # test + < (3 + 4) # other + > (4 + 5) # more +): + pass + + z = ( + a + + + # a: extracts this comment + ( + # b: and this comment + ( + # c: formats it as part of the expression + x and y + ) + ) + ) + +z = ( + ( + + ( + + x and y + # a: formats it as part of the expression + + ) + # b: extracts this comment + + ) + # c: and this comment + + a +) ``` ## Output @@ -459,19 +626,15 @@ if [ ... -if ( - [ - fffffffffffffffff, - gggggggggggggggggggg, - hhhhhhhhhhhhhhhhhhhhh, - iiiiiiiiiiiiiiii, - jjjjjjjjjjjjj, - ] - & - ( - # comment - a + b - ) +if [ + fffffffffffffffff, + gggggggggggggggggggg, + hhhhhhhhhhhhhhhhhhhhh, + iiiiiiiiiiiiiiii, + jjjjjjjjjjjjj, +] & ( + # comment + a + b ): ... @@ -512,6 +675,170 @@ x = ( x = ( () - () # ) + + +# Avoid unnecessary parentheses around multiline strings. +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" % ( + self.base_url, + date.today(), +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + # Needs parentheses + % ( + self.base_url, + date.today(), + ) +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % + # Needs parentheses + ( + self.base_url, + date.today(), + ) +) + + +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" + a.call.expression( + self.base_url, + date.today(), +) + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + + sssssssssssssssssssssssssssssssssssssssssooooo + * looooooooooooooooooooooooooooooongggggggggggg +) + +call( + arg1, + arg2, + """ +short +""", + arg3=True, +) + +expected_content = """ + +%s/simple/sitemap-simple.xml%s + + +""" % (self.base_url) + + +expected_content = ( + """ + +%s/simple/sitemap-simple.xml%s + + +""" + % ( + # Needs parentheses + self.base_url + ) +) + + +rowuses = [ + (1 << j) # column ordinal + | (1 << (n + i - j + n - 1)) # NW-SE ordinal + | (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal + for j in rangen +] + +rowuses = [ + (1 << j) # column ordinal + | + # comment + (1 << (n + i - j + n - 1)) # NW-SE ordinal + | (1 << (n + 2 * n - 1 + i + j)) # NE-SW ordinal + for j in rangen +] + +skip_bytes = ( + header.timecnt * 5 # Transition times and types + + header.typecnt * 6 # Local time type records + + header.charcnt # Time zone designations + + header.leapcnt * 8 # Leap second records + + header.isstdcnt # Standard/wall indicators + + header.isutcnt # UT/local indicators +) + + +if ( + (1 + 2) # test + or (3 + 4) # other + or (4 + 5) # more +): + pass + + +if ( + (1 and 2) # test + + (3 and 4) # other + + (4 and 5) # more +): + pass + + +if ( + (1 + 2) # test + < (3 + 4) # other + > (4 + 5) # more +): + pass + +z = ( + a + + + # a: extracts this comment + # b: and this comment + ( + # c: formats it as part of the expression + x and y + ) +) + +z = ( + ( + x and y + # a: formats it as part of the expression + ) + # b: extracts this comment + # c: and this comment + + a +) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap index 207b8772ba..286353d24f 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__binary_implicit_string.py.snap @@ -90,6 +90,15 @@ self._assert_skipping( + x ) +( + b + c + d + + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + f"bbbbbb{z}bbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" + % aaaaaaaaaaaa + + x +) + ( b < c > d < "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -124,6 +133,68 @@ def test3(): "(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) " "THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)" ) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3 + +c = (a + + # test leading binary comment + "a" "b" * b +) + +c = (a * + # test leading comment + "a" "b" + b + ) + +c = (a + + # test trailing comment + "a" "b" * b + ) + +c = (a + + + "a" "b" # test trailing comment + * b + ) + +c = (a + * + "a" "b" # test trailing binary comment + + b + ) + +c = (a + * + "a" "b" + + # test trailing operator comment + b + ) + +c = (a + * + "a" "b" + + + # test trailing operator comment + b + ) + +c = ("a" "b" + + # test leading binary comment + "a" "b" + ) + +( + b + c + d + + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + + "cccccccccccccccccccccccccc" + "dddddddddddddddddddddddddd" + % aaaaaaaaaaaa + + x +) + +"a" "b" "c" + "d" "e" + "f" "g" + "h" "i" "j" +class EC2REPATH: + f.write ("Pathway name" + "\t" "Database Identifier" + "\t" "Source database" + "\n") + ``` ## Output @@ -215,37 +286,32 @@ self._assert_skipping( ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - "cccccccccccccccccccccccccc" - % aaaaaaaaaaaa - + x + "cccccccccccccccccccccccccc" % aaaaaaaaaaaa + x ) ( - b - + c - + d - + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + b + c + d + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - "cccccccccccccccccccccccccc" % aaaaaaaaaaaa - + x + "cccccccccccccccccccccccccc" % aaaaaaaaaaaa + x ) ( - b - < c - > d - < "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + b + c + d + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + f"bbbbbb{z}bbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" % aaaaaaaaaaaa + x +) + +( + b < c > d < "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - "cccccccccccccccccccccccccc" % aaaaaaaaaaaa - > x + "cccccccccccccccccccccccccc" % aaaaaaaaaaaa > x ) self.assertEqual( response.status_code, status_code, - msg_prefix - + "Couldn't retrieve content: Response code was %d" + msg_prefix + "Couldn't retrieve content: Response code was %d" " (expected %d)" % (response.status_code, status_code), ) @@ -269,6 +335,74 @@ def test3(): "(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) " "THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)" ) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3 + + +c = ( + a + + # test leading binary comment + "a" + "b" * b +) + +c = ( + a * + # test leading comment + "a" + "b" + b +) + +c = ( + a + + # test trailing comment + "a" + "b" * b +) + +c = ( + a + "a" + "b" # test trailing comment + * b +) + +c = ( + a * "a" + "b" # test trailing binary comment + + b +) + +c = ( + a * "a" + "b" + + # test trailing operator comment + b +) + +c = ( + a * "a" + "b" + + # test trailing operator comment + b +) + +c = ( + "a" + "b" + + # test leading binary comment + "a" + "b" +) + +( + b + c + d + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" + "dddddddddddddddddddddddddd" % aaaaaaaaaaaa + x +) + +"a" "b" "c" + "d" "e" + "f" "g" + "h" "i" "j" + + +class EC2REPATH: + f.write("Pathway name" + "\t" "Database Identifier" + "\t" "Source database" + "\n") ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap index 3f3f171e49..e62f59f804 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__boolean_operation.py.snap @@ -108,6 +108,89 @@ def test(): and {k.lower(): v for k, v in self.items()} == {k.lower(): v for k, v in other.items()} ) + + + +if "_continue" in request.POST or ( + # Redirecting after "Save as new". + "_saveasnew" in request.POST + and self.save_as_continue + and self.has_change_permission(request, obj) +): + pass + + +if True: + if False: + if True: + if ( + self.validate_max + and self.total_form_count() - len(self.deleted_forms) > self.max_num + ) or self.management_form.cleaned_data[ + TOTAL_FORM_COUNT + ] > self.absolute_max: + pass + + +if True: + if ( + reference_field_name is None + or + # Unspecified to_field(s). + to_fields is None + or + # Reference to primary key. + ( + None in to_fields + and (reference_field is None or reference_field.primary_key) + ) + or + # Reference to field. + reference_field_name in to_fields + ): + pass + + +field = opts.get_field(name) +if ( + field.is_relation + and + # Generic foreign keys OR reverse relations + ((field.many_to_one and not field.related_model) or field.one_to_many) +): + pass + + +if True: + return ( + filtered.exists() + and + # It may happen that the object is deleted from the DB right after + # this check, causing the subsequent UPDATE to return zero matching + # rows. The same result can occur in some rare cases when the + # database returns zero despite the UPDATE being executed + # successfully (a row is matched and updated). In order to + # distinguish these two cases, the object's existence in the + # database is again checked for if the UPDATE query returns 0. + (filtered._update(values) > 0 or filtered.exists()) + ) + + +if (self._proc is not None + # has the child process finished? + and self._returncode is None + # the child process has finished, but the + # transport hasn't been notified yet? + and self._proc.poll() is None): + pass + +if (self._proc + # has the child process finished? + * self._returncode + # the child process has finished, but the + # transport hasn't been notified yet? + + self._proc.poll()): + pass ``` ## Output @@ -234,6 +317,89 @@ def test(): return isinstance(other, Mapping) and {k.lower(): v for k, v in self.items()} == { k.lower(): v for k, v in other.items() } + + +if "_continue" in request.POST or ( + # Redirecting after "Save as new". + "_saveasnew" in request.POST + and self.save_as_continue + and self.has_change_permission(request, obj) +): + pass + + +if True: + if False: + if True: + if ( + self.validate_max + and self.total_form_count() - len(self.deleted_forms) > self.max_num + ) or self.management_form.cleaned_data[ + TOTAL_FORM_COUNT + ] > self.absolute_max: + pass + + +if True: + if ( + reference_field_name is None + or + # Unspecified to_field(s). + to_fields is None + or + # Reference to primary key. + (None in to_fields and (reference_field is None or reference_field.primary_key)) + or + # Reference to field. + reference_field_name in to_fields + ): + pass + + +field = opts.get_field(name) +if ( + field.is_relation + and + # Generic foreign keys OR reverse relations + ((field.many_to_one and not field.related_model) or field.one_to_many) +): + pass + + +if True: + return ( + filtered.exists() + and + # It may happen that the object is deleted from the DB right after + # this check, causing the subsequent UPDATE to return zero matching + # rows. The same result can occur in some rare cases when the + # database returns zero despite the UPDATE being executed + # successfully (a row is matched and updated). In order to + # distinguish these two cases, the object's existence in the + # database is again checked for if the UPDATE query returns 0. + (filtered._update(values) > 0 or filtered.exists()) + ) + + +if ( + self._proc is not None + # has the child process finished? + and self._returncode is None + # the child process has finished, but the + # transport hasn't been notified yet? + and self._proc.poll() is None +): + pass + +if ( + self._proc + # has the child process finished? + * self._returncode + # the child process has finished, but the + # transport hasn't been notified yet? + + self._proc.poll() +): + pass ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap index e8bf4b5546..1b0564c04c 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__bytes.py.snap @@ -129,9 +129,9 @@ test_particular = [ ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -222,8 +222,7 @@ b"Let's" b"start" b"with" b"a" b"simple" b"example" b"now repeat after me:" b"I ) if ( - a - + b"Let's" + a + b"Let's" b"start" b"with" b"a" @@ -278,9 +277,9 @@ test_particular = [ ### Output 2 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Single magic-trailing-comma = Respect ``` @@ -371,8 +370,7 @@ b"Let's" b'start' b'with' b'a' b'simple' b'example' b'now repeat after me:' b'I ) if ( - a - + b"Let's" + a + b"Let's" b'start' b'with' b'a' diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap index e3771e0389..1e4b44427b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__call.py.snap @@ -86,6 +86,21 @@ f( # oddly placed own line comment dict() ) +f( + session, + b=1, + **(# oddly placed own line comment + dict() + ) +) +f( + session, + b=1, + **( + # oddly placed own line comment + dict() + ) +) # Don't add a magic trailing comma when there is only one entry # Minimized from https://github.com/django/django/blob/7eeadc82c2f7d7a778e3bb43c34d642e6275dacf/django/contrib/admin/checks.py#L674-L681 @@ -211,6 +226,51 @@ aaa = ( () .bbbbbbbbbbbbbbbb ) + +# Comments around keywords +f(x= # comment + 1) + +f(x # comment + = + 1) + +f(x= + # comment + 1) + +f(x=(# comment + 1 +)) + + +f(x=( + # comment + 1 +)) + +args = [2] +args2 = [3] +kwargs = {"4": 5} + +# https://github.com/astral-sh/ruff/issues/6498 +f(a=1, *args, **kwargs) +f(*args, a=1, **kwargs) +f(*args, a=1, *args2, **kwargs) +f( # a + * # b + args + # c + , # d + a=1, + # e + * # f + args2 + # g + ** # h + kwargs, +) + ``` ## Output @@ -288,13 +348,29 @@ f("aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaa f( session, b=1, - **dict(), # oddly placed end-of-line comment + # oddly placed end-of-line comment + **dict(), ) f( session, b=1, - **dict(), # oddly placed own line comment + **dict(), +) +f( + session, + b=1, + **( # oddly placed own line comment + dict() + ), +) +f( + session, + b=1, + **( + # oddly placed own line comment + dict() + ), ) # Don't add a magic trailing comma when there is only one entry @@ -333,10 +409,10 @@ threshold_date = datetime.datetime.now() - datetime.timedelta( # comment ) # Parenthesized and opening-parenthesis comments -func(x for x in y) +func((x for x in y)) func( # outer comment - x for x in y + (x for x in y) ) func( @@ -346,9 +422,11 @@ func( ) func( - # inner comment - x - for x in y + ( + # inner comment + x + for x in y + ) ) func( # outer comment @@ -408,6 +486,57 @@ aaa = ( bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # awkward comment )().bbbbbbbbbbbbbbbb + +# Comments around keywords +f( + # comment + x=1 +) + +f( + # comment + x=1 +) + +f( + # comment + x=1 +) + +f( + x=( # comment + 1 + ) +) + + +f( + x=( + # comment + 1 + ) +) + +args = [2] +args2 = [3] +kwargs = {"4": 5} + +# https://github.com/astral-sh/ruff/issues/6498 +f(a=1, *args, **kwargs) +f(*args, a=1, **kwargs) +f(*args, a=1, *args2, **kwargs) +f( # a + # b + *args, # d + # c + a=1, + # e + # f + *args2 + # g + ** # h + kwargs, +) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap index e47b22e60a..bb3dabb8ac 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__compare.py.snap @@ -117,6 +117,73 @@ ct_match = ( ct_match = ( (aaaaaaaaaaaaaaaa) == self.get_content_type[obj, rel_obj, using, instance._state.db].id ) + +# comments + +c = ( + 1 > # 1 + # 2 + 3 # 3 + > # 4 + 5 # 5 + # 6 +) + +# Implicit strings and comments + +assert ( + "One or more packages has an associated PGP signature; these will " + "be silently ignored by the index" + in caplog.messages +) + +( + b < c > d < + f"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" + % aaaaaaaaaaaa + > x +) + +c = (a > + # test leading binary comment + "a" "b" * b + ) + +c = (a * + # test leading comment + "a" "b" > b + ) + +c = (a + > # test trailing comment + "a" "b" * b + ) + +c = (a + > + "a" "b" # test trailing comment + * b + ) + +c = (a + > + "a" "b" # test trailing binary comment + + b + ) + + +c = (a > + # test leading binary comment + "a" "b" * b + ) + +c = (a * + # test leading comment + "a" "b" > b + ) + ``` ## Output @@ -134,8 +201,9 @@ a not in b ( a + == # comment - == b + b ) ( @@ -271,13 +339,84 @@ ct_match = ( == self.get_content_type[obj, rel_obj, using, instance._state.db].id ) -ct_match = { - aaaaaaaaaaaaaaaa -} == self.get_content_type[obj, rel_obj, using, instance._state.db].id +ct_match = {aaaaaaaaaaaaaaaa} == self.get_content_type[ + obj, rel_obj, using, instance._state.db +].id -ct_match = ( - aaaaaaaaaaaaaaaa -) == self.get_content_type[obj, rel_obj, using, instance._state.db].id +ct_match = (aaaaaaaaaaaaaaaa) == self.get_content_type[ + obj, rel_obj, using, instance._state.db +].id + +# comments + +c = ( + 1 # 1 + > + # 2 + 3 # 3 # 4 + > 5 # 5 + # 6 +) + +# Implicit strings and comments + +assert ( + "One or more packages has an associated PGP signature; these will " + "be silently ignored by the index" in caplog.messages +) + +( + b < c > d < f"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "cccccccccccccccccccccccccc" % aaaaaaaaaaaa > x +) + +c = ( + a > + # test leading binary comment + "a" + "b" * b +) + +c = ( + a * + # test leading comment + "a" + "b" > b +) + +c = ( + a # test trailing comment + > "a" + "b" * b +) + +c = ( + a > "a" + "b" # test trailing comment + * b +) + +c = ( + a > "a" + "b" # test trailing binary comment + + b +) + + +c = ( + a > + # test leading binary comment + "a" + "b" * b +) + +c = ( + a * + # test leading comment + "a" + "b" > b +) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap index a5b6c5e896..a1e535b1c2 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict.py.snap @@ -80,22 +80,26 @@ x={ # dangling end of line comment { **a, # leading - **b, # middle # trailing + # middle + **b, # trailing } { - **b # middle with single item + # middle with single item + **b } { # before - **b, # between + # between + **b, } { **a, # comment before preceding node's comma # before - **b, # between + # between + **b, } {} diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap index aa3f0a5133..37fa5a5e40 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap @@ -39,6 +39,30 @@ result_f = ( # comment '' ) + +( + f'{1}' # comment + f'{2}' +) + +( + f'{1}' + f'{2}' # comment +) + +( + 1, ( # comment + f'{2}' + ) +) + +( + ( + f'{1}' + # comment + ), + 2 +) ``` ## Output @@ -76,6 +100,30 @@ result_f = ( # comment "" ) + +( + f"{1}" # comment + f"{2}" +) + +( + f"{1}" f"{2}" # comment +) + +( + 1, + ( # comment + f"{2}" + ), +) + +( + ( + f"{1}" + # comment + ), + 2, +) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap index ed11b4724c..cc166a931b 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__generator_exp.py.snap @@ -22,6 +22,11 @@ f((1) for _ in (a)) # combination of the two above f(((1) for _ in (a))) +bases = tuple( + (base._meta.label_lower if hasattr(base, "_meta") else base) + for base in flattened_bases +) + # black keeps these atm, but intends to remove them in the future: # https://github.com/psf/black/issues/2943 @@ -67,13 +72,18 @@ sum((a for b in c), start=0) # black keeps these atm, but intends to remove them in the future: # https://github.com/psf/black/issues/2943 -f(1 for _ in a) +f((1 for _ in a)) # make sure source parenthesis detection isn't fooled by these f((1) for _ in (a)) # combination of the two above -f((1) for _ in (a)) +f(((1) for _ in (a))) + +bases = tuple( + (base._meta.label_lower if hasattr(base, "_meta") else base) + for base in flattened_bases +) # black keeps these atm, but intends to remove them in the future: diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap index f5a195c622..7aa5a080c8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__if.py.snap @@ -45,6 +45,75 @@ d1 = [ ("b") else # 2 ("c") ] + +e1 = ( + a + if True # 1 + else b + if False # 2 + else c +) + + +# Flattening nested if-expressions. +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + (NamedValuesListIterable + if named + else FlatValuesListIterable) + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else (FlatValuesListIterable + if flat + else ValuesListIterable) + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable(1,) + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else (FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + if flat + else ValuesListIterable) + ) ``` ## Output @@ -96,6 +165,81 @@ d1 = [ # 2 else ("c") ] + +e1 = ( + a + if True # 1 + else b + if False # 2 + else c +) + + +# Flattening nested if-expressions. +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + (NamedValuesListIterable if named else FlatValuesListIterable) + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else (FlatValuesListIterable if flat else ValuesListIterable) + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable( + 1, + ) + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else FlatValuesListIterable + + FlatValuesListIterable + + FlatValuesListIterable + + FlatValuesListIterable + if flat + else ValuesListIterable + ) + + +def something(): + clone._iterable_class = ( + NamedValuesListIterable + if named + else ( + FlatValuesListIterable + + FlatValuesListIterable + + FlatValuesListIterable + + FlatValuesListIterable + if flat + else ValuesListIterable + ) + ) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap index 73e3bcc04d..7585e7f371 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__lambda.py.snap @@ -124,6 +124,41 @@ lambda a, /, c: a # 4 None # 5 ) + +( + lambda + # comment + *x: x +) + +( + lambda + # comment 1 + * + # comment 2 + x: + # comment 3 + x +) + +( + lambda # comment 1 + * # comment 2 + x: # comment 3 + x +) + +lambda *x\ + :x + +( + lambda + # comment + *\ + x: x +) + + ``` ## Output @@ -185,7 +220,8 @@ lambda x: lambda y: lambda z: ( # Trailing a = ( - lambda: # Dangling + lambda: + # Dangling 1 ) @@ -232,22 +268,51 @@ lambda a, /, c: a # Dangling comments without parameters. ( - lambda: # 3 + lambda: + # 3 None ) ( - lambda: # 3 + lambda: + # 3 None ) ( - lambda: # 1 + lambda: + # 1 # 2 # 3 # 4 None # 5 ) + +( + lambda # comment + *x: x +) + +( + lambda # comment 1 + # comment 2 + *x: + # comment 3 + x +) + +( + lambda # comment 1 + # comment 2 + *x: x # comment 3 +) + +lambda *x: x + +( + lambda # comment + *x: x +) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap index 9046b6740f..cbf28c546a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__string.py.snap @@ -141,9 +141,9 @@ x = (b"""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa""" b"""bbbbbbbbbbbbbbbbbbbbbbbbbbb ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -240,8 +240,7 @@ String \"\"\" ) if ( - a - + "Let's" + a + "Let's" "start" "with" "a" @@ -311,9 +310,9 @@ x = ( ### Output 2 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Single magic-trailing-comma = Respect ``` @@ -410,8 +409,7 @@ String \"\"\" ) if ( - a - + "Let's" + a + "Let's" 'start' 'with' 'a' diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap index 85dfa81fff..0f8997294a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap @@ -72,6 +72,9 @@ g2 = ( # a h1 = ((((1, 2)))) h2 = ((((1, "qweiurpoiqwurepqiurpqirpuqoiwrupqoirupqoirupqoiurpqiorupwqiourpqurpqurpqurpqurpqurpqurüqurqpuriq")))) h3 = 1, "qweiurpoiqwurepqiurpqirpuqoiwrupqoirupqoirupqoiurpqiorupwqiourpqurpqurpqurpqurpqurpqurüqurqpuriq" + +i1 = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # This should break + ``` ## Output @@ -275,6 +278,10 @@ h3 = ( 1, "qweiurpoiqwurepqiurpqirpuqoiwrupqoirupqoirupqoiurpqiorupwqiourpqurpqurpqurpqurpqurpqurüqurqpuriq", ) + +i1 = ( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", +) # This should break ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap index 8a78898651..ea1754c33d 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__fmt_off_docstring.py.snap @@ -28,9 +28,9 @@ def test(): ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -60,9 +60,9 @@ def test(): ### Output 2 ``` -indent-style = Spaces, size: 2 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 2 quote-style = Double magic-trailing-comma = Respect ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap index d373b18048..5330ab331e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__indent.py.snap @@ -4,271 +4,45 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off --- ## Input ```py -def test(): - # fmt: off - a_very_small_indent - ( -not_fixed - ) - - if True: - pass - more - # fmt: on - - formatted - - def test(): - a_small_indent - # fmt: off -# fix under-indented comments - (or_the_inner_expression + -expressions - ) - - if True: - pass - # fmt: on - - -# fmt: off -def test(): - pass - - # It is necessary to indent comments because the following fmt: on comment because it otherwise becomes a trailing comment - # of the `test` function if the "proper" indentation is larger than 2 spaces. - # fmt: on - -disabled + formatting; - -# fmt: on - -formatted; - -def test(): - pass - # fmt: off - """A multiline strings - that should not get formatted""" - - "A single quoted multiline \ - string" - - disabled + formatting; - -# fmt: on - -formatted; ``` ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` ```py -def test(): - # fmt: off - a_very_small_indent - ( -not_fixed - ) - - if True: - pass - more - # fmt: on - - formatted - - def test(): - a_small_indent - # fmt: off - # fix under-indented comments - (or_the_inner_expression + -expressions - ) - - if True: - pass - # fmt: on - - -# fmt: off -def test(): - pass - - # It is necessary to indent comments because the following fmt: on comment because it otherwise becomes a trailing comment - # of the `test` function if the "proper" indentation is larger than 2 spaces. - # fmt: on - -disabled + formatting; - -# fmt: on - -formatted - - -def test(): - pass - # fmt: off - """A multiline strings - that should not get formatted""" - - "A single quoted multiline \ - string" - - disabled + formatting - - -# fmt: on - -formatted ``` ### Output 2 ``` -indent-style = Spaces, size: 1 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 1 quote-style = Double magic-trailing-comma = Respect ``` ```py -def test(): - # fmt: off - a_very_small_indent - ( -not_fixed - ) - - if True: - pass - more - # fmt: on - - formatted - - def test(): - a_small_indent - # fmt: off - # fix under-indented comments - (or_the_inner_expression + -expressions - ) - - if True: - pass - # fmt: on - - -# fmt: off -def test(): - pass - - # It is necessary to indent comments because the following fmt: on comment because it otherwise becomes a trailing comment - # of the `test` function if the "proper" indentation is larger than 2 spaces. - # fmt: on - -disabled + formatting; - -# fmt: on - -formatted - - -def test(): - pass - # fmt: off - """A multiline strings - that should not get formatted""" - - "A single quoted multiline \ - string" - - disabled + formatting - - -# fmt: on - -formatted ``` ### Output 3 ``` -indent-style = Tab +indent-style = tab line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` ```py -def test(): - # fmt: off - a_very_small_indent - ( -not_fixed - ) - - if True: - pass - more - # fmt: on - - formatted - - def test(): - a_small_indent - # fmt: off - # fix under-indented comments - (or_the_inner_expression + -expressions - ) - - if True: - pass - # fmt: on - - -# fmt: off -def test(): - pass - - # It is necessary to indent comments because the following fmt: on comment because it otherwise becomes a trailing comment - # of the `test` function if the "proper" indentation is larger than 2 spaces. - # fmt: on - -disabled + formatting; - -# fmt: on - -formatted - - -def test(): - pass - # fmt: off - """A multiline strings - that should not get formatted""" - - "A single quoted multiline \ - string" - - disabled + formatting - - -# fmt: on - -formatted ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap index 8bc61fd6cb..a8911f2fe6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__mixed_space_and_tab.py.snap @@ -24,9 +24,9 @@ not_fixed ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -45,15 +45,17 @@ not_fixed more else: other + + # fmt: on ``` ### Output 2 ``` -indent-style = Spaces, size: 2 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 2 quote-style = Double magic-trailing-comma = Respect ``` @@ -72,15 +74,17 @@ not_fixed more else: other + + # fmt: on ``` ### Output 3 ``` -indent-style = Tab +indent-style = tab line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -99,6 +103,8 @@ not_fixed more else: other + + # fmt: on ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap new file mode 100644 index 0000000000..d7041c2e79 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__newlines.py.snap @@ -0,0 +1,90 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py +--- +## Input +```py +def func(): + pass +# fmt: off +x = 1 +# fmt: on + + +# fmt: off +def func(): + pass +# fmt: on +x = 1 + + +# fmt: off +def func(): + pass +# fmt: on +def func(): + pass + + +# fmt: off +def func(): + pass +# fmt: off +def func(): + pass + + +# fmt: on +def func(): + pass +# fmt: on +def func(): + pass +``` + +## Output +```py +def func(): + pass + + +# fmt: off +x = 1 +# fmt: on + + +# fmt: off +def func(): + pass +# fmt: on +x = 1 + + +# fmt: off +def func(): + pass +# fmt: on +def func(): + pass + + +# fmt: off +def func(): + pass +# fmt: off +def func(): + pass + + +# fmt: on +def func(): + pass + + +# fmt: on +def func(): + pass +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap new file mode 100644 index 0000000000..eb28317e4a --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment1.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment1.py +--- +## Input +```py +__all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] + +# Shared types throughout the stub +``` + +## Output +```py +__all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] + +# Shared types throughout the stub +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap new file mode 100644 index 0000000000..c419b524ca --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@module_dangling_comment2.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/module_dangling_comment2.py +--- +## Input +```py +__all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] +# Shared types throughout the stub +``` + +## Output +```py +__all__ = ["X", "XK", "Xatom", "Xcursorfont", "Xutil", "display", "error", "rdb"] +# Shared types throughout the stub +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap new file mode 100644 index 0000000000..654d55dbb9 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@newlines.py.snap @@ -0,0 +1,345 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.py +--- +## Input +```py +### +# Blank lines around functions +### + +x = 1 + +# comment + +def f(): + pass + + +if True: + x = 1 + +# comment + +def f(): + pass + + +x = 1 + + + +# comment + +def f(): + pass + + +x = 1 + + + +# comment +def f(): + pass + + +x = 1 + +# comment + +# comment +def f(): + pass + +x = 1 + +# comment +# comment + +def f(): + pass + +x = 1 + +# comment +# comment +def f(): + pass + + +x = 1 + + +# comment + + + +# comment + + + +def f(): + pass +# comment + + +def f(): + pass + +# comment + +def f(): + pass + + +# comment + +### +# Blank lines around imports. +### + +def f(): + import x + # comment + import y + + +def f(): + import x + + # comment + import y + + +def f(): + import x + # comment + + import y + + +def f(): + import x + # comment + + + import y + + +def f(): + import x + + + # comment + import y + + +def f(): + import x + + # comment + + import y + + +def f(): + import x # comment + # comment + + import y + + +def f(): pass # comment +# comment + +x = 1 + + +def f(): + pass + + + + +# comment + +x = 1 +``` + +## Output +```py +### +# Blank lines around functions +### + +x = 1 + +# comment + + +def f(): + pass + + +if True: + x = 1 + +# comment + + +def f(): + pass + + +x = 1 + + +# comment + + +def f(): + pass + + +x = 1 + + +# comment +def f(): + pass + + +x = 1 + +# comment + + +# comment +def f(): + pass + + +x = 1 + +# comment +# comment + + +def f(): + pass + + +x = 1 + + +# comment +# comment +def f(): + pass + + +x = 1 + + +# comment + + +# comment + + +def f(): + pass + + +# comment + + +def f(): + pass + + +# comment + + +def f(): + pass + + +# comment + +### +# Blank lines around imports. +### + + +def f(): + import x + + # comment + import y + + +def f(): + import x + + # comment + import y + + +def f(): + import x + # comment + + import y + + +def f(): + import x + # comment + + import y + + +def f(): + import x + + # comment + import y + + +def f(): + import x + + # comment + + import y + + +def f(): + import x # comment + # comment + + import y + + +def f(): + pass # comment + + +# comment + +x = 1 + + +def f(): + pass + + +# comment + +x = 1 +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap index 8c8c952a79..e448447ba1 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__call_chains.py.snap @@ -167,6 +167,61 @@ max_message_id = ( max_message_id = ( Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id() ) + +# Parentheses with fluent style within and outside of the parentheses. +( + ( + df1_aaaaaaaaaaaa.merge() + ) + .groupby(1,) + .sum() +) + +( + ( # foo + df1_aaaaaaaaaaaa.merge() + ) + .groupby(1,) + .sum() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + ) + .sum() +) + + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + ) + .sum() + .bar() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + .bar() + ) + .sum() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby(1,) + .bar() + ) + .sum() + .baz() +) + ``` ## Output @@ -268,7 +323,9 @@ d13 = ( ) # Doesn't fit, default -d2 = x.e().esadjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkfsdddd() # +d2 = ( + x.e().esadjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkfsdddd() # +) # Doesn't fit, fluent style d3 = ( @@ -348,6 +405,66 @@ max_message_id = ( max_message_id = ( Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id() ) + +# Parentheses with fluent style within and outside of the parentheses. +( + (df1_aaaaaaaaaaaa.merge()) + .groupby( + 1, + ) + .sum() +) + +( + ( # foo + df1_aaaaaaaaaaaa.merge() + ) + .groupby( + 1, + ) + .sum() +) + +( + ( + df1_aaaaaaaaaaaa.merge().groupby( + 1, + ) + ).sum() +) + + +( + ( + df1_aaaaaaaaaaaa.merge().groupby( + 1, + ) + ) + .sum() + .bar() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby( + 1, + ) + .bar() + ).sum() +) + +( + ( + df1_aaaaaaaaaaaa.merge() + .groupby( + 1, + ) + .bar() + ) + .sum() + .baz() +) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap index 2106ed7f65..b9052fb1ac 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@parentheses__nested.py.snap @@ -90,8 +90,7 @@ a = ( + b + c + d - + - ( # Hello + + ( # Hello e + f + g ) ) diff --git a/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap index 08d17e970d..d592ecdca8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@skip_magic_trailing_comma.py.snap @@ -42,9 +42,9 @@ with (a,): # magic trailing comma ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -94,9 +94,9 @@ with ( ### Output 2 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Ignore ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap index 2db923a1df..534b604e8a 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__assert.py.snap @@ -191,10 +191,9 @@ assert ( # Trailing test value own-line # Test dangler ), "Some string" # Trailing msg same-line - - # Trailing assert + def test(): assert ( { diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap index 185579f079..9258c1ca71 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__class_definition.py.snap @@ -212,6 +212,22 @@ class TestTypeParams[Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa class TestTypeParams[A, B, C](meta=Aaaaaaaaaaaaaaaaaaaaaa): pass + + +# Regression test for: https://github.com/astral-sh/ruff/pull/7001 +class QuerySet(AltersData): + """Represent a lazy database lookup for a set of objects.""" + + def as_manager(cls): + # Address the circular dependency between `Queryset` and `Manager`. + from django.db.models.manager import Manager + + manager = Manager.from_queryset(cls)() + manager._built_with_as_manager = True + return manager + + as_manager.queryset_only = True + as_manager = classmethod(as_manager) ``` ## Output @@ -459,6 +475,22 @@ class TestTypeParams[ class TestTypeParams[A, B, C](meta=Aaaaaaaaaaaaaaaaaaaaaa): pass + + +# Regression test for: https://github.com/astral-sh/ruff/pull/7001 +class QuerySet(AltersData): + """Represent a lazy database lookup for a set of objects.""" + + def as_manager(cls): + # Address the circular dependency between `Queryset` and `Manager`. + from django.db.models.manager import Manager + + manager = Manager.from_queryset(cls)() + manager._built_with_as_manager = True + return manager + + as_manager.queryset_only = True + as_manager = classmethod(as_manager) ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap index ce4add0b94..2afea0bb26 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__delete.py.snap @@ -204,7 +204,13 @@ del ( # NOTE: This shouldn't format. See https://github.com/astral-sh/ruff/issues/5630. # Delete something -del x, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, b, c, d # Delete these +del ( + x, + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + b, + c, + d, +) # Delete these # Ready to delete # Delete something diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap index d801c863eb..d5ebcab226 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__function.py.snap @@ -406,6 +406,7 @@ def test( ### Different function argument wrappings + def single_line(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbb, ccccccccccccccccc): pass @@ -511,6 +512,7 @@ def type_param_comments[ # trailing bracket comment # Different type parameter wrappings + def single_line[Aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, Bbbbbbbbbbbbbbb, Ccccccccccccccccc](): pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap index 8a23c2f6d7..2ca2c18fa8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap @@ -985,18 +985,18 @@ match pattern_match_class: ... case A( - b=# b + # b # c - 2 # d + b=2 # d # e ): pass case A( # a - b=# b + # b # c - 2 # d + b=2 # d # e ): pass diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap index 589d8a25e7..e4fe04e434 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap @@ -324,7 +324,9 @@ finally: try: # 1 preceding: any, following: first in body, enclosing: try print(1) # 2 preceding: last in body, following: fist in alt body, enclosing: try -except ZeroDivisionError: # 3 preceding: test, following: fist in alt body, enclosing: try +except ( + ZeroDivisionError +): # 3 preceding: test, following: fist in alt body, enclosing: try print(2) # 4 preceding: last in body, following: fist in alt body, enclosing: exc except: # 5 preceding: last in body, following: fist in alt body, enclosing: try print(2) # 6 preceding: last in body, following: fist in alt body, enclosing: exc diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap index fdc99df9a6..9b09af15db 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__while.py.snap @@ -57,7 +57,9 @@ while aVeryLongConditionThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGo else: ... -while some_condition(unformatted, args) and anotherCondition or aThirdCondition: # comment +while ( + some_condition(unformatted, args) and anotherCondition or aThirdCondition +): # comment print("Do something") diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap new file mode 100644 index 0000000000..beb8e4a11e --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__comments.pyi.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/comments.pyi +--- +## Input +```py +class SupportsAnext: + def __anext__(self): ... + +# Comparison protocols + +class SupportsDunderLT: + def __init__(self): ... +``` + +## Output +```py +class SupportsAnext: + def __anext__(self): ... + +# Comparison protocols + +class SupportsDunderLT: + def __init__(self): ... +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap new file mode 100644 index 0000000000..ba86351d1a --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__nesting.pyi.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/nesting.pyi +--- +## Input +```py +"""Tests specifically for https://github.com/psf/black/issues/3861""" + +import sys + + +class OuterClassOrOtherSuite: + class Nested11: + class Nested12: + assignment = 1 + def function_definition(self): ... + + def f1(self) -> str: ... + + class Nested21: + class Nested22: + def function_definition(self): ... + assignment = 1 + + def f2(self) -> str: ... + +if sys.version_info > (3, 7): + if sys.platform == "win32": + assignment = 1 + def function_definition(self): ... + + def f1(self) -> str: ... + if sys.platform != "win32": + def function_definition(self): ... + assignment = 1 + + def f2(self) -> str: ... +``` + +## Output +```py +"""Tests specifically for https://github.com/psf/black/issues/3861""" + +import sys + +class OuterClassOrOtherSuite: + class Nested11: + class Nested12: + assignment = 1 + def function_definition(self): ... + + def f1(self) -> str: ... + + class Nested21: + class Nested22: + def function_definition(self): ... + assignment = 1 + + def f2(self) -> str: ... + +if sys.version_info > (3, 7): + if sys.platform == "win32": + assignment = 1 + def function_definition(self): ... + + def f1(self) -> str: ... + if sys.platform != "win32": + def function_definition(self): ... + assignment = 1 + + def f2(self) -> str: ... +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap new file mode 100644 index 0000000000..cf4b0523c0 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__suite.pyi.snap @@ -0,0 +1,312 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/suite.pyi +--- +## Input +```py +"""Tests for empty line rules in stub files, mostly inspired by typeshed. +The rules are a list of nested exceptions. See also +https://github.com/psf/black/blob/c160e4b7ce30c661ac4f2dfa5038becf1b8c5c33/src/black/lines.py#L576-L744 +""" + +import sys +from typing import Self, TypeAlias, final + +if sys.version_info >= (3, 8): + class InnerClass1: ... + + class InnerClass2: + def a(self): ... + + class InnerClass3: + def a(self): ... + + class InnerClass4: ... + details: int + def f1(self, hresult: int, text: str | None, detail: int) -> None: ... + details: int + def f2(self, hresult: int, text: str | None, detail: int) -> None: ... + @final + class DecoratorInsteadOfEmptyLine: ... + + def open(device: str) -> None: ... + + # oss_mixer_device return type + def openmixer(device: str = ...) -> None: ... + def open2(device: str) -> None: ... + # oss_mixer_device2 return type + def openmixer2(device: str = ...) -> None: ... + +else: + class Slice1: ... + _Slice1: TypeAlias = Slice1 + + class Slice2: ... + _Slice2: TypeAlias = Slice2 + +class NoEmptyLinesBetweenFunctions: + def multi_line_but_only_ellipsis( + self, + mandatory_release: float | None, + ) -> None: ... + def only_ellipsis1(self) -> float: ... + def only_ellipsis2(self) -> float | None: ... + def has_impl1(self): + print(self) + return 1 + + def has_impl2(self): + print(self) + return 2 + + def no_impl4(self): ... + +class NoEmptyLinesBetweenField: + field1: int + field2: ( + # type + int + ) + field3 = 3 + field4 = ( + 1, + 2, + ) + field5 = 5 + +class FieldAndFunctionsWithOptionalEmptyLines: + details1: int + def f1(self, hresult: int, text: str | None, detail: int) -> None: ... + details2: int + def f2(self, hresult: int, text: str | None, detail: int) -> None: ... + details3: int + +class NewlinesBetweenStubInnerClasses: + def f1(self): ... + + class InnerClass1: ... + class InnerClass2: ... + + def f2(self): ... + + class InnerClass3: ... + class InnerClass4: ... + field = 1 + + class InnerClass3: ... + class InnerClass4: ... + + def f3(self): ... + @final + class DecoratorInsteadOfEmptyLine: ... + + @final + class DecoratorStillEmptyLine: ... + +class NewlinesBetweenInnerClasses: + class InnerClass1: ... + + class InnerClass2: + def a(self): ... + + class InnerClass3: + def a(self): ... + + class InnerClass4: ... + + class InnerClass5: + def a(self): ... + field1 = 1 + + class InnerClass6: + def a(self): ... + + def f1(self): ... + + class InnerClass7: + def a(self): ... + print("hi") + + class InnerClass8: + def a(self): ... + +class ComplexStatements: + # didn't match the name in the C implementation, + # meaning it is only *safe* to pass it as a keyword argument on 3.12+ + if sys.version_info >= (3, 12): + @classmethod + def fromtimestamp(cls, timestamp: float, tz: float | None = ...) -> Self: ... + else: + @classmethod + def fromtimestamp(cls, __timestamp: float, tz: float | None = ...) -> Self: ... + + @classmethod + def utcfromtimestamp(cls, __t: float) -> Self: ... + if sys.version_info >= (3, 8): + @classmethod + def now(cls, tz: float | None = None) -> Self: ... + else: + @classmethod + def now(cls, tz: None = None) -> Self: ... + @classmethod + def now2(cls, tz: float) -> Self: ... + + @classmethod + def utcnow(cls) -> Self: ... +``` + +## Output +```py +"""Tests for empty line rules in stub files, mostly inspired by typeshed. +The rules are a list of nested exceptions. See also +https://github.com/psf/black/blob/c160e4b7ce30c661ac4f2dfa5038becf1b8c5c33/src/black/lines.py#L576-L744 +""" + +import sys +from typing import Self, TypeAlias, final + +if sys.version_info >= (3, 8): + class InnerClass1: ... + + class InnerClass2: + def a(self): ... + + class InnerClass3: + def a(self): ... + + class InnerClass4: ... + details: int + def f1(self, hresult: int, text: str | None, detail: int) -> None: ... + details: int + def f2(self, hresult: int, text: str | None, detail: int) -> None: ... + @final + class DecoratorInsteadOfEmptyLine: ... + + def open(device: str) -> None: ... + + # oss_mixer_device return type + def openmixer(device: str = ...) -> None: ... + def open2(device: str) -> None: ... + # oss_mixer_device2 return type + def openmixer2(device: str = ...) -> None: ... + +else: + class Slice1: ... + _Slice1: TypeAlias = Slice1 + + class Slice2: ... + _Slice2: TypeAlias = Slice2 + +class NoEmptyLinesBetweenFunctions: + def multi_line_but_only_ellipsis( + self, + mandatory_release: float | None, + ) -> None: ... + def only_ellipsis1(self) -> float: ... + def only_ellipsis2(self) -> float | None: ... + def has_impl1(self): + print(self) + return 1 + + def has_impl2(self): + print(self) + return 2 + + def no_impl4(self): ... + +class NoEmptyLinesBetweenField: + field1: int + field2: ( + # type + int + ) + field3 = 3 + field4 = ( + 1, + 2, + ) + field5 = 5 + +class FieldAndFunctionsWithOptionalEmptyLines: + details1: int + def f1(self, hresult: int, text: str | None, detail: int) -> None: ... + details2: int + def f2(self, hresult: int, text: str | None, detail: int) -> None: ... + details3: int + +class NewlinesBetweenStubInnerClasses: + def f1(self): ... + + class InnerClass1: ... + class InnerClass2: ... + + def f2(self): ... + + class InnerClass3: ... + class InnerClass4: ... + field = 1 + + class InnerClass3: ... + class InnerClass4: ... + + def f3(self): ... + @final + class DecoratorInsteadOfEmptyLine: ... + + @final + class DecoratorStillEmptyLine: ... + +class NewlinesBetweenInnerClasses: + class InnerClass1: ... + + class InnerClass2: + def a(self): ... + + class InnerClass3: + def a(self): ... + + class InnerClass4: ... + + class InnerClass5: + def a(self): ... + field1 = 1 + + class InnerClass6: + def a(self): ... + + def f1(self): ... + + class InnerClass7: + def a(self): ... + print("hi") + + class InnerClass8: + def a(self): ... + +class ComplexStatements: + # didn't match the name in the C implementation, + # meaning it is only *safe* to pass it as a keyword argument on 3.12+ + if sys.version_info >= (3, 12): + @classmethod + def fromtimestamp(cls, timestamp: float, tz: float | None = ...) -> Self: ... + else: + @classmethod + def fromtimestamp(cls, __timestamp: float, tz: float | None = ...) -> Self: ... + + @classmethod + def utcfromtimestamp(cls, __t: float) -> Self: ... + if sys.version_info >= (3, 8): + @classmethod + def now(cls, tz: float | None = None) -> Self: ... + else: + @classmethod + def now(cls, tz: None = None) -> Self: ... + @classmethod + def now2(cls, tz: float) -> Self: ... + + @classmethod + def utcnow(cls) -> Self: ... +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap new file mode 100644 index 0000000000..99c29acbdd --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@stub_files__top_level.pyi.snap @@ -0,0 +1,47 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/stub_files/top_level.pyi +--- +## Input +```py +from typing import final + + +def count1(): ... +def count2(): ... +@final +def count3(): ... +@final +class LockType1: ... + +def count4(): ... + +class LockType2: ... +class LockType3: ... + +@final +class LockType4: ... +``` + +## Output +```py +from typing import final + +def count1(): ... +def count2(): ... +@final +def count3(): ... +@final +class LockType1: ... + +def count4(): ... + +class LockType2: ... +class LockType3: ... + +@final +class LockType4: ... +``` + + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap index 6e46ff92f0..e9fad4dfc2 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@tab_width.py.snap @@ -5,45 +5,42 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width. ## Input ```py # Fits with tab width 2 -1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567890" +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567") # Fits with tab width 4 -1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345678" +(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345") # Fits with tab width 8 -1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234" +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901") ``` ## Outputs ### Output 1 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 2 +indent-width = 2 quote-style = Double magic-trailing-comma = Respect ``` ```py # Fits with tab width 2 -( - 1 - + " 012345678901234567890123456789012345678901234567890123456789012345678901234567890" -) +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567") # Fits with tab width 4 -1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345678" +(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345") # Fits with tab width 8 -1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234" +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901") ``` ### Output 2 ``` -indent-style = Spaces, size: 4 +indent-style = space line-width = 88 -tab-width = 4 +indent-width = 4 quote-style = Double magic-trailing-comma = Respect ``` @@ -52,17 +49,41 @@ magic-trailing-comma = Respect # Fits with tab width 2 ( 1 - + " 012345678901234567890123456789012345678901234567890123456789012345678901234567890" + + " 012345678901234567890123456789012345678901234567890123456789012345678901234567" +) + +# Fits with tab width 4 +(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345") + +# Fits with tab width 8 +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901") +``` + + +### Output 3 +``` +indent-style = space +line-width = 88 +indent-width = 8 +quote-style = Double +magic-trailing-comma = Respect +``` + +```py +# Fits with tab width 2 +( + 1 + + " 012345678901234567890123456789012345678901234567890123456789012345678901234567" ) # Fits with tab width 4 ( - 1 - + " 0123456789012345678901234567890123456789012345678901234567890123456789012345678" + 1 + + " 0123456789012345678901234567890123456789012345678901234567890123456789012345" ) # Fits with tab width 8 -1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234" +(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901") ``` diff --git a/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap new file mode 100644 index 0000000000..7e6a4bdc16 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@trailing_comments.py.snap @@ -0,0 +1,76 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/trailing_comments.py +--- +## Input +```py +# Pragma reserved width fixtures +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # type: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pyright: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pylint: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # nocoverage: This should break + + +# Pragma fixtures for non-breaking space (lead by NBSP) +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # type: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pyright: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pylint: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # nocoverage: This should break + + +# As of adding this fixture Black adds a space before the non-breaking space if part of a type pragma. +# https://github.com/psf/black/blob/b4dca26c7d93f930bbd5a7b552807370b60d4298/src/black/comments.py#L122-L129 +i = "" #  type: Add space before leading NBSP followed by spaces +i = "" #type: A space is added +i = "" #  type: Add space before leading NBSP followed by a space +i = "" # type: Add space before leading NBSP +i = "" #  type: Add space before two leading NBSP + + +# A noqa as `#\u{A0}\u{A0}noqa` becomes `# \u{A0}noqa` +i = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" #  noqa +``` + +## Output +```py +# Pragma reserved width fixtures +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # type: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pyright: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pylint: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa This shouldn't break +i = ( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", +) # nocoverage: This should break + + +# Pragma fixtures for non-breaking space (lead by NBSP) +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) #  type: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pyright: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # pylint: This shouldn't break +i = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",) # noqa This shouldn't break +i = ( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", +) # nocoverage: This should break + + +# As of adding this fixture Black adds a space before the non-breaking space if part of a type pragma. +# https://github.com/psf/black/blob/b4dca26c7d93f930bbd5a7b552807370b60d4298/src/black/comments.py#L122-L129 +i = "" #   type: Add space before leading NBSP followed by spaces +i = "" # type: A space is added +i = "" #   type: Add space before leading NBSP followed by a space +i = "" #  type: Add space before leading NBSP +i = "" #   type: Add space before two leading NBSP + + +# A noqa as `#\u{A0}\u{A0}noqa` becomes `# \u{A0}noqa` +i = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" #  noqa +``` + + + diff --git a/crates/ruff_python_parser/Cargo.toml b/crates/ruff_python_parser/Cargo.toml index 02b27577b2..a4bb8f6c50 100644 --- a/crates/ruff_python_parser/Cargo.toml +++ b/crates/ruff_python_parser/Cargo.toml @@ -23,15 +23,13 @@ itertools = { workspace = true } lalrpop-util = { version = "0.20.0", default-features = false } num-bigint = { workspace = true } num-traits = { workspace = true } -unic-emoji-char = "0.9.0" -unic-ucd-ident = "0.9.0" +unicode-ident = { workspace = true } unicode_names2 = { version = "0.6.0", git = "https://github.com/youknowone/unicode_names2.git", rev = "4ce16aa85cbcdd9cc830410f1a72ef9a235f2fde" } rustc-hash = { workspace = true } static_assertions = "1.1.0" [dev-dependencies] insta = { workspace = true } -test-case = { workspace = true } [build-dependencies] anyhow = { workspace = true } diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 1691fc6c49..fca0ba5b90 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -28,7 +28,6 @@ //! //! [Lexical analysis]: https://docs.python.org/3/reference/lexical_analysis.html -use std::borrow::Cow; use std::iter::FusedIterator; use std::{char, cmp::Ordering, str::FromStr}; @@ -36,8 +35,7 @@ use num_bigint::BigInt; use num_traits::{Num, Zero}; use ruff_python_ast::IpyEscapeKind; use ruff_text_size::{TextLen, TextRange, TextSize}; -use unic_emoji_char::is_emoji_presentation; -use unic_ucd_ident::{is_xid_continue, is_xid_start}; +use unicode_ident::{is_xid_continue, is_xid_start}; use crate::lexer::cursor::{Cursor, EOF_CHAR}; use crate::lexer::indentation::{Indentation, Indentations}; @@ -264,9 +262,10 @@ impl<'source> Lexer<'source> { 'x' | 'o' | 'b' )); - let value_text = self.radix_run(None, radix); + let mut number = LexedText::new(self.offset(), self.source); + self.radix_run(&mut number, radix); let value = - BigInt::from_str_radix(&value_text, radix.as_u32()).map_err(|e| LexicalError { + BigInt::from_str_radix(number.as_str(), radix.as_u32()).map_err(|e| LexicalError { error: LexicalErrorType::OtherError(format!("{e:?}")), location: self.token_range().start(), })?; @@ -279,15 +278,14 @@ impl<'source> Lexer<'source> { debug_assert!(self.cursor.previous().is_ascii_digit() || self.cursor.previous() == '.'); let start_is_zero = first_digit_or_dot == '0'; - let mut value_text = if first_digit_or_dot == '.' { - String::new() - } else { - self.radix_run(Some(first_digit_or_dot), Radix::Decimal) - .into_owned() + let mut number = LexedText::new(self.token_start(), self.source); + if first_digit_or_dot != '.' { + number.push(first_digit_or_dot); + self.radix_run(&mut number, Radix::Decimal); }; let is_float = if first_digit_or_dot == '.' || self.cursor.eat_char('.') { - value_text.push('.'); + number.push('.'); if self.cursor.eat_char('_') { return Err(LexicalError { @@ -296,7 +294,7 @@ impl<'source> Lexer<'source> { }); } - value_text.push_str(&self.radix_run(None, Radix::Decimal)); + self.radix_run(&mut number, Radix::Decimal); true } else { // Normal number: @@ -305,14 +303,14 @@ impl<'source> Lexer<'source> { let is_float = match self.cursor.rest().as_bytes() { [b'e' | b'E', b'0'..=b'9', ..] | [b'e' | b'E', b'-' | b'+', b'0'..=b'9', ..] => { - value_text.push('e'); - self.cursor.bump(); // e | E + // 'e' | 'E' + number.push(self.cursor.bump().unwrap()); if let Some(sign) = self.cursor.eat_if(|c| matches!(c, '+' | '-')) { - value_text.push(sign); + number.push(sign); } - value_text.push_str(&self.radix_run(None, Radix::Decimal)); + self.radix_run(&mut number, Radix::Decimal); true } @@ -321,7 +319,7 @@ impl<'source> Lexer<'source> { if is_float { // Improvement: Use `Cow` instead of pushing to value text - let value = f64::from_str(&value_text).map_err(|_| LexicalError { + let value = f64::from_str(number.as_str()).map_err(|_| LexicalError { error: LexicalErrorType::OtherError("Invalid decimal literal".to_owned()), location: self.token_start(), })?; @@ -338,10 +336,10 @@ impl<'source> Lexer<'source> { } else { // Parse trailing 'j': if self.cursor.eat_if(|c| matches!(c, 'j' | 'J')).is_some() { - let imag = f64::from_str(&value_text).unwrap(); + let imag = f64::from_str(number.as_str()).unwrap(); Ok(Tok::Complex { real: 0.0, imag }) } else { - let value = value_text.parse::().unwrap(); + let value = number.as_str().parse::().unwrap(); if start_is_zero && !value.is_zero() { // leading zeros in decimal integer literals are not permitted return Err(LexicalError { @@ -357,34 +355,19 @@ impl<'source> Lexer<'source> { /// Consume a sequence of numbers with the given radix, /// the digits can be decorated with underscores /// like this: '`1_2_3_4`' == '1234' - fn radix_run(&mut self, first: Option, radix: Radix) -> Cow<'source, str> { - let start = if let Some(first) = first { - self.offset() - first.text_len() - } else { - self.offset() - }; - self.cursor.eat_while(|c| radix.is_digit(c)); - - let number = &self.source[TextRange::new(start, self.offset())]; - - // Number that contains `_` separators. Remove them from the parsed text. - if radix.is_digit(self.cursor.second()) && self.cursor.eat_char('_') { - let mut value_text = number.to_string(); - - loop { - if let Some(c) = self.cursor.eat_if(|c| radix.is_digit(c)) { - value_text.push(c); - } else if self.cursor.first() == '_' && radix.is_digit(self.cursor.second()) { - // Skip over `_` - self.cursor.bump(); - } else { - break; - } + fn radix_run(&mut self, number: &mut LexedText, radix: Radix) { + loop { + if let Some(c) = self.cursor.eat_if(|c| radix.is_digit(c)) { + number.push(c); + } + // Number that contains `_` separators. Remove them from the parsed text. + else if self.cursor.first() == '_' && radix.is_digit(self.cursor.second()) { + // Skip over `_` + self.cursor.bump(); + number.skip_char(); + } else { + break; } - - Cow::Owned(value_text) - } else { - Cow::Borrowed(number) } } @@ -580,6 +563,73 @@ impl<'source> Lexer<'source> { } } + if self.state.is_after_newline() { + if let Some(indentation) = self.eat_indentation()? { + return Ok(indentation); + } + } else { + self.skip_whitespace()?; + } + + self.cursor.start_token(); + if let Some(c) = self.cursor.bump() { + if c.is_ascii() { + self.consume_ascii_character(c) + } else if is_unicode_identifier_start(c) { + let identifier = self.lex_identifier(c)?; + self.state = State::Other; + + Ok((identifier, self.token_range())) + } else { + Err(LexicalError { + error: LexicalErrorType::UnrecognizedToken { tok: c }, + location: self.token_start(), + }) + } + } else { + // Reached the end of the file. Emit a trailing newline token if not at the beginning of a logical line, + // empty the dedent stack, and finally, return the EndOfFile token. + self.consume_end() + } + } + + fn skip_whitespace(&mut self) -> Result<(), LexicalError> { + loop { + match self.cursor.first() { + ' ' => { + self.cursor.bump(); + } + '\t' => { + self.cursor.bump(); + } + '\\' => { + self.cursor.bump(); + if self.cursor.eat_char('\r') { + self.cursor.eat_char('\n'); + } else if self.cursor.is_eof() { + return Err(LexicalError { + error: LexicalErrorType::Eof, + location: self.token_start(), + }); + } else if !self.cursor.eat_char('\n') { + return Err(LexicalError { + error: LexicalErrorType::LineContinuationError, + location: self.token_start(), + }); + } + } + // Form feed + '\x0C' => { + self.cursor.bump(); + } + _ => break, + } + } + + Ok(()) + } + + fn eat_indentation(&mut self) -> Result, LexicalError> { let mut indentation = Indentation::root(); self.cursor.start_token(); @@ -619,48 +669,18 @@ impl<'source> Lexer<'source> { } } - if self.state.is_after_newline() { - // Handle indentation if this is a new, not all empty, logical line - if !matches!(self.cursor.first(), '\n' | '\r' | '#' | EOF_CHAR) { - self.state = State::NonEmptyLogicalLine; + // Handle indentation if this is a new, not all empty, logical line + if !matches!(self.cursor.first(), '\n' | '\r' | '#' | EOF_CHAR) { + self.state = State::NonEmptyLogicalLine; - if let Some(spanned) = self.handle_indentation(indentation)? { - // Set to false so that we don't handle indentation on the next call. + if let Some(spanned) = self.handle_indentation(indentation)? { + // Set to false so that we don't handle indentation on the next call. - return Ok(spanned); - } + return Ok(Some(spanned)); } } - self.cursor.start_token(); - if let Some(c) = self.cursor.bump() { - if c.is_ascii() { - self.consume_ascii_character(c) - } else if is_unicode_identifier_start(c) { - let identifier = self.lex_identifier(c)?; - self.state = State::Other; - - Ok((identifier, self.token_range())) - } else if is_emoji_presentation(c) { - self.state = State::Other; - - Ok(( - Tok::Name { - name: c.to_string(), - }, - self.token_range(), - )) - } else { - Err(LexicalError { - error: LexicalErrorType::UnrecognizedToken { tok: c }, - location: self.token_start(), - }) - } - } else { - // Reached the end of the file. Emit a trailing newline token if not at the beginning of a logical line, - // empty the dedent stack, and finally, return the EndOfFile token. - self.consume_end() - } + Ok(None) } fn handle_indentation( @@ -756,7 +776,7 @@ impl<'source> Lexer<'source> { } c @ ('%' | '!') - if self.mode == Mode::Jupyter + if self.mode == Mode::Ipython && self.state.is_after_equal() && self.nesting == 0 => { @@ -765,7 +785,7 @@ impl<'source> Lexer<'source> { } c @ ('%' | '!' | '?' | '/' | ';' | ',') - if self.mode == Mode::Jupyter && self.state.is_new_logical_line() => + if self.mode == Mode::Ipython && self.state.is_new_logical_line() => { let kind = if let Ok(kind) = IpyEscapeKind::try_from([c, self.cursor.first()]) { self.cursor.bump(); @@ -778,7 +798,7 @@ impl<'source> Lexer<'source> { self.lex_ipython_escape_command(kind) } - '?' if self.mode == Mode::Jupyter => Tok::Question, + '?' if self.mode == Mode::Ipython => Tok::Question, '/' => { if self.cursor.eat_char('=') { @@ -1200,13 +1220,52 @@ const fn is_python_whitespace(c: char) -> bool { ) } +enum LexedText<'a> { + Source { source: &'a str, range: TextRange }, + Owned(String), +} + +impl<'a> LexedText<'a> { + fn new(start: TextSize, source: &'a str) -> Self { + Self::Source { + range: TextRange::empty(start), + source, + } + } + + fn push(&mut self, c: char) { + match self { + LexedText::Source { range, source } => { + *range = range.add_end(c.text_len()); + debug_assert!(source[*range].ends_with(c)); + } + LexedText::Owned(owned) => owned.push(c), + } + } + + fn as_str<'b>(&'b self) -> &'b str + where + 'b: 'a, + { + match self { + LexedText::Source { range, source } => &source[*range], + LexedText::Owned(owned) => owned, + } + } + + fn skip_char(&mut self) { + match self { + LexedText::Source { range, source } => { + *self = LexedText::Owned(source[*range].to_string()); + } + LexedText::Owned(_) => {} + } + } +} + #[cfg(test)] mod tests { - use num_bigint::BigInt; - use ruff_python_ast::IpyEscapeKind; - use insta::assert_debug_snapshot; - use test_case::test_case; use super::*; @@ -1214,50 +1273,63 @@ mod tests { const MAC_EOL: &str = "\r"; const UNIX_EOL: &str = "\n"; - pub(crate) fn lex_source(source: &str) -> Vec { - let lexer = lex(source, Mode::Module); - lexer.map(|x| x.unwrap().0).collect() + fn lex_source_with_mode(source: &str, mode: Mode) -> Vec { + let lexer = lex(source, mode); + lexer.map(std::result::Result::unwrap).collect() } - pub(crate) fn lex_jupyter_source(source: &str) -> Vec { - let lexer = lex(source, Mode::Jupyter); - lexer.map(|x| x.unwrap().0).collect() + fn lex_source(source: &str) -> Vec { + lex_source_with_mode(source, Mode::Module) } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_ipython_escape_command_line_continuation_eol(eol: &str) { + fn lex_jupyter_source(source: &str) -> Vec { + lex_source_with_mode(source, Mode::Ipython) + } + + fn ipython_escape_command_line_continuation_eol(eol: &str) -> Vec { let source = format!("%matplotlib \\{eol} --inline"); - let tokens = lex_jupyter_source(&source); - assert_eq!( - tokens, - vec![ - Tok::IpyEscapeCommand { - value: "matplotlib --inline".to_string(), - kind: IpyEscapeKind::Magic - }, - Tok::Newline - ] - ); + lex_jupyter_source(&source) } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_ipython_escape_command_line_continuation_with_eol_and_eof(eol: &str) { + #[test] + fn test_ipython_escape_command_line_continuation_unix_eol() { + assert_debug_snapshot!(ipython_escape_command_line_continuation_eol(UNIX_EOL)); + } + + #[test] + fn test_ipython_escape_command_line_continuation_mac_eol() { + assert_debug_snapshot!(ipython_escape_command_line_continuation_eol(MAC_EOL)); + } + + #[test] + fn test_ipython_escape_command_line_continuation_windows_eol() { + assert_debug_snapshot!(ipython_escape_command_line_continuation_eol(WINDOWS_EOL)); + } + + fn ipython_escape_command_line_continuation_with_eol_and_eof(eol: &str) -> Vec { let source = format!("%matplotlib \\{eol}"); - let tokens = lex_jupyter_source(&source); - assert_eq!( - tokens, - vec![ - Tok::IpyEscapeCommand { - value: "matplotlib ".to_string(), - kind: IpyEscapeKind::Magic - }, - Tok::Newline - ] - ); + lex_jupyter_source(&source) + } + + #[test] + fn test_ipython_escape_command_line_continuation_with_unix_eol_and_eof() { + assert_debug_snapshot!(ipython_escape_command_line_continuation_with_eol_and_eof( + UNIX_EOL + )); + } + + #[test] + fn test_ipython_escape_command_line_continuation_with_mac_eol_and_eof() { + assert_debug_snapshot!(ipython_escape_command_line_continuation_with_eol_and_eof( + MAC_EOL + )); + } + + #[test] + fn test_ipython_escape_command_line_continuation_with_windows_eol_and_eof() { + assert_debug_snapshot!(ipython_escape_command_line_continuation_with_eol_and_eof( + WINDOWS_EOL + )); } #[test] @@ -1334,8 +1406,8 @@ baz = %matplotlib \ assert_debug_snapshot!(lex_jupyter_source(source)); } - fn assert_no_ipython_escape_command(tokens: &[Tok]) { - for tok in tokens { + fn assert_no_ipython_escape_command(tokens: &[Spanned]) { + for (tok, _) in tokens { if let Tok::IpyEscapeCommand { .. } = tok { panic!("Unexpected escape command token: {tok:?}") } @@ -1365,45 +1437,48 @@ def f(arg=%timeit a = b): assert_debug_snapshot!(lex_source(source)); } - #[test_case(" foo"; "long")] - #[test_case(" "; "whitespace")] - #[test_case(" "; "single whitespace")] - #[test_case(""; "empty")] - fn test_line_comment(comment: &str) { - let source = format!("99232 # {comment}"); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::Int { - value: BigInt::from(99232) - }, - Tok::Comment(format!("# {comment}")), - Tok::Newline - ] - ); + #[test] + fn test_line_comment_long() { + let source = "99232 # foo".to_string(); + assert_debug_snapshot!(lex_source(&source)); } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_comment_until_eol(eol: &str) { + #[test] + fn test_line_comment_whitespace() { + let source = "99232 # ".to_string(); + assert_debug_snapshot!(lex_source(&source)); + } + + #[test] + fn test_line_comment_single_whitespace() { + let source = "99232 # ".to_string(); + assert_debug_snapshot!(lex_source(&source)); + } + + #[test] + fn test_line_comment_empty() { + let source = "99232 #".to_string(); + assert_debug_snapshot!(lex_source(&source)); + } + + fn comment_until_eol(eol: &str) -> Vec { let source = format!("123 # Foo{eol}456"); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::Int { - value: BigInt::from(123) - }, - Tok::Comment("# Foo".to_string()), - Tok::Newline, - Tok::Int { - value: BigInt::from(456) - }, - Tok::Newline, - ] - ); + lex_source(&source) + } + + #[test] + fn test_comment_until_unix_eol() { + assert_debug_snapshot!(comment_until_eol(UNIX_EOL)); + } + + #[test] + fn test_comment_until_mac_eol() { + assert_debug_snapshot!(comment_until_eol(MAC_EOL)); + } + + #[test] + fn test_comment_until_windows_eol() { + assert_debug_snapshot!(comment_until_eol(WINDOWS_EOL)); } #[test] @@ -1412,115 +1487,67 @@ def f(arg=%timeit a = b): assert_debug_snapshot!(lex_source(source)); } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_indentation_with_eol(eol: &str) { + fn indentation_with_eol(eol: &str) -> Vec { let source = format!("def foo():{eol} return 99{eol}{eol}"); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::Def, - Tok::Name { - name: String::from("foo"), - }, - Tok::Lpar, - Tok::Rpar, - Tok::Colon, - Tok::Newline, - Tok::Indent, - Tok::Return, - Tok::Int { - value: BigInt::from(99) - }, - Tok::Newline, - Tok::NonLogicalNewline, - Tok::Dedent, - ] - ); + lex_source(&source) } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_double_dedent_with_eol(eol: &str) { + #[test] + fn test_indentation_with_unix_eol() { + assert_debug_snapshot!(indentation_with_eol(UNIX_EOL)); + } + + #[test] + fn test_indentation_with_mac_eol() { + assert_debug_snapshot!(indentation_with_eol(MAC_EOL)); + } + + #[test] + fn test_indentation_with_windows_eol() { + assert_debug_snapshot!(indentation_with_eol(WINDOWS_EOL)); + } + + fn double_dedent_with_eol(eol: &str) -> Vec { let source = format!("def foo():{eol} if x:{eol}{eol} return 99{eol}{eol}"); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::Def, - Tok::Name { - name: String::from("foo"), - }, - Tok::Lpar, - Tok::Rpar, - Tok::Colon, - Tok::Newline, - Tok::Indent, - Tok::If, - Tok::Name { - name: String::from("x"), - }, - Tok::Colon, - Tok::Newline, - Tok::NonLogicalNewline, - Tok::Indent, - Tok::Return, - Tok::Int { - value: BigInt::from(99) - }, - Tok::Newline, - Tok::NonLogicalNewline, - Tok::Dedent, - Tok::Dedent, - ] - ); + lex_source(&source) } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_double_dedent_with_tabs(eol: &str) { + #[test] + fn test_double_dedent_with_unix_eol() { + assert_debug_snapshot!(double_dedent_with_eol(UNIX_EOL)); + } + + #[test] + fn test_double_dedent_with_mac_eol() { + assert_debug_snapshot!(double_dedent_with_eol(MAC_EOL)); + } + + #[test] + fn test_double_dedent_with_windows_eol() { + assert_debug_snapshot!(double_dedent_with_eol(WINDOWS_EOL)); + } + + fn double_dedent_with_tabs_eol(eol: &str) -> Vec { let source = format!("def foo():{eol}\tif x:{eol}{eol}\t\t return 99{eol}{eol}"); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::Def, - Tok::Name { - name: String::from("foo"), - }, - Tok::Lpar, - Tok::Rpar, - Tok::Colon, - Tok::Newline, - Tok::Indent, - Tok::If, - Tok::Name { - name: String::from("x"), - }, - Tok::Colon, - Tok::Newline, - Tok::NonLogicalNewline, - Tok::Indent, - Tok::Return, - Tok::Int { - value: BigInt::from(99) - }, - Tok::Newline, - Tok::NonLogicalNewline, - Tok::Dedent, - Tok::Dedent, - ] - ); + lex_source(&source) } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_newline_in_brackets(eol: &str) { + #[test] + fn test_double_dedent_with_tabs_unix_eol() { + assert_debug_snapshot!(double_dedent_with_tabs_eol(UNIX_EOL)); + } + + #[test] + fn test_double_dedent_with_tabs_mac_eol() { + assert_debug_snapshot!(double_dedent_with_tabs_eol(MAC_EOL)); + } + + #[test] + fn test_double_dedent_with_tabs_windows_eol() { + assert_debug_snapshot!(double_dedent_with_tabs_eol(WINDOWS_EOL)); + } + + fn newline_in_brackets_eol(eol: &str) -> Vec { let source = r"x = [ 1,2 @@ -1532,59 +1559,22 @@ def f(arg=%timeit a = b): 7}] " .replace('\n', eol); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::Name { - name: String::from("x"), - }, - Tok::Equal, - Tok::Lsqb, - Tok::NonLogicalNewline, - Tok::NonLogicalNewline, - Tok::Int { - value: BigInt::from(1) - }, - Tok::Comma, - Tok::Int { - value: BigInt::from(2) - }, - Tok::NonLogicalNewline, - Tok::Comma, - Tok::Lpar, - Tok::Int { - value: BigInt::from(3) - }, - Tok::Comma, - Tok::NonLogicalNewline, - Tok::Int { - value: BigInt::from(4) - }, - Tok::Comma, - Tok::NonLogicalNewline, - Tok::Rpar, - Tok::Comma, - Tok::Lbrace, - Tok::NonLogicalNewline, - Tok::Int { - value: BigInt::from(5) - }, - Tok::Comma, - Tok::NonLogicalNewline, - Tok::Int { - value: BigInt::from(6) - }, - Tok::Comma, - // Continuation here - no NonLogicalNewline. - Tok::Int { - value: BigInt::from(7) - }, - Tok::Rbrace, - Tok::Rsqb, - Tok::Newline, - ] - ); + lex_source(&source) + } + + #[test] + fn test_newline_in_brackets_unix_eol() { + assert_debug_snapshot!(newline_in_brackets_eol(UNIX_EOL)); + } + + #[test] + fn test_newline_in_brackets_mac_eol() { + assert_debug_snapshot!(newline_in_brackets_eol(MAC_EOL)); + } + + #[test] + fn test_newline_in_brackets_windows_eol() { + assert_debug_snapshot!(newline_in_brackets_eol(WINDOWS_EOL)); } #[test] @@ -1617,60 +1607,50 @@ def f(arg=%timeit a = b): assert_debug_snapshot!(lex_source(source)); } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_string_continuation_with_eol(eol: &str) { + fn string_continuation_with_eol(eol: &str) -> Vec { let source = format!("\"abc\\{eol}def\""); - let tokens = lex_source(&source); + lex_source(&source) + } - assert_eq!( - tokens, - vec![ - Tok::String { - value: format!("abc\\{eol}def"), - kind: StringKind::String, - triple_quoted: false, - }, - Tok::Newline, - ] - ); + #[test] + fn test_string_continuation_with_unix_eol() { + assert_debug_snapshot!(string_continuation_with_eol(UNIX_EOL)); + } + + #[test] + fn test_string_continuation_with_mac_eol() { + assert_debug_snapshot!(string_continuation_with_eol(MAC_EOL)); + } + + #[test] + fn test_string_continuation_with_windows_eol() { + assert_debug_snapshot!(string_continuation_with_eol(WINDOWS_EOL)); } #[test] fn test_escape_unicode_name() { let source = r#""\N{EN SPACE}""#; - let tokens = lex_source(source); - assert_eq!( - tokens, - vec![ - Tok::String { - value: r"\N{EN SPACE}".to_string(), - kind: StringKind::String, - triple_quoted: false, - }, - Tok::Newline - ] - ); + assert_debug_snapshot!(lex_source(source)); } - #[test_case(UNIX_EOL)] - #[test_case(MAC_EOL)] - #[test_case(WINDOWS_EOL)] - fn test_triple_quoted(eol: &str) { + fn triple_quoted_eol(eol: &str) -> Vec { let source = format!("\"\"\"{eol} test string{eol} \"\"\""); - let tokens = lex_source(&source); - assert_eq!( - tokens, - vec![ - Tok::String { - value: format!("{eol} test string{eol} "), - kind: StringKind::String, - triple_quoted: true, - }, - Tok::Newline, - ] - ); + lex_source(&source) + } + + #[test] + fn test_triple_quoted_unix_eol() { + assert_debug_snapshot!(triple_quoted_eol(UNIX_EOL)); + } + + #[test] + fn test_triple_quoted_mac_eol() { + assert_debug_snapshot!(triple_quoted_eol(MAC_EOL)); + } + + #[test] + fn test_triple_quoted_windows_eol() { + assert_debug_snapshot!(triple_quoted_eol(WINDOWS_EOL)); } // This test case is to just make sure that the lexer doesn't go into @@ -1680,4 +1660,22 @@ def f(arg=%timeit a = b): let source = "[1"; let _ = lex(source, Mode::Module).collect::>(); } + + /// Emoji identifiers are a non-standard python feature and are not supported by our lexer. + #[test] + fn test_emoji_identifier() { + let source = "🐦"; + + let lexed: Vec<_> = lex(source, Mode::Module).collect(); + + match lexed.as_slice() { + [Err(error)] => { + assert_eq!( + error.error, + LexicalErrorType::UnrecognizedToken { tok: '🐦' } + ); + } + result => panic!("Expected an error token but found {result:?}"), + } + } } diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index fca224f6f8..a8262848d0 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -150,7 +150,7 @@ pub fn parse_program_tokens( is_jupyter_notebook: bool, ) -> anyhow::Result { let mode = if is_jupyter_notebook { - Mode::Jupyter + Mode::Ipython } else { Mode::Module }; @@ -267,15 +267,8 @@ pub enum Mode { Module, /// The code consists of a single expression. Expression, - /// The code consists of a sequence of statements which are part of a - /// Jupyter Notebook and thus could include escape commands scoped to - /// a single line. - /// - /// ## Limitations: - /// - /// For [Dynamic object information], the escape characters (`?`, `??`) - /// must be used before an object. For example, `?foo` will be recognized, - /// but `foo?` will not. + /// The code consists of a sequence of statements which can include the + /// escape commands that are part of IPython syntax. /// /// ## Supported escape commands: /// @@ -290,7 +283,7 @@ pub enum Mode { /// [Dynamic object information]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#dynamic-object-information /// [System shell access]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#system-shell-access /// [Automatic parentheses and quotes]: https://ipython.readthedocs.io/en/stable/interactive/reference.html#automatic-parentheses-and-quotes - Jupyter, + Ipython, } impl std::str::FromStr for Mode { @@ -299,7 +292,7 @@ impl std::str::FromStr for Mode { match s { "exec" | "single" => Ok(Mode::Module), "eval" => Ok(Mode::Expression), - "jupyter" => Ok(Mode::Jupyter), + "ipython" => Ok(Mode::Ipython), _ => Err(ModeParseError), } } @@ -313,7 +306,7 @@ impl AsMode for PySourceType { fn as_mode(&self) -> Mode { match self { PySourceType::Python | PySourceType::Stub => Mode::Module, - PySourceType::Ipynb => Mode::Jupyter, + PySourceType::Ipynb => Mode::Ipython, } } } @@ -324,7 +317,7 @@ pub struct ModeParseError; impl std::fmt::Display for ModeParseError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, r#"mode must be "exec", "eval", "jupyter", or "single""#) + write!(f, r#"mode must be "exec", "eval", "ipython", or "single""#) } } diff --git a/crates/ruff_python_parser/src/parser.rs b/crates/ruff_python_parser/src/parser.rs index 8ffc2078e1..d6f6fde5d7 100644 --- a/crates/ruff_python_parser/src/parser.rs +++ b/crates/ruff_python_parser/src/parser.rs @@ -156,7 +156,7 @@ pub fn parse_expression_starts_at( /// ?str.replace /// !ls /// "#; -/// let program = parse(source, Mode::Jupyter, ""); +/// let program = parse(source, Mode::Ipython, ""); /// assert!(program.is_ok()); /// ``` pub fn parse(source: &str, mode: Mode, source_path: &str) -> Result { @@ -643,6 +643,30 @@ with (0 as a, 1 as b,): pass insta::assert_debug_snapshot!(parse_suite(source, "").unwrap()); } + #[test] + fn test_parenthesized_with_statement() { + let source = "\ +with ((a), (b)): pass +with ((a), (b), c as d, (e)): pass +with (a, b): pass +with (a, b) as c: pass +with ((a, b) as c): pass +with (a as b): pass +with (a): pass +with (a := 0): pass +with (a := 0) as x: pass +with ((a)): pass +with ((a := 0)): pass +with (a as b, (a := 0)): pass +with (a, (a := 0)): pass +with (yield): pass +with (yield from a): pass +with ((yield)): pass +with ((yield from a)): pass +"; + insta::assert_debug_snapshot!(parse_suite(source, "").unwrap()); + } + #[test] fn test_with_statement_invalid() { for source in [ @@ -1198,7 +1222,7 @@ foo.bar[0].baz[1]?? foo.bar[0].baz[2].egg?? " .trim(), - Mode::Jupyter, + Mode::Ipython, "", ) .unwrap(); @@ -1212,11 +1236,12 @@ a = 1 %timeit a == 1 "# .trim(); - let lxr = lexer::lex_starts_at(source, Mode::Jupyter, TextSize::default()); + let lxr = lexer::lex_starts_at(source, Mode::Ipython, TextSize::default()); let parse_err = parse_tokens(lxr, Mode::Module, "").unwrap_err(); assert_eq!( parse_err.to_string(), - "IPython escape commands are only allowed in Jupyter mode at byte offset 6".to_string() + "IPython escape commands are only allowed in `Mode::Ipython` at byte offset 6" + .to_string() ); } } diff --git a/crates/ruff_python_parser/src/python.lalrpop b/crates/ruff_python_parser/src/python.lalrpop index 85be9d859f..1c0d828393 100644 --- a/crates/ruff_python_parser/src/python.lalrpop +++ b/crates/ruff_python_parser/src/python.lalrpop @@ -23,7 +23,7 @@ grammar(mode: Mode); // By having only a single pub function, we reduce this to one. pub(crate) Top: ast::Mod = { StartModule => ast::ModModule { body, range: (start..end).into() }.into(), - StartExpression ("\n")* => ast::ModExpression { body: Box::new(body), range: (start..end).into() }.into() + StartExpression ("\n")* => ast::ModExpression { body: Box::new(body.into()), range: (start..end).into() }.into() }; Program: ast::Suite = { @@ -102,7 +102,7 @@ PassStatement: ast::Stmt = { DelStatement: ast::Stmt = { "del" => { ast::Stmt::Delete( - ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect(), range: (location..end_location).into() } + ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr.into(), ast::ExprContext::Del)).collect(), range: (location..end_location).into() } ) }, }; @@ -112,16 +112,16 @@ ExpressionStatement: ast::Stmt = { // Just an expression, no assignment: if suffix.is_empty() { ast::Stmt::Expr( - ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() } + ast::StmtExpr { value: Box::new(expression.into()), range: (location..end_location).into() } ) } else { - let mut targets = vec![set_context(expression, ast::ExprContext::Store)]; + let mut targets = vec![set_context(expression.into(), ast::ExprContext::Store)]; let mut values = suffix; - let value = Box::new(values.pop().unwrap()); + let value = Box::new(values.pop().unwrap().into()); for target in values { - targets.push(set_context(target, ast::ExprContext::Store)); + targets.push(set_context(target.into(), ast::ExprContext::Store)); } ast::Stmt::Assign( @@ -132,20 +132,20 @@ ExpressionStatement: ast::Stmt = { => { ast::Stmt::AugAssign( ast::StmtAugAssign { - target: Box::new(set_context(target, ast::ExprContext::Store)), + target: Box::new(set_context(target.into(), ast::ExprContext::Store)), op, - value: Box::new(rhs), + value: Box::new(rhs.into()), range: (location..end_location).into() }, ) }, > ":" > => { - let simple = target.is_name_expr(); + let simple = target.expr.is_name_expr(); ast::Stmt::AnnAssign( ast::StmtAnnAssign { - target: Box::new(set_context(target, ast::ExprContext::Store)), - annotation: Box::new(annotation), - value: rhs.map(Box::new), + target: Box::new(set_context(target.into(), ast::ExprContext::Store)), + annotation: Box::new(annotation.into()), + value: rhs.map(ast::Expr::from).map(Box::new), simple, range: (location..end_location).into() }, @@ -153,33 +153,33 @@ ExpressionStatement: ast::Stmt = { }, }; -AssignSuffix: ast::Expr = { +AssignSuffix: ast::ParenthesizedExpr = { "=" => e, "=" => e }; -TestListOrYieldExpr: ast::Expr = { +TestListOrYieldExpr: ast::ParenthesizedExpr = { TestList, YieldExpr } #[inline] -TestOrStarExprList: ast::Expr = { +TestOrStarExprList: ast::ParenthesizedExpr = { // as far as I can tell, these were the same TestList }; -TestOrStarExpr: ast::Expr = { +TestOrStarExpr: ast::ParenthesizedExpr = { Test<"all">, StarExpr, }; -NamedOrStarExpr: ast::Expr = { +NamedOrStarExpr: ast::ParenthesizedExpr = { NamedExpression, StarExpr, }; -TestOrStarNamedExpr: ast::Expr = { +TestOrStarNamedExpr: ast::ParenthesizedExpr = { NamedExpressionTest, StarExpr, }; @@ -210,12 +210,12 @@ FlowStatement: ast::Stmt = { }, "return" => { ast::Stmt::Return( - ast::StmtReturn { value: value.map(Box::new), range: (location..end_location).into() } + ast::StmtReturn { value: value.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) }, => { ast::Stmt::Expr( - ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() } + ast::StmtExpr { value: Box::new(expression.into()), range: (location..end_location).into() } ) }, RaiseStatement, @@ -227,9 +227,9 @@ RaiseStatement: ast::Stmt = { ast::StmtRaise { exc: None, cause: None, range: (location..end_location).into() } ) }, - "raise" > >)?> => { + "raise" > >)?> => { ast::Stmt::Raise( - ast::StmtRaise { exc: Some(Box::new(t)), cause: c.map(Box::new), range: (location..end_location).into() } + ast::StmtRaise { exc: Some(Box::new(exc.into())), cause: cause.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) }, }; @@ -315,8 +315,8 @@ AssertStatement: ast::Stmt = { "assert" > >)?> => { ast::Stmt::Assert( ast::StmtAssert { - test: Box::new(test), - msg: msg.map(Box::new), + test: Box::new(test.into()), + msg: msg.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) @@ -325,7 +325,7 @@ AssertStatement: ast::Stmt = { IpyEscapeCommandStatement: ast::Stmt = { =>? { - if mode == Mode::Jupyter { + if mode == Mode::Ipython { Ok(ast::Stmt::IpyEscapeCommand( ast::StmtIpyEscapeCommand { kind: c.0, @@ -335,16 +335,16 @@ IpyEscapeCommandStatement: ast::Stmt = { )) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in `Mode::Ipython`".to_string()), location, })? } } } -IpyEscapeCommandExpr: ast::Expr = { +IpyEscapeCommandExpr: ast::ParenthesizedExpr = { =>? { - if mode == Mode::Jupyter { + if mode == Mode::Ipython { // This should never occur as the lexer won't allow it. if !matches!(c.0, IpyEscapeKind::Magic | IpyEscapeKind::Shell) { return Err(LexicalError { @@ -352,16 +352,14 @@ IpyEscapeCommandExpr: ast::Expr = { location, })?; } - Ok(ast::Expr::IpyEscapeCommand( - ast::ExprIpyEscapeCommand { - kind: c.0, - value: c.1, - range: (location..end_location).into() - } - )) + Ok(ast::ExprIpyEscapeCommand { + kind: c.0, + value: c.1, + range: (location..end_location).into() + }.into()) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in `Mode::Ipython`".to_string()), location, })? } @@ -405,10 +403,10 @@ IpyHelpEndEscapeCommandStatement: ast::Stmt = { Ok(()) } - if mode != Mode::Jupyter { + if mode != Mode::Ipython { return Err(ParseError::User { error: LexicalError { - error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in `Mode::Ipython`".to_string()), location, }, }); @@ -428,7 +426,7 @@ IpyHelpEndEscapeCommandStatement: ast::Stmt = { }; let mut value = String::new(); - unparse_expr(&e, &mut value)?; + unparse_expr(&e.into(), &mut value)?; Ok(ast::Stmt::IpyEscapeCommand( ast::StmtIpyEscapeCommand { @@ -462,7 +460,7 @@ MatchStatement: ast::Stmt = { .end(); ast::Stmt::Match( ast::StmtMatch { - subject: Box::new(subject), + subject: Box::new(subject.into()), cases, range: (location..end_location).into() } @@ -478,13 +476,13 @@ MatchStatement: ast::Stmt = { .end(); ast::Stmt::Match( ast::StmtMatch { - subject: Box::new(subject), + subject: Box::new(subject.into()), cases, range: (location..end_location).into() } ) }, - "match" > ","? ":" "\n" Indent Dedent => { + "match" > ","? ":" "\n" Indent Dedent => { let end_location = cases .last() .unwrap() @@ -492,11 +490,12 @@ MatchStatement: ast::Stmt = { .last() .unwrap() .end(); + let elts = elts.into_iter().map(ast::Expr::from).collect(); ast::Stmt::Match( ast::StmtMatch { subject: Box::new(ast::Expr::Tuple( ast::ExprTuple { - elts: subjects, + elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, @@ -523,7 +522,7 @@ MatchCase: ast::MatchCase = { Guard: ast::Expr = { "if" => { - guard + guard.into() } } @@ -622,32 +621,30 @@ StarPattern: ast::Pattern = { }.into(), } -ConstantAtom: ast::Expr = { +ConstantAtom: ast::ParenthesizedExpr = { => ast::Expr::Constant( - ast::ExprConstant { value, kind: None, range: (location..end_location).into() } - ), + ast::ExprConstant { value, range: (location..end_location).into() } + ).into(), } -ConstantExpr: ast::Expr = { +ConstantExpr: ast::ParenthesizedExpr = { ConstantAtom, "-" => ast::Expr::UnaryOp( ast::ExprUnaryOp { op: ast::UnaryOp::USub, - operand: Box::new(operand), + operand: Box::new(operand.into()), range: (location..end_location).into() } - ), + ).into(), } -AddOpExpr: ast::Expr = { - => ast::Expr::BinOp( - ast::ExprBinOp { - left: Box::new(left), - op, - right: Box::new(right), - range: (location..end_location).into() - } - ), +AddOpExpr: ast::ParenthesizedExpr = { + => ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into(), } LiteralPattern: ast::Pattern = { @@ -664,11 +661,11 @@ LiteralPattern: ast::Pattern = { range: (location..end_location).into() }.into(), => ast::PatternMatchValue { - value: Box::new(value), + value: Box::new(value.into()), range: (location..end_location).into() }.into(), => ast::PatternMatchValue { - value: Box::new(value), + value: Box::new(value.into()), range: (location..end_location).into() }.into(), =>? Ok(ast::PatternMatchValue { @@ -692,22 +689,18 @@ MatchName: ast::Expr = { } MatchNameOrAttr: ast::Expr = { - "." => ast::Expr::Attribute( - ast::ExprAttribute { - value: Box::new(name), - attr, - ctx: ast::ExprContext::Load, - range: (location..end_location).into() - }, - ), - "." => ast::Expr::Attribute( - ast::ExprAttribute { - value: Box::new(e), - attr, - ctx: ast::ExprContext::Load, - range: (location..end_location).into() - }, - ) + "." => ast::ExprAttribute { + value: Box::new(name), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into() + }.into(), + "." => ast::ExprAttribute { + value: Box::new(e), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into() + }.into(), } ValuePattern: ast::Pattern = { @@ -718,30 +711,21 @@ ValuePattern: ast::Pattern = { } MappingKey: ast::Expr = { - ConstantExpr, - AddOpExpr, MatchNameOrAttr, - "None" => ast::Expr::Constant( - ast::ExprConstant { - value: ast::Constant::None, - kind: None, - range: (location..end_location).into() - }, - ), - "True" => ast::Expr::Constant( - ast::ExprConstant { - value: true.into(), - kind: None, - range: (location..end_location).into() - }, - ), - "False" => ast::Expr::Constant( - ast::ExprConstant { - value: false.into(), - kind: None, - range: (location..end_location).into() - }, - ), + => e.into(), + => e.into(), + "None" => ast::ExprConstant { + value: ast::Constant::None, + range: (location..end_location).into() + }.into(), + "True" => ast::ExprConstant { + value: true.into(), + range: (location..end_location).into() + }.into(), + "False" => ast::ExprConstant { + value: false.into(), + range: (location..end_location).into() + }.into(), =>? Ok(parse_strings(s)?), } @@ -850,7 +834,7 @@ IfStatement: ast::Stmt = { "if" ":" "elif" ":" )*> "else" ":" )?> => { let elif_else_clauses: Vec<_> = s2.into_iter().map(|(start, test, body)| ast::ElifElseClause { range: (start..body.last().unwrap().end()).into(), - test: Some(test), + test: Some(test.into()), body, }).chain(s3.into_iter().map(|(start, body)| ast::ElifElseClause { range: (start..body.last().unwrap().end()).into(), @@ -863,7 +847,7 @@ IfStatement: ast::Stmt = { .map_or_else(|| body.last().unwrap().end(), Ranged::end); ast::Stmt::If( - ast::StmtIf { test: Box::new(test), body, elif_else_clauses, range: (location..end_location).into() } + ast::StmtIf { test: Box::new(test.into()), body, elif_else_clauses, range: (location..end_location).into() } ) }, }; @@ -878,7 +862,7 @@ WhileStatement: ast::Stmt = { .end(); ast::Stmt::While( ast::StmtWhile { - test: Box::new(test), + test: Box::new(test.into()), body, orelse, range: (location..end_location).into() @@ -895,8 +879,8 @@ ForStatement: ast::Stmt = { .or_else(|| body.last()) .unwrap() .end(); - let target = Box::new(set_context(target, ast::ExprContext::Store)); - let iter = Box::new(iter); + let target = Box::new(set_context(target.into(), ast::ExprContext::Store)); + let iter = Box::new(iter.into()); ast::Stmt::For(ast::StmtFor { target, iter, body, orelse, is_async: is_async.is_some(), range: (location..end_location).into() }) }, }; @@ -964,7 +948,7 @@ ExceptStarClause: ast::ExceptHandler = { let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: Some(Box::new(typ)), + type_: Some(Box::new(typ.into())), name: None, body, range: (location..end_location).into() @@ -975,7 +959,7 @@ ExceptStarClause: ast::ExceptHandler = { let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: Some(Box::new(x.0)), + type_: Some(Box::new(x.0.into())), name: Some(x.1), body, range: (location..end_location).into() @@ -990,7 +974,7 @@ ExceptClause: ast::ExceptHandler = { let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: typ.map(Box::new), + type_: typ.map(ast::Expr::from).map(Box::new), name: None, body, range: (location..end_location).into() @@ -1001,7 +985,7 @@ ExceptClause: ast::ExceptHandler = { let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: Some(Box::new(x.0)), + type_: Some(Box::new(x.0.into())), name: Some(x.1), body, range: (location..end_location).into() @@ -1022,7 +1006,25 @@ WithItems: Vec = { "(" ",")?> >)*> ","? ")" => { left.into_iter().flatten().chain([mid]).chain(right).collect() }, - > => vec![<>], + > => { + // Special-case: if the `WithItem` is a parenthesized named expression, then the item + // should _exclude_ the outer parentheses in its range. For example: + // ```python + // with (a := 0): pass + // ``` + // In this case, the `(` and `)` are part of the `with` statement. + // The same applies to `yield` and `yield from`. + let item = if matches!(item.context_expr, ast::Expr::NamedExpr(_) | ast::Expr::Yield(_) | ast::Expr::YieldFrom(_)) { + ast::WithItem { + range: item.range().add_start(TextSize::new(1)).sub_end(TextSize::new(1)), + context_expr: item.context_expr, + optional_vars: item.optional_vars, + } + } else { + item + }; + vec![item] + }, > >)+> => { [item].into_iter().chain(items).collect() } @@ -1030,36 +1032,61 @@ WithItems: Vec = { #[inline] WithItemsNoAs: Vec = { - >> => { - all.into_iter().map(|context_expr| ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() }).collect() + >> => { + all.into_iter().map(|context_expr| ast::WithItem { + range: context_expr.range(), + context_expr: context_expr.into(), + optional_vars: None, + }).collect() }, } WithItem: ast::WithItem = { - > => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() }, + > => { + ast::WithItem { + range: context_expr.range(), + context_expr: context_expr.into(), + optional_vars: None, + } + }, , }; WithItemAs: ast::WithItem = { - > "as" > => { - let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store))); - ast::WithItem { context_expr, optional_vars, range: (location..end_location).into() } + > "as" > => { + let optional_vars = Some(Box::new(set_context(optional_vars.into(), ast::ExprContext::Store))); + ast::WithItem { + context_expr: context_expr.into(), + optional_vars, + range: (location..end_location).into(), + } }, } FuncDef: ast::Stmt = { - "def" " >)?> ":" => { - let args = Box::new(args); - let returns = r.map(Box::new); + "def" " >)?> ":" => { + let parameters = Box::new(parameters); + let returns = returns.map(ast::Expr::from).map(Box::new); let end_location = body.last().unwrap().end(); - ast::StmtFunctionDef { name, parameters:args, body, decorator_list, returns, type_params, is_async: is_async.is_some(), range: (location..end_location).into() }.into() + ast::StmtFunctionDef { + name, + parameters, + body, + decorator_list, + returns, + type_params, + is_async: is_async.is_some(), + range: (location..end_location).into(), + }.into() }, }; TypeAliasName: ast::Expr = { - => ast::Expr::Name( - ast::ExprName { id: name.into(), ctx: ast::ExprContext::Store, range: (location..end_location).into() }, - ), + => ast::ExprName { + id: name.into(), + ctx: ast::ExprContext::Store, + range: (location..end_location).into(), + }.into(), } TypeAliasStatement: ast::Stmt = { @@ -1067,7 +1094,7 @@ TypeAliasStatement: ast::Stmt = { ast::Stmt::TypeAlias( ast::StmtTypeAlias { name: Box::new(name), - value: Box::new(value), + value: Box::new(value.into()), type_params, range: (location..end_location).into() }, @@ -1163,17 +1190,17 @@ ParameterDefs: (Vec, Vec: ast::ParameterWithDefault = { => i, - "=" > => { - i.default = Some(Box::new(e)); + "=" > => { + i.default = Some(Box::new(default.into())); i.range = (i.range.start()..end_location).into(); i }, }; UntypedParameter: ast::ParameterWithDefault = { - => { - let def = ast::Parameter { name:arg, annotation: None, range: (location..end_location).into() }; - ast::ParameterWithDefault { parameter:def, default: None, range: (location..end_location).into() } + => { + let parameter = ast::Parameter { name, annotation: None, range: (location..end_location).into() }; + ast::ParameterWithDefault { parameter, default: None, range: (location..end_location).into() } }, }; StarUntypedParameter: ast::Parameter = { @@ -1181,24 +1208,24 @@ StarUntypedParameter: ast::Parameter = { }; TypedParameter: ast::ParameterWithDefault = { - >)?> => { - let annotation = a.map(Box::new); - let def = ast::Parameter { name:arg, annotation, range: (location..end_location).into() }; - ast::ParameterWithDefault { parameter:def, default: None, range: (location..end_location).into() } + >)?> => { + let annotation = annotation.map(ast::Expr::from).map(Box::new); + let parameter = ast::Parameter { name, annotation, range: (location..end_location).into() }; + ast::ParameterWithDefault { parameter, default: None, range: (location..end_location).into() } }, }; StarTypedParameter: ast::Parameter = { - )?> => { - let annotation = a.map(Box::new); - ast::Parameter { name:arg, annotation, range: (location..end_location).into() } + )?> => { + let annotation = annotation.map(ast::Expr::from).map(Box::new); + ast::Parameter { name, annotation, range: (location..end_location).into() } }, }; DoubleStarTypedParameter: ast::Parameter = { - >)?> => { - let annotation = a.map(Box::new); - ast::Parameter { name:arg, annotation, range: (location..end_location).into() } + >)?> => { + let annotation = annotation.map(ast::Expr::from).map(Box::new); + ast::Parameter { name, annotation, range: (location..end_location).into() } }, }; @@ -1255,7 +1282,7 @@ TypeParams: ast::TypeParams = { TypeParam: ast::TypeParam = { >)?> => { ast::TypeParam::TypeVar( - ast::TypeParamTypeVar { name, bound: bound.map(Box::new), range: (location..end_location).into() } + ast::TypeParamTypeVar { name, bound: bound.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) }, "*" => { @@ -1272,103 +1299,97 @@ TypeParam: ast::TypeParam = { // Decorators: Decorator: ast::Decorator = { - "@" "\n" => { - ast::Decorator { range: (location..end_location).into(), expression: p } + "@" "\n" => { + ast::Decorator { range: (location..end_location).into(), expression: expression.into() } }, }; -YieldExpr: ast::Expr = { - "yield" => ast::Expr::Yield( - ast::ExprYield { value: value.map(Box::new), range: (location..end_location).into() } - ), - "yield" "from" > => ast::Expr::YieldFrom( - ast::ExprYieldFrom { value: Box::new(e), range: (location..end_location).into() } - ), +YieldExpr: ast::ParenthesizedExpr = { + "yield" => ast::ExprYield { + value: value.map(ast::Expr::from).map(Box::new), + range: (location..end_location).into(), + }.into(), + "yield" "from" > => ast::ExprYieldFrom { + value: Box::new(value.into()), + range: (location..end_location).into(), + }.into(), }; -Test: ast::Expr = { - > "if" > "else" > => ast::Expr::IfExp( - ast::ExprIfExp { - test: Box::new(test), - body: Box::new(body), - orelse: Box::new(orelse), - range: (location..end_location).into() - } - ), +Test: ast::ParenthesizedExpr = { + > "if" > "else" > => ast::ExprIfExp { + test: Box::new(test.into()), + body: Box::new(body.into()), + orelse: Box::new(orelse.into()), + range: (location..end_location).into() + }.into(), OrTest, LambdaDef, }; -NamedExpressionTest: ast::Expr = { +NamedExpressionTest: ast::ParenthesizedExpr = { NamedExpression, Test<"all">, } -NamedExpressionName: ast::Expr = { - => ast::Expr::Name( - ast::ExprName { id: id.into(), ctx: ast::ExprContext::Store, range: (location..end_location).into() }, - ), +NamedExpressionName: ast::ParenthesizedExpr = { + => ast::ExprName { + id: id.into(), + ctx: ast::ExprContext::Store, + range: (location..end_location).into(), + }.into(), } -NamedExpression: ast::Expr = { +NamedExpression: ast::ParenthesizedExpr = { ":=" > => { - ast::Expr::NamedExpr( - ast::ExprNamedExpr { - target: Box::new(target), - value: Box::new(value), - range: (location..end_location).into(), - } - ) + ast::ExprNamedExpr { + target: Box::new(target.into()), + value: Box::new(value.into()), + range: (location..end_location).into(), + }.into() }, }; -LambdaDef: ast::Expr = { +LambdaDef: ast::ParenthesizedExpr = { "lambda" ?> ":" > =>? { parameters.as_ref().map(validate_arguments).transpose()?; - Ok(ast::Expr::Lambda( - ast::ExprLambda { - parameters: parameters.map(Box::new), - body: Box::new(body), - range: (location..end_location).into() - } - )) + Ok(ast::ExprLambda { + parameters: parameters.map(Box::new), + body: Box::new(body.into()), + range: (location..end_location).into() + }.into()) } } -OrTest: ast::Expr = { - > "or")+> > => { - values.push(last); - ast::Expr::BoolOp( - ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() } - ) +OrTest: ast::ParenthesizedExpr = { + > "or")+> > => { + let values = values.into_iter().chain(std::iter::once(last)).map(ast::Expr::from).collect(); + ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() }.into() }, AndTest, }; -AndTest: ast::Expr = { - > "and")+> > => { - values.push(last); - ast::Expr::BoolOp( - ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() } - ) +AndTest: ast::ParenthesizedExpr = { + > "and")+> > => { + let values = values.into_iter().chain(std::iter::once(last)).map(ast::Expr::from).collect(); + ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() }.into() }, NotTest, }; -NotTest: ast::Expr = { - "not" > => ast::Expr::UnaryOp( - ast::ExprUnaryOp { operand: Box::new(e), op: ast::UnaryOp::Not, range: (location..end_location).into() } - ), +NotTest: ast::ParenthesizedExpr = { + "not" > => ast::ExprUnaryOp { + operand: Box::new(operand.into()), + op: ast::UnaryOp::Not, + range: (location..end_location).into(), + }.into(), Comparison, }; -Comparison: ast::Expr = { +Comparison: ast::ParenthesizedExpr = { > )+> => { - let (ops, comparators) = comparisons.into_iter().unzip(); - ast::Expr::Compare( - ast::ExprCompare { left: Box::new(left), ops, comparators, range: (location..end_location).into() } - ) + let (ops, comparators) = comparisons.into_iter().map(|(op, comparator)| (op, ast::Expr::from(comparator))).unzip(); + ast::ExprCompare { left: Box::new(left.into()), ops, comparators, range: (location..end_location).into() }.into() }, Expression, }; @@ -1386,31 +1407,43 @@ CompOp: ast::CmpOp = { "is" "not" => ast::CmpOp::IsNot, }; -Expression: ast::Expr = { - > "|" > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2), range: (location..end_location).into() } - ), +Expression: ast::ParenthesizedExpr = { + > "|" > => ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitOr, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into(), XorExpression, }; -XorExpression: ast::Expr = { - > "^" > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2), range: (location..end_location).into() } - ), +XorExpression: ast::ParenthesizedExpr = { + > "^" > => ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitXor, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into(), AndExpression, }; -AndExpression: ast::Expr = { - > "&" > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2), range: (location..end_location).into() } - ), +AndExpression: ast::ParenthesizedExpr = { + > "&" > => ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitAnd, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into(), ShiftExpression, }; -ShiftExpression: ast::Expr = { - > > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2), range: (location..end_location).into() } - ), +ShiftExpression: ast::ParenthesizedExpr = { + > > => ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into(), ArithmeticExpression, }; @@ -1419,10 +1452,13 @@ ShiftOp: ast::Operator = { ">>" => ast::Operator::RShift, }; -ArithmeticExpression: ast::Expr = { - > > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } - ), +ArithmeticExpression: ast::ParenthesizedExpr = { + > > => ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into(), Term, }; @@ -1431,10 +1467,13 @@ AddOp: ast::Operator = { "-" => ast::Operator::Sub, }; -Term: ast::Expr = { - > > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } - ), +Term: ast::ParenthesizedExpr = { + > > => ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into(), Factor, }; @@ -1446,10 +1485,12 @@ MulOp: ast::Operator = { "@" => ast::Operator::MatMult, }; -Factor: ast::Expr = { - > => ast::Expr::UnaryOp( - ast::ExprUnaryOp { operand: Box::new(e), op, range: (location..end_location).into() } - ), +Factor: ast::ParenthesizedExpr = { + > => ast::ExprUnaryOp { + operand: Box::new(operand.into()), + op, + range: (location..end_location).into(), + }.into(), Power, }; @@ -1459,122 +1500,139 @@ UnaryOp: ast::UnaryOp = { "~" => ast::UnaryOp::Invert, }; -Power: ast::Expr = { - > "**" > => ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b), range: (location..end_location).into() } - ), +Power: ast::ParenthesizedExpr = { + > "**" > => ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::Pow, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into(), AtomExpr, }; -AtomExpr: ast::Expr = { - "await" > => { - ast::Expr::Await( - ast::ExprAwait { value: Box::new(atom), range: (location..end_location).into() } - ) +AtomExpr: ast::ParenthesizedExpr = { + "await" > => { + ast::ExprAwait { value: Box::new(value.into()), range: (location..end_location).into() }.into() }, AtomExpr2, } -AtomExpr2: ast::Expr = { +AtomExpr2: ast::ParenthesizedExpr = { Atom, - > => { - ast::Expr::Call( - ast::ExprCall { func: Box::new(f), arguments, range: (location..end_location).into() } - ) - }, - > "[" "]" => ast::Expr::Subscript( - ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ), - > "." => ast::Expr::Attribute( - ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ), + > => ast::ExprCall { + func: Box::new(func.into()), + arguments, + range: (location..end_location).into(), + }.into(), + > "[" "]" => ast::ExprSubscript { + value: Box::new(value.into()), + slice: Box::new(slice.into()), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into(), + > "." => ast::ExprAttribute { + value: Box::new(value.into()), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into(), }; -SubscriptList: ast::Expr = { - => { - s1 - }, +SubscriptList: ast::ParenthesizedExpr = { + Subscript, "," => { - ast::Expr::Tuple( - ast::ExprTuple { elts: vec![s1], ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ) + ast::ExprTuple { + elts: vec![s1.into()], + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() }, > ","? => { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { + elts, + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } }; -Subscript: ast::Expr = { +Subscript: ast::ParenthesizedExpr = { TestOrStarNamedExpr, - ?> ":" ?> => { - let lower = e1.map(Box::new); - let upper = e2.map(Box::new); - let step = e3.flatten().map(Box::new); + ?> ":" ?> => { + let lower = lower.map(ast::Expr::from).map(Box::new); + let upper = upper.map(ast::Expr::from).map(Box::new); + let step = step.flatten().map(ast::Expr::from).map(Box::new); ast::Expr::Slice( ast::ExprSlice { lower, upper, step, range: (location..end_location).into() } - ) + ).into() } }; -SliceOp: Option = { +SliceOp: Option = { ":" ?> => e, } -Atom: ast::Expr = { - =>? Ok(parse_strings(s)?), - => ast::Expr::Constant( - ast::ExprConstant { value, kind: None, range: (location..end_location).into() } - ), - => ast::Expr::Name( - ast::ExprName { id: id.into(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ), - "[" "]" => { - let elts = e.unwrap_or_default(); - ast::Expr::List( - ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) +Atom: ast::ParenthesizedExpr = { + =>? Ok(parse_strings(s)?.into()), + => ast::ExprConstant { + value, + range: (location..end_location).into(), + }.into(), + => ast::ExprName { + id: id.into(), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into(), + "[" "]" => { + let elts = elts.into_iter().flatten().map(ast::Expr::from).collect(); + ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() }, "[" "]" => { - ast::Expr::ListComp( - ast::ExprListComp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) + ast::ExprListComp { elt: Box::new(elt.into()), generators, range: (location..end_location).into() }.into() }, "(" >> ")" if Goal != "no-withitems" => { if elts.len() == 1 && trailing_comma.is_none() { - elts.into_iter().next().unwrap() + ast::ParenthesizedExpr { + expr: elts.into_iter().next().unwrap().into(), + range: (location..end_location).into(), + } } else { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } }, "(" >> ",")?> )*> ")" =>? { if left.is_none() && right.is_empty() && trailing_comma.is_none() { - if mid.is_starred_expr() { + if mid.expr.is_starred_expr() { return Err(LexicalError{ error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()), location: mid.start(), })?; } - Ok(mid) + Ok(ast::ParenthesizedExpr { + expr: mid.into(), + range: (location..end_location).into(), + }) } else { - let elts = left.into_iter().flatten().chain([mid]).chain(right).collect(); - Ok(ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - )) + let elts = left.into_iter().flatten().chain([mid]).chain(right).map(ast::Expr::from).collect(); + Ok(ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into()) } }, - "(" ")" => ast::Expr::Tuple( - ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ), - "(" ")" => e, - "(" ")" => { - ast::Expr::GeneratorExp( - ast::ExprGeneratorExp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) + "(" ")" => ast::ExprTuple { + elts: Vec::new(), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into(), + "(" ")" => ast::ParenthesizedExpr { + expr: e.into(), + range: (location..end_location).into(), }, + "(" ")" => ast::ExprGeneratorExp { + elt: Box::new(elt.into()), + generators, + range: (location..end_location).into(), + }.into(), "(" "**" > ")" =>? { Err(LexicalError{ error : LexicalErrorType::OtherError("cannot use double starred expression here".to_string()), @@ -1585,67 +1643,67 @@ Atom: ast::Expr = { let (keys, values) = e .unwrap_or_default() .into_iter() - .map(|(k, v)| (k.map(|x| *x), v)) + .map(|(k, v)| (k.map(|x| ast::Expr::from(*x)), ast::Expr::from(v))) .unzip(); - ast::Expr::Dict( - ast::ExprDict { keys, values, range: (location..end_location).into() } - ) + ast::ExprDict { keys, values, range: (location..end_location).into() }.into() }, "{" "}" => { - ast::Expr::DictComp( - ast::ExprDictComp { - key: Box::new(e1.0), - value: Box::new(e1.1), - generators, - range: (location..end_location).into() - } - ) + ast::ExprDictComp { + key: Box::new(e1.0.into()), + value: Box::new(e1.1.into()), + generators, + range: (location..end_location).into() + }.into() }, - "{" "}" => ast::Expr::Set( - ast::ExprSet { elts, range: (location..end_location).into() } - ), - "{" "}" => { - ast::Expr::SetComp( - ast::ExprSetComp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) + "{" "}" => { + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprSet { + elts, + range: (location..end_location).into(), + }.into() }, - "True" => ast::Expr::Constant(ast::ExprConstant { value: true.into(), kind: None, range: (location..end_location).into() }), - "False" => ast::Expr::Constant(ast::ExprConstant { value: false.into(), kind: None, range: (location..end_location).into() }), - "None" => ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::None, kind: None, range: (location..end_location).into() }), - "..." => ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None, range: (location..end_location).into() }), + "{" "}" => ast::ExprSetComp { + elt: Box::new(elt.into()), + generators, + range: (location..end_location).into(), + }.into(), + "True" => ast::ExprConstant { value: true.into(), range: (location..end_location).into() }.into(), + "False" => ast::ExprConstant { value: false.into(), range: (location..end_location).into() }.into(), + "None" => ast::ExprConstant { value: ast::Constant::None, range: (location..end_location).into() }.into(), + "..." => ast::ExprConstant { value: ast::Constant::Ellipsis, range: (location..end_location).into() }.into(), }; -ListLiteralValues: Vec = { +ListLiteralValues: Vec = { > ","? => e, }; -DictLiteralValues: Vec<(Option>, ast::Expr)> = { +DictLiteralValues: Vec<(Option>, ast::ParenthesizedExpr)> = { > ","? => elements, }; -DictEntry: (ast::Expr, ast::Expr) = { +DictEntry: (ast::ParenthesizedExpr, ast::ParenthesizedExpr) = { > ":" > => (e1, e2), }; -DictElement: (Option>, ast::Expr) = { +DictElement: (Option>, ast::ParenthesizedExpr) = { => (Some(Box::new(e.0)), e.1), "**" > => (None, e), }; -SetLiteralValues: Vec = { +SetLiteralValues: Vec = { > ","? => e1 }; -ExpressionOrStarExpression = { +ExpressionOrStarExpression: ast::ParenthesizedExpr = { Expression<"all">, StarExpr }; -ExpressionList: ast::Expr = { +ExpressionList: ast::ParenthesizedExpr = { GenericList }; -ExpressionList2: Vec = { +ExpressionList2: Vec = { > ","? => elements, }; @@ -1654,27 +1712,31 @@ ExpressionList2: Vec = { // - a single expression // - a single expression followed by a trailing comma #[inline] -TestList: ast::Expr = { +TestList: ast::ParenthesizedExpr = { GenericList }; -GenericList: ast::Expr = { +GenericList: ast::ParenthesizedExpr = { > => { if elts.len() == 1 && trailing_comma.is_none() { - elts.into_iter().next().unwrap() + ast::ParenthesizedExpr { + expr: elts.into_iter().next().unwrap().into(), + range: (location..end_location).into(), + } } else { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } } } // Test -StarExpr: ast::Expr = { - "*" > => ast::Expr::Starred( - ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ) +StarExpr: ast::ParenthesizedExpr = { + "*" > => ast::ExprStarred { + value: Box::new(value.into()), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into(), }; // Comprehensions: @@ -1683,9 +1745,10 @@ CompFor: Vec = => c; SingleForComprehension: ast::Comprehension = { "for" "in" > => { let is_async = is_async.is_some(); + let ifs = ifs.into_iter().map(ast::Expr::from).collect(); ast::Comprehension { - target: set_context(target, ast::ExprContext::Store), - iter, + target: set_context(target.into(), ast::ExprContext::Store), + iter: iter.into(), ifs, is_async, range: (location..end_location).into() @@ -1693,8 +1756,8 @@ SingleForComprehension: ast::Comprehension = { } }; -ExpressionNoCond: ast::Expr = OrTest<"all">; -ComprehensionIf: ast::Expr = "if" => c; +ExpressionNoCond: ast::ParenthesizedExpr = OrTest<"all">; +ComprehensionIf: ast::ParenthesizedExpr = "if" => c; Arguments: ast::Arguments = { "(" > ")" =>? { @@ -1708,27 +1771,27 @@ Arguments: ast::Arguments = { }; FunctionArgument: (Option<(TextSize, TextSize, Option)>, ast::Expr) = { - => { - let expr = match c { - Some(c) => ast::Expr::GeneratorExp( + => { + let expr = match generators { + Some(generators) => ast::Expr::GeneratorExp( ast::ExprGeneratorExp { - elt: Box::new(e), - generators: c, + elt: Box::new(elt.into()), + generators, range: (location..end_location).into() } ), - None => e, + None => elt.into(), }; (None, expr) }, - "=" > => (Some((location, end_location, Some(i))), e), - "*" > => { - let expr = ast::Expr::Starred( - ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ); + "=" > => (Some((location, end_location, Some(i))), e.into()), + "*" > => { + let expr = ast::Expr::Starred(ast::ExprStarred { + value: Box::new(value.into()), ctx: ast::ExprContext::Load, range: (location..end_location).into(), + }); (None, expr) }, - "**" > => (Some((location, end_location, None)), e), + "**" > => (Some((location, end_location, None)), e.into()), }; /// Comma separated sequence that allows an optional trailing comma. diff --git a/crates/ruff_python_parser/src/python.rs b/crates/ruff_python_parser/src/python.rs index 1e0d84f9fe..64b4588a21 100644 --- a/crates/ruff_python_parser/src/python.rs +++ b/crates/ruff_python_parser/src/python.rs @@ -1,5 +1,5 @@ // auto-generated: "lalrpop 0.20.0" -// sha3: 775b210bb49d67488594b3367cf46ced8b5d43213ea80fa21d2d4b96b5bece3d +// sha3: e8f3229288c1a13387ea6041355e2d8fe9ab788fbc7229032d2de92beb675944 use num_bigint::BigInt; use ruff_text_size::{Ranged, TextSize}; use ruff_python_ast::{self as ast, IpyEscapeKind}; @@ -59,9 +59,9 @@ mod __parse__Top { Variant11(alloc::vec::Vec), Variant12((Option>, Vec, Option>)), Variant13(core::option::Option<(Option>, Vec, Option>)>), - Variant14(ast::Expr), - Variant15(core::option::Option), - Variant16(alloc::vec::Vec), + Variant14(ast::ParenthesizedExpr), + Variant15(core::option::Option), + Variant16(alloc::vec::Vec), Variant17(ast::WithItem), Variant18(alloc::vec::Vec), Variant19((token::Tok, ast::Identifier)), @@ -71,75 +71,77 @@ mod __parse__Top { Variant23(core::option::Option), Variant24(ast::Suite), Variant25(core::option::Option), - Variant26((TextSize, ast::Expr, ast::Suite)), - Variant27(alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>), + Variant26((TextSize, ast::ParenthesizedExpr, ast::Suite)), + Variant27(alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>), Variant28((TextSize, ast::Suite)), Variant29(core::option::Option<(TextSize, ast::Suite)>), Variant30((Option<(TextSize, TextSize, Option)>, ast::Expr)), Variant31(alloc::vec::Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>), - Variant32(Vec), - Variant33(core::option::Option>), + Variant32(Vec), + Variant33(core::option::Option>), Variant34(ast::Pattern), Variant35(alloc::vec::Vec), Variant36(ast::Stmt), Variant37(alloc::vec::Vec), - Variant38((ast::Expr, ast::Identifier)), + Variant38((ast::ParenthesizedExpr, ast::Identifier)), Variant39(Vec), Variant40(core::option::Option>), Variant41((TextSize, (String, StringKind, bool), TextSize)), Variant42(alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>), - Variant43((ast::CmpOp, ast::Expr)), - Variant44(alloc::vec::Vec<(ast::CmpOp, ast::Expr)>), - Variant45(ast::Parameters), - Variant46(core::option::Option), - Variant47(TextSize), - Variant48(ast::Operator), - Variant49(ast::Arguments), - Variant50(core::option::Option), - Variant51(Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>), - Variant52(Vec), - Variant53(Vec), - Variant54(core::option::Option>), - Variant55(ast::CmpOp), - Variant56(ast::Constant), - Variant57(ast::Decorator), - Variant58(alloc::vec::Vec), - Variant59((Option>, ast::Expr)), - Variant60((ast::Expr, ast::Expr)), - Variant61(Vec<(Option>, ast::Expr)>), - Variant62(core::option::Option>, ast::Expr)>>), - Variant63(ast::Parameter), - Variant64(core::option::Option), - Variant65(ast::ExceptHandler), - Variant66(alloc::vec::Vec), - Variant67(core::option::Option<(Option<(TextSize, TextSize, Option)>, ast::Expr)>), - Variant68(ast::Alias), - Variant69(Vec), - Variant70(ast::Int), - Variant71(alloc::vec::Vec), - Variant72((Option, Option)), - Variant73(ast::MatchCase), - Variant74(alloc::vec::Vec), - Variant75(ast::PatternKeyword), - Variant76((ast::Expr, ast::Pattern)), - Variant77(Vec), - Variant78(Vec), - Variant79(Vec<(ast::Expr, ast::Pattern)>), - Variant80(Vec), - Variant81(Vec), - Variant82((Vec, Vec)), - Variant83(core::option::Option), - Variant84(ast::PatternArguments), - Variant85(ast::Comprehension), - Variant86(alloc::vec::Vec), - Variant87(Option), - Variant88(core::option::Option>), - Variant89(Vec), - Variant90(ast::Mod), - Variant91(ast::TypeParam), - Variant92(ast::TypeParams), - Variant93(core::option::Option), - Variant94(ast::UnaryOp), + Variant43((ast::CmpOp, ast::ParenthesizedExpr)), + Variant44(alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>), + Variant45(ast::Expr), + Variant46(core::option::Option), + Variant47(ast::Parameters), + Variant48(core::option::Option), + Variant49(TextSize), + Variant50(ast::Operator), + Variant51(ast::Arguments), + Variant52(core::option::Option), + Variant53(Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>), + Variant54(Vec), + Variant55(Vec), + Variant56(core::option::Option>), + Variant57(ast::CmpOp), + Variant58(ast::Constant), + Variant59(ast::Decorator), + Variant60(alloc::vec::Vec), + Variant61((Option>, ast::ParenthesizedExpr)), + Variant62((ast::ParenthesizedExpr, ast::ParenthesizedExpr)), + Variant63(Vec<(Option>, ast::ParenthesizedExpr)>), + Variant64(core::option::Option>, ast::ParenthesizedExpr)>>), + Variant65(ast::Parameter), + Variant66(core::option::Option), + Variant67(ast::ExceptHandler), + Variant68(alloc::vec::Vec), + Variant69(core::option::Option<(Option<(TextSize, TextSize, Option)>, ast::Expr)>), + Variant70(ast::Alias), + Variant71(Vec), + Variant72(ast::Int), + Variant73(alloc::vec::Vec), + Variant74((Option, Option)), + Variant75(ast::MatchCase), + Variant76(alloc::vec::Vec), + Variant77(ast::PatternKeyword), + Variant78((ast::Expr, ast::Pattern)), + Variant79(Vec), + Variant80(Vec), + Variant81(Vec<(ast::Expr, ast::Pattern)>), + Variant82(Vec), + Variant83(Vec), + Variant84((Vec, Vec)), + Variant85(core::option::Option), + Variant86(ast::PatternArguments), + Variant87(ast::Comprehension), + Variant88(alloc::vec::Vec), + Variant89(Option), + Variant90(core::option::Option>), + Variant91(Vec), + Variant92(ast::Mod), + Variant93(ast::TypeParam), + Variant94(ast::TypeParams), + Variant95(core::option::Option), + Variant96(ast::UnaryOp), } const __ACTION: &[i16] = &[ // State 0 @@ -861,7 +863,7 @@ mod __parse__Top { // State 358 0, 0, 0, 0, 0, 0, 325, 0, 326, 0, 0, 0, 0, 0, 0, 327, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 967, 968, 969, 328, 1080, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 329, 0, 0, 0, 0, 0, 0, 0, 0, 415, 416, 417, 0, 418, 419, // State 359 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 424, 0, 0, 425, 0, 0, 0, 0, 0, 0, 0, 0, -456, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 424, 0, 0, 425, 0, 0, 0, 0, 0, 0, 0, 0, -457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 418, 0, // State 361 @@ -2181,7 +2183,7 @@ mod __parse__Top { // State 1018 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -462, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 422, // State 1019 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -458, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1020 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -476, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1021 @@ -2191,7 +2193,7 @@ mod __parse__Top { // State 1023 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1024 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 351, 0, 0, 0, 0, 0, -458, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 351, 0, 0, 0, 0, 0, -456, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1025 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 372, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1083, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 1026 @@ -11556,16 +11558,16 @@ mod __parse__Top { __reduce21(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 22 => { - // ("," >) = ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(937); + // ("," >) = ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(935); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action937::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action935::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11573,7 +11575,7 @@ mod __parse__Top { (5, 13) } 23 => { - // ("," >) = ",", "*", ",", KwargParameter => ActionFn(938); + // ("," >) = ",", "*", ",", KwargParameter => ActionFn(936); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -11581,7 +11583,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action938::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action936::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11589,17 +11591,17 @@ mod __parse__Top { (4, 13) } 24 => { - // ("," >) = ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(939); + // ("," >) = ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(937); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action939::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action937::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11607,7 +11609,7 @@ mod __parse__Top { (6, 13) } 25 => { - // ("," >) = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(940); + // ("," >) = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(938); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -11616,7 +11618,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action940::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action938::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11624,14 +11626,14 @@ mod __parse__Top { (5, 13) } 26 => { - // ("," >) = ",", "*", StarTypedParameter => ActionFn(941); + // ("," >) = ",", "*", StarTypedParameter => ActionFn(939); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action941::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action939::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11639,13 +11641,13 @@ mod __parse__Top { (3, 13) } 27 => { - // ("," >) = ",", "*" => ActionFn(942); + // ("," >) = ",", "*" => ActionFn(940); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action942::<>(mode, __sym0, __sym1) { + let __nt = match super::__action940::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11653,15 +11655,15 @@ mod __parse__Top { (2, 13) } 28 => { - // ("," >) = ",", "*", StarTypedParameter, ("," >)+ => ActionFn(943); + // ("," >) = ",", "*", StarTypedParameter, ("," >)+ => ActionFn(941); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action943::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action941::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11669,14 +11671,14 @@ mod __parse__Top { (4, 13) } 29 => { - // ("," >) = ",", "*", ("," >)+ => ActionFn(944); + // ("," >) = ",", "*", ("," >)+ => ActionFn(942); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action944::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action942::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11684,16 +11686,16 @@ mod __parse__Top { (3, 13) } 30 => { - // ("," >)? = ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(961); + // ("," >)? = ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(959); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action961::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action959::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11701,7 +11703,7 @@ mod __parse__Top { (5, 14) } 31 => { - // ("," >)? = ",", "*", ",", KwargParameter => ActionFn(962); + // ("," >)? = ",", "*", ",", KwargParameter => ActionFn(960); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -11709,7 +11711,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action962::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action960::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11717,17 +11719,17 @@ mod __parse__Top { (4, 14) } 32 => { - // ("," >)? = ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(963); + // ("," >)? = ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(961); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action963::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action961::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11735,7 +11737,7 @@ mod __parse__Top { (6, 14) } 33 => { - // ("," >)? = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(964); + // ("," >)? = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(962); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -11744,7 +11746,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action964::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action962::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11752,14 +11754,14 @@ mod __parse__Top { (5, 14) } 34 => { - // ("," >)? = ",", "*", StarTypedParameter => ActionFn(965); + // ("," >)? = ",", "*", StarTypedParameter => ActionFn(963); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action965::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action963::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11767,13 +11769,13 @@ mod __parse__Top { (3, 14) } 35 => { - // ("," >)? = ",", "*" => ActionFn(966); + // ("," >)? = ",", "*" => ActionFn(964); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action966::<>(mode, __sym0, __sym1) { + let __nt = match super::__action964::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11781,15 +11783,15 @@ mod __parse__Top { (2, 14) } 36 => { - // ("," >)? = ",", "*", StarTypedParameter, ("," >)+ => ActionFn(967); + // ("," >)? = ",", "*", StarTypedParameter, ("," >)+ => ActionFn(965); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action967::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action965::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11797,14 +11799,14 @@ mod __parse__Top { (4, 14) } 37 => { - // ("," >)? = ",", "*", ("," >)+ => ActionFn(968); + // ("," >)? = ",", "*", ("," >)+ => ActionFn(966); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action968::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action966::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11815,16 +11817,16 @@ mod __parse__Top { __reduce38(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 39 => { - // ("," >) = ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(997); + // ("," >) = ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(995); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action997::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action995::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11832,7 +11834,7 @@ mod __parse__Top { (5, 15) } 40 => { - // ("," >) = ",", "*", ",", KwargParameter => ActionFn(998); + // ("," >) = ",", "*", ",", KwargParameter => ActionFn(996); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -11840,7 +11842,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action998::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action996::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11848,17 +11850,17 @@ mod __parse__Top { (4, 15) } 41 => { - // ("," >) = ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(999); + // ("," >) = ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(997); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action999::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action997::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11866,7 +11868,7 @@ mod __parse__Top { (6, 15) } 42 => { - // ("," >) = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1000); + // ("," >) = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(998); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -11875,7 +11877,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1000::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action998::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11883,14 +11885,14 @@ mod __parse__Top { (5, 15) } 43 => { - // ("," >) = ",", "*", StarUntypedParameter => ActionFn(1001); + // ("," >) = ",", "*", StarUntypedParameter => ActionFn(999); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1001::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action999::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11898,13 +11900,13 @@ mod __parse__Top { (3, 15) } 44 => { - // ("," >) = ",", "*" => ActionFn(1002); + // ("," >) = ",", "*" => ActionFn(1000); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1002::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1000::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11912,15 +11914,15 @@ mod __parse__Top { (2, 15) } 45 => { - // ("," >) = ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1003); + // ("," >) = ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1001); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1003::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1001::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11928,14 +11930,14 @@ mod __parse__Top { (4, 15) } 46 => { - // ("," >) = ",", "*", ("," >)+ => ActionFn(1004); + // ("," >) = ",", "*", ("," >)+ => ActionFn(1002); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1004::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1002::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11943,16 +11945,16 @@ mod __parse__Top { (3, 15) } 47 => { - // ("," >)? = ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1021); + // ("," >)? = ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1019); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1021::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1019::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11960,7 +11962,7 @@ mod __parse__Top { (5, 16) } 48 => { - // ("," >)? = ",", "*", ",", KwargParameter => ActionFn(1022); + // ("," >)? = ",", "*", ",", KwargParameter => ActionFn(1020); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -11968,7 +11970,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1022::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1020::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11976,17 +11978,17 @@ mod __parse__Top { (4, 16) } 49 => { - // ("," >)? = ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1023); + // ("," >)? = ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1021); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1023::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1021::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -11994,7 +11996,7 @@ mod __parse__Top { (6, 16) } 50 => { - // ("," >)? = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1024); + // ("," >)? = ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1022); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -12003,7 +12005,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1024::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1022::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12011,14 +12013,14 @@ mod __parse__Top { (5, 16) } 51 => { - // ("," >)? = ",", "*", StarUntypedParameter => ActionFn(1025); + // ("," >)? = ",", "*", StarUntypedParameter => ActionFn(1023); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1025::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1023::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12026,13 +12028,13 @@ mod __parse__Top { (3, 16) } 52 => { - // ("," >)? = ",", "*" => ActionFn(1026); + // ("," >)? = ",", "*" => ActionFn(1024); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1026::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1024::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12040,15 +12042,15 @@ mod __parse__Top { (2, 16) } 53 => { - // ("," >)? = ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1027); + // ("," >)? = ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1025); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant63(__symbols); + let __sym2 = __pop_Variant65(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1027::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1025::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12056,14 +12058,14 @@ mod __parse__Top { (4, 16) } 54 => { - // ("," >)? = ",", "*", ("," >)+ => ActionFn(1028); + // ("," >)? = ",", "*", ("," >)+ => ActionFn(1026); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1028::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1026::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12392,36 +12394,36 @@ mod __parse__Top { __reduce161(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 162 => { - // Arguments = "(", FunctionArgument, ")" => ActionFn(1502); + // Arguments = "(", FunctionArgument, ")" => ActionFn(1498); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant30(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1502::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1498::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant49(__nt), __end)); + __symbols.push((__start, __Symbol::Variant51(__nt), __end)); (3, 85) } 163 => { - // Arguments = "(", ")" => ActionFn(1503); + // Arguments = "(", ")" => ActionFn(1499); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1503::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1499::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant49(__nt), __end)); + __symbols.push((__start, __Symbol::Variant51(__nt), __end)); (2, 85) } 164 => { - // Arguments = "(", ( ",")+, FunctionArgument, ")" => ActionFn(1504); + // Arguments = "(", ( ",")+, FunctionArgument, ")" => ActionFn(1500); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant30(__symbols); @@ -12429,26 +12431,26 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1504::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1500::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant49(__nt), __end)); + __symbols.push((__start, __Symbol::Variant51(__nt), __end)); (4, 85) } 165 => { - // Arguments = "(", ( ",")+, ")" => ActionFn(1505); + // Arguments = "(", ( ",")+, ")" => ActionFn(1501); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant31(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1505::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1501::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant49(__nt), __end)); + __symbols.push((__start, __Symbol::Variant51(__nt), __end)); (3, 85) } 166 => { @@ -12470,14 +12472,14 @@ mod __parse__Top { __reduce171(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 172 => { - // AsPattern = OrPattern, "as", Identifier => ActionFn(1185); + // AsPattern = OrPattern, "as", Identifier => ActionFn(1195); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant34(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1185::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1195::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12548,7 +12550,7 @@ mod __parse__Top { __reduce190(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 191 => { - // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ",", ")" => ActionFn(1194); + // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ",", ")" => ActionFn(1204); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); @@ -12558,7 +12560,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1194::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1204::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12566,7 +12568,7 @@ mod __parse__Top { (6, 95) } 192 => { - // Atom<"all"> = "(", NamedOrStarExpr, ",", ")" => ActionFn(1195); + // Atom<"all"> = "(", NamedOrStarExpr, ",", ")" => ActionFn(1205); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -12574,7 +12576,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1195::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1205::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12582,7 +12584,7 @@ mod __parse__Top { (4, 95) } 193 => { - // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1196); + // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1206); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -12593,7 +12595,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1196::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1206::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12601,7 +12603,7 @@ mod __parse__Top { (7, 95) } 194 => { - // Atom<"all"> = "(", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1197); + // Atom<"all"> = "(", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1207); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -12610,7 +12612,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1197::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1207::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12618,7 +12620,7 @@ mod __parse__Top { (5, 95) } 195 => { - // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ")" => ActionFn(1198); + // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ")" => ActionFn(1208); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant14(__symbols); @@ -12627,7 +12629,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1198::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1208::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12635,14 +12637,14 @@ mod __parse__Top { (5, 95) } 196 => { - // Atom<"all"> = "(", NamedOrStarExpr, ")" => ActionFn(1199); + // Atom<"all"> = "(", NamedOrStarExpr, ")" => ActionFn(1209); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1199::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1209::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12650,7 +12652,7 @@ mod __parse__Top { (3, 95) } 197 => { - // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ")" => ActionFn(1200); + // Atom<"all"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ")" => ActionFn(1210); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant16(__symbols); @@ -12660,7 +12662,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1200::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1210::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12668,7 +12670,7 @@ mod __parse__Top { (6, 95) } 198 => { - // Atom<"all"> = "(", NamedOrStarExpr, ("," )+, ")" => ActionFn(1201); + // Atom<"all"> = "(", NamedOrStarExpr, ("," )+, ")" => ActionFn(1211); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant16(__symbols); @@ -12676,7 +12678,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1201::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1211::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12693,7 +12695,7 @@ mod __parse__Top { __reduce201(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 202 => { - // Atom<"all"> = "(", "**", Expression<"all">, ")" => ActionFn(1204); + // Atom<"all"> = "(", "**", Expression<"all">, ")" => ActionFn(1215); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant14(__symbols); @@ -12701,7 +12703,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1204::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1215::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12736,11 +12738,11 @@ mod __parse__Top { __reduce211(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 212 => { - // Atom<"no-withitems"> = (@L string @R)+ => ActionFn(728); + // Atom<"no-withitems"> = (@L string @R)+ => ActionFn(729); let __sym0 = __pop_Variant42(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action728::<>(mode, __sym0) { + let __nt = match super::__action729::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12763,7 +12765,7 @@ mod __parse__Top { __reduce217(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 218 => { - // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ",", ")" => ActionFn(1217); + // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ",", ")" => ActionFn(1228); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); @@ -12773,7 +12775,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1217::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1228::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12781,7 +12783,7 @@ mod __parse__Top { (6, 96) } 219 => { - // Atom<"no-withitems"> = "(", NamedOrStarExpr, ",", ")" => ActionFn(1218); + // Atom<"no-withitems"> = "(", NamedOrStarExpr, ",", ")" => ActionFn(1229); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -12789,7 +12791,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1218::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1229::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12797,7 +12799,7 @@ mod __parse__Top { (4, 96) } 220 => { - // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1219); + // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1230); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -12808,7 +12810,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1219::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1230::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12816,7 +12818,7 @@ mod __parse__Top { (7, 96) } 221 => { - // Atom<"no-withitems"> = "(", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1220); + // Atom<"no-withitems"> = "(", NamedOrStarExpr, ("," )+, ",", ")" => ActionFn(1231); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -12825,7 +12827,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1220::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1231::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12833,7 +12835,7 @@ mod __parse__Top { (5, 96) } 222 => { - // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ")" => ActionFn(1221); + // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ")" => ActionFn(1232); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant14(__symbols); @@ -12842,7 +12844,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1221::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1232::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12850,14 +12852,14 @@ mod __parse__Top { (5, 96) } 223 => { - // Atom<"no-withitems"> = "(", NamedOrStarExpr, ")" => ActionFn(1222); + // Atom<"no-withitems"> = "(", NamedOrStarExpr, ")" => ActionFn(1233); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1222::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1233::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12865,7 +12867,7 @@ mod __parse__Top { (3, 96) } 224 => { - // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ")" => ActionFn(1223); + // Atom<"no-withitems"> = "(", OneOrMore>, ",", NamedOrStarExpr, ("," )+, ")" => ActionFn(1234); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant16(__symbols); @@ -12875,7 +12877,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1223::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1234::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12883,7 +12885,7 @@ mod __parse__Top { (6, 96) } 225 => { - // Atom<"no-withitems"> = "(", NamedOrStarExpr, ("," )+, ")" => ActionFn(1224); + // Atom<"no-withitems"> = "(", NamedOrStarExpr, ("," )+, ")" => ActionFn(1235); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant16(__symbols); @@ -12891,7 +12893,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1224::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1235::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -12908,7 +12910,7 @@ mod __parse__Top { __reduce228(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 229 => { - // Atom<"no-withitems"> = "(", "**", Expression<"all">, ")" => ActionFn(1227); + // Atom<"no-withitems"> = "(", "**", Expression<"all">, ")" => ActionFn(1239); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant14(__symbols); @@ -12916,7 +12918,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1227::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1239::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13542,11 +13544,11 @@ mod __parse__Top { __reduce435(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 436 => { - // IpyEscapeCommandExpr = ipy_escape_command => ActionFn(1288); + // IpyEscapeCommandExpr = ipy_escape_command => ActionFn(1300); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1288::<>(mode, __sym0) { + let __nt = match super::__action1300::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13554,11 +13556,11 @@ mod __parse__Top { (1, 163) } 437 => { - // IpyEscapeCommandStatement = ipy_escape_command => ActionFn(1289); + // IpyEscapeCommandStatement = ipy_escape_command => ActionFn(1301); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1289::<>(mode, __sym0) { + let __nt = match super::__action1301::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13566,13 +13568,13 @@ mod __parse__Top { (1, 164) } 438 => { - // IpyHelpEndEscapeCommandStatement = Expression<"all">, ("?")+ => ActionFn(1290); + // IpyHelpEndEscapeCommandStatement = Expression<"all">, ("?")+ => ActionFn(1302); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant21(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1290::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1302::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13592,15 +13594,15 @@ mod __parse__Top { __reduce442(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 443 => { - // LambdaDef = "lambda", ParameterList, ":", Test<"all"> => ActionFn(1672); + // LambdaDef = "lambda", ParameterList, ":", Test<"all"> => ActionFn(1668); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant45(__symbols); + let __sym1 = __pop_Variant47(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1672::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1668::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13608,14 +13610,14 @@ mod __parse__Top { (4, 168) } 444 => { - // LambdaDef = "lambda", ":", Test<"all"> => ActionFn(1673); + // LambdaDef = "lambda", ":", Test<"all"> => ActionFn(1669); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1673::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1669::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13650,11 +13652,11 @@ mod __parse__Top { __reduce453(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 454 => { - // LiteralPattern = (@L string @R)+ => ActionFn(1297); + // LiteralPattern = (@L string @R)+ => ActionFn(1309); let __sym0 = __pop_Variant42(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1297::<>(mode, __sym0) { + let __nt = match super::__action1309::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -13680,15 +13682,15 @@ mod __parse__Top { __reduce460(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 461 => { - // MappingKey = (@L string @R)+ => ActionFn(818); + // MappingKey = (@L string @R)+ => ActionFn(820); let __sym0 = __pop_Variant42(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action818::<>(mode, __sym0) { + let __nt = match super::__action820::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } 462 => { @@ -13944,955 +13946,955 @@ mod __parse__Top { __reduce545(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 546 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1552); + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1548); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1552::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1548::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } 547 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1553); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1549); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant0(__symbols); let __sym7 = __pop_Variant8(__symbols); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1549::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 210) + } + 548 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1550); + assert!(__symbols.len() >= 10); + let __sym9 = __pop_Variant0(__symbols); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym9.2; + let __nt = match super::__action1550::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (10, 210) + } + 549 => { + // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter, "," => ActionFn(1551); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant8(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1551::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 210) + } + 550 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter, "," => ActionFn(1552); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1552::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 210) + } + 551 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter, "," => ActionFn(1553); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym8.2; let __nt = match super::__action1553::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 210) - } - 548 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1554); - assert!(__symbols.len() >= 10); - let __sym9 = __pop_Variant0(__symbols); - let __sym8 = __pop_Variant8(__symbols); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym9.2; - let __nt = match super::__action1554::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (10, 210) - } - 549 => { - // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter, "," => ActionFn(1555); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant8(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1555::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 210) - } - 550 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter, "," => ActionFn(1556); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant8(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1556::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 210) - } - 551 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter, "," => ActionFn(1557); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1557::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (9, 210) } 552 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1558); + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1554); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant8(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = match super::__action1558::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + let __nt = match super::__action1554::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 210) } 553 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1559); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1555); assert!(__symbols.len() >= 10); let __sym9 = __pop_Variant0(__symbols); let __sym8 = __pop_Variant8(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym9.2; + let __nt = match super::__action1555::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (10, 210) + } + 554 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1556); + assert!(__symbols.len() >= 11); + let __sym10 = __pop_Variant0(__symbols); + let __sym9 = __pop_Variant8(__symbols); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym10.2; + let __nt = match super::__action1556::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9, __sym10) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (11, 210) + } + 555 => { + // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1557); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant8(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym6.2; + let __nt = match super::__action1557::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 210) + } + 556 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1558); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant11(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1558::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 210) + } + 557 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1559); + assert!(__symbols.len() >= 10); + let __sym9 = __pop_Variant0(__symbols); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant11(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym9.2; let __nt = match super::__action1559::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (10, 210) } - 554 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1560); - assert!(__symbols.len() >= 11); - let __sym10 = __pop_Variant0(__symbols); - let __sym9 = __pop_Variant8(__symbols); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); + 558 => { + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, "," => ActionFn(1560); + assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym10.2; - let __nt = match super::__action1560::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9, __sym10) { + let __end = __sym4.2; + let __nt = match super::__action1560::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (11, 210) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 210) } - 555 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1561); + 559 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, "," => ActionFn(1561); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; let __nt = match super::__action1561::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } - 556 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1562); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant11(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1562::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 210) - } - 557 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1563); - assert!(__symbols.len() >= 10); - let __sym9 = __pop_Variant0(__symbols); - let __sym8 = __pop_Variant8(__symbols); + 560 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, "," => ActionFn(1562); + assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym9.2; - let __nt = match super::__action1563::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + let __end = __sym7.2; + let __nt = match super::__action1562::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (10, 210) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 210) } - 558 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, "," => ActionFn(1564); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant63(__symbols); + 561 => { + // ParameterList = OneOrMore>, ",", "*", "," => ActionFn(1563); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1564::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __end = __sym3.2; + let __nt = match super::__action1563::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 210) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (4, 210) } - 559 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, "," => ActionFn(1565); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant63(__symbols); + 562 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", "," => ActionFn(1564); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1564::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 210) + } + 563 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", "," => ActionFn(1565); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; let __nt = match super::__action1565::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 210) - } - 560 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, "," => ActionFn(1566); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1566::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 210) - } - 561 => { - // ParameterList = OneOrMore>, ",", "*", "," => ActionFn(1567); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym3.2; - let __nt = match super::__action1567::<>(mode, __sym0, __sym1, __sym2, __sym3) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (4, 210) - } - 562 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", "," => ActionFn(1568); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1568::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 210) - } - 563 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", "," => ActionFn(1569); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1569::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } 564 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+, "," => ActionFn(1570); + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+, "," => ActionFn(1566); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1570::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1566::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } 565 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+, "," => ActionFn(1571); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+, "," => ActionFn(1567); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1567::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 210) + } + 566 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+, "," => ActionFn(1568); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1568::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 210) + } + 567 => { + // ParameterList = OneOrMore>, ",", "*", ("," >)+, "," => ActionFn(1569); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym4.2; + let __nt = match super::__action1569::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 210) + } + 568 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, "," => ActionFn(1570); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant11(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym6.2; + let __nt = match super::__action1570::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 210) + } + 569 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, "," => ActionFn(1571); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant11(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; let __nt = match super::__action1571::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 210) - } - 566 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+, "," => ActionFn(1572); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1572::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 210) - } - 567 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+, "," => ActionFn(1573); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1573::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 210) - } - 568 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, "," => ActionFn(1574); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant11(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1574::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 210) - } - 569 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, "," => ActionFn(1575); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1575::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 210) } 570 => { - // ParameterList = OneOrMore>, "," => ActionFn(1576); + // ParameterList = OneOrMore>, "," => ActionFn(1572); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1576::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1572::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 210) } 571 => { - // ParameterList = OneOrMore>, ",", "/", "," => ActionFn(1577); + // ParameterList = OneOrMore>, ",", "/", "," => ActionFn(1573); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1577::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1573::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 572 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, "," => ActionFn(1578); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, "," => ActionFn(1574); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym4.2; + let __nt = match super::__action1574::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 210) + } + 573 => { + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(1575); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant8(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant65(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1575::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 210) + } + 574 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(1576); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant65(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1576::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 210) + } + 575 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(1577); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1577::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 210) + } + 576 => { + // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter => ActionFn(1578); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant8(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym4.2; let __nt = match super::__action1578::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 210) } - 573 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(1579); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant8(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant63(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1579::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 210) - } - 574 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(1580); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant63(__symbols); + 577 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter => ActionFn(1579); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym6.2; + let __nt = match super::__action1579::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 210) + } + 578 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter => ActionFn(1580); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; let __nt = match super::__action1580::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 210) - } - 575 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ",", KwargParameter => ActionFn(1581); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant8(__symbols); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1581::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 210) - } - 576 => { - // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter => ActionFn(1582); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant8(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1582::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 210) - } - 577 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter => ActionFn(1583); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant8(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1583::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 210) - } - 578 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter => ActionFn(1584); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1584::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 210) } 579 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1585); + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1581); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant8(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1585::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1581::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } 580 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1586); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1582); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant8(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1582::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 210) + } + 581 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1583); + assert!(__symbols.len() >= 10); + let __sym9 = __pop_Variant8(__symbols); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym9.2; + let __nt = match super::__action1583::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (10, 210) + } + 582 => { + // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1584); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant8(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1584::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 210) + } + 583 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1585); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant11(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1585::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 210) + } + 584 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1586); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant11(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym8.2; let __nt = match super::__action1586::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (9, 210) } - 581 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1587); - assert!(__symbols.len() >= 10); - let __sym9 = __pop_Variant8(__symbols); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + 585 => { + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter => ActionFn(1587); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym9.2; - let __nt = match super::__action1587::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + let __end = __sym3.2; + let __nt = match super::__action1587::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (10, 210) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (4, 210) } - 582 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1588); + 586 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter => ActionFn(1588); assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; let __nt = match super::__action1588::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } - 583 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1589); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant11(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1589::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 210) - } - 584 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1590); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant8(__symbols); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant11(__symbols); + 587 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter => ActionFn(1589); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant65(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1590::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + let __end = __sym6.2; + let __nt = match super::__action1589::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 210) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 210) } - 585 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter => ActionFn(1591); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant63(__symbols); + 588 => { + // ParameterList = OneOrMore>, ",", "*" => ActionFn(1590); + assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym3.2; - let __nt = match super::__action1591::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __end = __sym2.2; + let __nt = match super::__action1590::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (4, 210) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (3, 210) } - 586 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter => ActionFn(1592); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant63(__symbols); + 589 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*" => ActionFn(1591); + assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym4.2; + let __nt = match super::__action1591::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 210) + } + 590 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*" => ActionFn(1592); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; let __nt = match super::__action1592::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 210) - } - 587 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter => ActionFn(1593); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1593::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 210) - } - 588 => { - // ParameterList = OneOrMore>, ",", "*" => ActionFn(1594); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym2.2; - let __nt = match super::__action1594::<>(mode, __sym0, __sym1, __sym2) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (3, 210) - } - 589 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*" => ActionFn(1595); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1595::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 210) - } - 590 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*" => ActionFn(1596); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1596::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } 591 => { - // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+ => ActionFn(1597); + // ParameterList = OneOrMore>, ",", "*", StarTypedParameter, ("," >)+ => ActionFn(1593); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1597::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1593::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 210) } 592 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+ => ActionFn(1598); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarTypedParameter, ("," >)+ => ActionFn(1594); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1598::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1594::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } 593 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+ => ActionFn(1599); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarTypedParameter, ("," >)+ => ActionFn(1595); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); + let __sym6 = __pop_Variant65(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = match super::__action1599::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + let __nt = match super::__action1595::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 210) } 594 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+ => ActionFn(1600); + // ParameterList = OneOrMore>, ",", "*", ("," >)+ => ActionFn(1596); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1600::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1596::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 595 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+ => ActionFn(1601); + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+ => ActionFn(1597); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant11(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1601::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1597::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } 596 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+ => ActionFn(1602); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+ => ActionFn(1598); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant11(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -14900,95 +14902,95 @@ mod __parse__Top { let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1602::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1598::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } 597 => { - // ParameterList = OneOrMore> => ActionFn(1603); - let __sym0 = __pop_Variant80(__symbols); + // ParameterList = OneOrMore> => ActionFn(1599); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1603::<>(mode, __sym0) { + let __nt = match super::__action1599::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 210) } 598 => { - // ParameterList = OneOrMore>, ",", "/" => ActionFn(1604); + // ParameterList = OneOrMore>, ",", "/" => ActionFn(1600); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1604::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1600::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 210) } 599 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+ => ActionFn(1605); + // ParameterList = OneOrMore>, ",", "/", ("," >)+ => ActionFn(1601); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1605::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1601::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 600 => { - // ParameterList = OneOrMore>, ",", KwargParameter, "," => ActionFn(1606); + // ParameterList = OneOrMore>, ",", KwargParameter, "," => ActionFn(1602); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1606::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1602::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 601 => { - // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter, "," => ActionFn(1607); + // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter, "," => ActionFn(1603); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1607::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1603::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } 602 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter, "," => ActionFn(1608); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter, "," => ActionFn(1604); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant8(__symbols); @@ -14996,85 +14998,85 @@ mod __parse__Top { let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1608::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1604::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 210) } 603 => { - // ParameterList = OneOrMore>, ",", KwargParameter => ActionFn(1609); + // ParameterList = OneOrMore>, ",", KwargParameter => ActionFn(1605); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1609::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1605::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 210) } 604 => { - // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter => ActionFn(1610); + // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter => ActionFn(1606); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1610::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1606::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 210) } 605 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter => ActionFn(1611); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter => ActionFn(1607); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1611::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1607::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } 606 => { - // ParameterList = "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1342); + // ParameterList = "*", StarTypedParameter, ",", KwargParameter, "," => ActionFn(1354); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1342::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1354::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 210) } 607 => { - // ParameterList = "*", ",", KwargParameter, "," => ActionFn(1343); + // ParameterList = "*", ",", KwargParameter, "," => ActionFn(1355); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant8(__symbols); @@ -15082,33 +15084,33 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1343::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1355::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 608 => { - // ParameterList = "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1344); + // ParameterList = "*", StarTypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1356); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1344::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1356::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 210) } 609 => { - // ParameterList = "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1345); + // ParameterList = "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1357); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant8(__symbols); @@ -15117,123 +15119,123 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1345::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1357::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 210) } 610 => { - // ParameterList = "*", StarTypedParameter, "," => ActionFn(1346); + // ParameterList = "*", StarTypedParameter, "," => ActionFn(1358); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1346::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1358::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 210) } 611 => { - // ParameterList = "*", "," => ActionFn(1347); + // ParameterList = "*", "," => ActionFn(1359); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1347::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1359::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 210) } 612 => { - // ParameterList = "*", StarTypedParameter, ("," >)+, "," => ActionFn(1348); + // ParameterList = "*", StarTypedParameter, ("," >)+, "," => ActionFn(1360); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1348::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1360::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 613 => { - // ParameterList = "*", ("," >)+, "," => ActionFn(1349); + // ParameterList = "*", ("," >)+, "," => ActionFn(1361); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant11(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1349::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1361::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 210) } 614 => { - // ParameterList = "*", StarTypedParameter, ",", KwargParameter => ActionFn(1350); + // ParameterList = "*", StarTypedParameter, ",", KwargParameter => ActionFn(1362); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1350::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1362::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 615 => { - // ParameterList = "*", ",", KwargParameter => ActionFn(1351); + // ParameterList = "*", ",", KwargParameter => ActionFn(1363); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1351::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1363::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 210) } 616 => { - // ParameterList = "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1352); + // ParameterList = "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1364); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1352::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1364::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 210) } 617 => { - // ParameterList = "*", ("," >)+, ",", KwargParameter => ActionFn(1353); + // ParameterList = "*", ("," >)+, ",", KwargParameter => ActionFn(1365); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -15241,66 +15243,66 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1353::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1365::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 210) } 618 => { - // ParameterList = "*", StarTypedParameter => ActionFn(1354); + // ParameterList = "*", StarTypedParameter => ActionFn(1366); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1354::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1366::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 210) } 619 => { - // ParameterList = "*" => ActionFn(1355); + // ParameterList = "*" => ActionFn(1367); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1355::<>(mode, __sym0) { + let __nt = match super::__action1367::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 210) } 620 => { - // ParameterList = "*", StarTypedParameter, ("," >)+ => ActionFn(1356); + // ParameterList = "*", StarTypedParameter, ("," >)+ => ActionFn(1368); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1356::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1368::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 210) } 621 => { - // ParameterList = "*", ("," >)+ => ActionFn(1357); + // ParameterList = "*", ("," >)+ => ActionFn(1369); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant11(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1357::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1369::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 210) } 622 => { @@ -15310,955 +15312,955 @@ mod __parse__Top { __reduce623(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 624 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1612); + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1608); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1612::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1608::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } 625 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1613); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1609); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant0(__symbols); let __sym7 = __pop_Variant8(__symbols); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1609::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 211) + } + 626 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1610); + assert!(__symbols.len() >= 10); + let __sym9 = __pop_Variant0(__symbols); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym9.2; + let __nt = match super::__action1610::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (10, 211) + } + 627 => { + // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter, "," => ActionFn(1611); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant8(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1611::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 211) + } + 628 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter, "," => ActionFn(1612); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1612::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 211) + } + 629 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter, "," => ActionFn(1613); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym8.2; let __nt = match super::__action1613::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 211) - } - 626 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1614); - assert!(__symbols.len() >= 10); - let __sym9 = __pop_Variant0(__symbols); - let __sym8 = __pop_Variant8(__symbols); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym9.2; - let __nt = match super::__action1614::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (10, 211) - } - 627 => { - // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter, "," => ActionFn(1615); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant8(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1615::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 211) - } - 628 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter, "," => ActionFn(1616); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant8(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1616::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 211) - } - 629 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter, "," => ActionFn(1617); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1617::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (9, 211) } 630 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1618); + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1614); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant8(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = match super::__action1618::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + let __nt = match super::__action1614::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 211) } 631 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1619); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1615); assert!(__symbols.len() >= 10); let __sym9 = __pop_Variant0(__symbols); let __sym8 = __pop_Variant8(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym9.2; + let __nt = match super::__action1615::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (10, 211) + } + 632 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1616); + assert!(__symbols.len() >= 11); + let __sym10 = __pop_Variant0(__symbols); + let __sym9 = __pop_Variant8(__symbols); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym10.2; + let __nt = match super::__action1616::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9, __sym10) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (11, 211) + } + 633 => { + // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1617); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant8(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym6.2; + let __nt = match super::__action1617::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 211) + } + 634 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1618); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant11(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1618::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 211) + } + 635 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1619); + assert!(__symbols.len() >= 10); + let __sym9 = __pop_Variant0(__symbols); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant11(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym9.2; let __nt = match super::__action1619::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (10, 211) } - 632 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1620); - assert!(__symbols.len() >= 11); - let __sym10 = __pop_Variant0(__symbols); - let __sym9 = __pop_Variant8(__symbols); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); + 636 => { + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, "," => ActionFn(1620); + assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym10.2; - let __nt = match super::__action1620::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9, __sym10) { + let __end = __sym4.2; + let __nt = match super::__action1620::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (11, 211) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 211) } - 633 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1621); + 637 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, "," => ActionFn(1621); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; let __nt = match super::__action1621::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } - 634 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1622); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant11(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1622::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 211) - } - 635 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1623); - assert!(__symbols.len() >= 10); - let __sym9 = __pop_Variant0(__symbols); - let __sym8 = __pop_Variant8(__symbols); + 638 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, "," => ActionFn(1622); + assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym9.2; - let __nt = match super::__action1623::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + let __end = __sym7.2; + let __nt = match super::__action1622::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (10, 211) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 211) } - 636 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, "," => ActionFn(1624); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant63(__symbols); + 639 => { + // ParameterList = OneOrMore>, ",", "*", "," => ActionFn(1623); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1624::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __end = __sym3.2; + let __nt = match super::__action1623::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 211) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (4, 211) } - 637 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, "," => ActionFn(1625); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant63(__symbols); + 640 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", "," => ActionFn(1624); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1624::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 211) + } + 641 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", "," => ActionFn(1625); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; let __nt = match super::__action1625::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 211) - } - 638 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, "," => ActionFn(1626); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1626::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 211) - } - 639 => { - // ParameterList = OneOrMore>, ",", "*", "," => ActionFn(1627); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym3.2; - let __nt = match super::__action1627::<>(mode, __sym0, __sym1, __sym2, __sym3) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (4, 211) - } - 640 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", "," => ActionFn(1628); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1628::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 211) - } - 641 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", "," => ActionFn(1629); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1629::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } 642 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1630); + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1626); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1630::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1626::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } 643 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1631); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1627); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1627::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 211) + } + 644 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1628); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1628::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 211) + } + 645 => { + // ParameterList = OneOrMore>, ",", "*", ("," >)+, "," => ActionFn(1629); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym4.2; + let __nt = match super::__action1629::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 211) + } + 646 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, "," => ActionFn(1630); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant11(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym6.2; + let __nt = match super::__action1630::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 211) + } + 647 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, "," => ActionFn(1631); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant11(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; let __nt = match super::__action1631::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 211) - } - 644 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1632); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1632::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 211) - } - 645 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+, "," => ActionFn(1633); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1633::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 211) - } - 646 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, "," => ActionFn(1634); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant11(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1634::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 211) - } - 647 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, "," => ActionFn(1635); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1635::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 211) } 648 => { - // ParameterList = OneOrMore>, "," => ActionFn(1636); + // ParameterList = OneOrMore>, "," => ActionFn(1632); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1636::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1632::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 211) } 649 => { - // ParameterList = OneOrMore>, ",", "/", "," => ActionFn(1637); + // ParameterList = OneOrMore>, ",", "/", "," => ActionFn(1633); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1637::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1633::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 650 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, "," => ActionFn(1638); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, "," => ActionFn(1634); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym4.2; + let __nt = match super::__action1634::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 211) + } + 651 => { + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1635); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant8(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant65(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1635::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 211) + } + 652 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1636); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant65(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1636::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 211) + } + 653 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1637); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1637::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 211) + } + 654 => { + // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter => ActionFn(1638); + assert!(__symbols.len() >= 5); + let __sym4 = __pop_Variant8(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym4.2; let __nt = match super::__action1638::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 211) } - 651 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1639); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant8(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant63(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1639::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 211) - } - 652 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1640); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant63(__symbols); + 655 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter => ActionFn(1639); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym6.2; + let __nt = match super::__action1639::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 211) + } + 656 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter => ActionFn(1640); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; let __nt = match super::__action1640::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 211) - } - 653 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1641); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant8(__symbols); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1641::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 211) - } - 654 => { - // ParameterList = OneOrMore>, ",", "*", ",", KwargParameter => ActionFn(1642); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant8(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1642::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 211) - } - 655 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ",", KwargParameter => ActionFn(1643); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant8(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1643::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 211) - } - 656 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ",", KwargParameter => ActionFn(1644); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1644::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 211) } 657 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1645); + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1641); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant8(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1645::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1641::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } 658 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1646); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1642); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant8(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym8.2; + let __nt = match super::__action1642::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (9, 211) + } + 659 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1643); + assert!(__symbols.len() >= 10); + let __sym9 = __pop_Variant8(__symbols); + let __sym8 = __pop_Variant0(__symbols); + let __sym7 = __pop_Variant11(__symbols); + let __sym6 = __pop_Variant65(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym9.2; + let __nt = match super::__action1643::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (10, 211) + } + 660 => { + // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1644); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant8(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym5.2; + let __nt = match super::__action1644::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (6, 211) + } + 661 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1645); + assert!(__symbols.len() >= 8); + let __sym7 = __pop_Variant8(__symbols); + let __sym6 = __pop_Variant0(__symbols); + let __sym5 = __pop_Variant11(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant0(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym7.2; + let __nt = match super::__action1645::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (8, 211) + } + 662 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1646); + assert!(__symbols.len() >= 9); + let __sym8 = __pop_Variant8(__symbols); + let __sym7 = __pop_Variant0(__symbols); + let __sym6 = __pop_Variant11(__symbols); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym8.2; let __nt = match super::__action1646::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (9, 211) } - 659 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1647); - assert!(__symbols.len() >= 10); - let __sym9 = __pop_Variant8(__symbols); - let __sym8 = __pop_Variant0(__symbols); - let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + 663 => { + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter => ActionFn(1647); + assert!(__symbols.len() >= 4); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym9.2; - let __nt = match super::__action1647::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9) { + let __end = __sym3.2; + let __nt = match super::__action1647::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (10, 211) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (4, 211) } - 660 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1648); + 664 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter => ActionFn(1648); assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant8(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); + let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; let __nt = match super::__action1648::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } - 661 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1649); - assert!(__symbols.len() >= 8); - let __sym7 = __pop_Variant8(__symbols); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant11(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym7.2; - let __nt = match super::__action1649::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (8, 211) - } - 662 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+, ",", KwargParameter => ActionFn(1650); - assert!(__symbols.len() >= 9); - let __sym8 = __pop_Variant8(__symbols); - let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant11(__symbols); + 665 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter => ActionFn(1649); + assert!(__symbols.len() >= 7); + let __sym6 = __pop_Variant65(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym8.2; - let __nt = match super::__action1650::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8) { + let __end = __sym6.2; + let __nt = match super::__action1649::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (9, 211) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (7, 211) } - 663 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter => ActionFn(1651); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant63(__symbols); + 666 => { + // ParameterList = OneOrMore>, ",", "*" => ActionFn(1650); + assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; - let __end = __sym3.2; - let __nt = match super::__action1651::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __end = __sym2.2; + let __nt = match super::__action1650::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (4, 211) + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (3, 211) } - 664 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter => ActionFn(1652); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant63(__symbols); + 667 => { + // ParameterList = OneOrMore>, ",", "/", ",", "*" => ActionFn(1651); + assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); + let __start = __sym0.0; + let __end = __sym4.2; + let __nt = match super::__action1651::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }; + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + (5, 211) + } + 668 => { + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*" => ActionFn(1652); + assert!(__symbols.len() >= 6); + let __sym5 = __pop_Variant0(__symbols); + let __sym4 = __pop_Variant0(__symbols); + let __sym3 = __pop_Variant11(__symbols); + let __sym2 = __pop_Variant0(__symbols); + let __sym1 = __pop_Variant0(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; let __nt = match super::__action1652::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (6, 211) - } - 665 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter => ActionFn(1653); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant63(__symbols); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym6.2; - let __nt = match super::__action1653::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (7, 211) - } - 666 => { - // ParameterList = OneOrMore>, ",", "*" => ActionFn(1654); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym2.2; - let __nt = match super::__action1654::<>(mode, __sym0, __sym1, __sym2) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (3, 211) - } - 667 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*" => ActionFn(1655); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym4.2; - let __nt = match super::__action1655::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); - (5, 211) - } - 668 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*" => ActionFn(1656); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant11(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); - let __start = __sym0.0; - let __end = __sym5.2; - let __nt = match super::__action1656::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } 669 => { - // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1657); + // ParameterList = OneOrMore>, ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1653); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant11(__symbols); - let __sym3 = __pop_Variant63(__symbols); + let __sym3 = __pop_Variant65(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1657::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1653::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 211) } 670 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1658); + // ParameterList = OneOrMore>, ",", "/", ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1654); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant11(__symbols); - let __sym5 = __pop_Variant63(__symbols); + let __sym5 = __pop_Variant65(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1658::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1654::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } 671 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1659); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", StarUntypedParameter, ("," >)+ => ActionFn(1655); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant11(__symbols); - let __sym6 = __pop_Variant63(__symbols); + let __sym6 = __pop_Variant65(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = match super::__action1659::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { + let __nt = match super::__action1655::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (8, 211) } 672 => { - // ParameterList = OneOrMore>, ",", "*", ("," >)+ => ActionFn(1660); + // ParameterList = OneOrMore>, ",", "*", ("," >)+ => ActionFn(1656); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1660::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1656::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 673 => { - // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+ => ActionFn(1661); + // ParameterList = OneOrMore>, ",", "/", ",", "*", ("," >)+ => ActionFn(1657); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant11(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1661::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1657::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } 674 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+ => ActionFn(1662); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", "*", ("," >)+ => ActionFn(1658); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant11(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -16266,95 +16268,95 @@ mod __parse__Top { let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1662::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1658::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } 675 => { - // ParameterList = OneOrMore> => ActionFn(1663); - let __sym0 = __pop_Variant80(__symbols); + // ParameterList = OneOrMore> => ActionFn(1659); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1663::<>(mode, __sym0) { + let __nt = match super::__action1659::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 211) } 676 => { - // ParameterList = OneOrMore>, ",", "/" => ActionFn(1664); + // ParameterList = OneOrMore>, ",", "/" => ActionFn(1660); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1664::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1660::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 211) } 677 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+ => ActionFn(1665); + // ParameterList = OneOrMore>, ",", "/", ("," >)+ => ActionFn(1661); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1665::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1661::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 678 => { - // ParameterList = OneOrMore>, ",", KwargParameter, "," => ActionFn(1666); + // ParameterList = OneOrMore>, ",", KwargParameter, "," => ActionFn(1662); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1666::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1662::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 679 => { - // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter, "," => ActionFn(1667); + // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter, "," => ActionFn(1663); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1667::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1663::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } 680 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter, "," => ActionFn(1668); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter, "," => ActionFn(1664); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant8(__symbols); @@ -16362,85 +16364,85 @@ mod __parse__Top { let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = match super::__action1668::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { + let __nt = match super::__action1664::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (7, 211) } 681 => { - // ParameterList = OneOrMore>, ",", KwargParameter => ActionFn(1669); + // ParameterList = OneOrMore>, ",", KwargParameter => ActionFn(1665); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1669::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1665::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 211) } 682 => { - // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter => ActionFn(1670); + // ParameterList = OneOrMore>, ",", "/", ",", KwargParameter => ActionFn(1666); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1670::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1666::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 211) } 683 => { - // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter => ActionFn(1671); + // ParameterList = OneOrMore>, ",", "/", ("," >)+, ",", KwargParameter => ActionFn(1667); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant8(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1671::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1667::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } 684 => { - // ParameterList = "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1380); + // ParameterList = "*", StarUntypedParameter, ",", KwargParameter, "," => ActionFn(1392); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1380::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1392::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 211) } 685 => { - // ParameterList = "*", ",", KwargParameter, "," => ActionFn(1381); + // ParameterList = "*", ",", KwargParameter, "," => ActionFn(1393); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant8(__symbols); @@ -16448,33 +16450,33 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1381::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1393::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 686 => { - // ParameterList = "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1382); + // ParameterList = "*", StarUntypedParameter, ("," >)+, ",", KwargParameter, "," => ActionFn(1394); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = match super::__action1382::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { + let __nt = match super::__action1394::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (6, 211) } 687 => { - // ParameterList = "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1383); + // ParameterList = "*", ("," >)+, ",", KwargParameter, "," => ActionFn(1395); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant8(__symbols); @@ -16483,123 +16485,123 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1383::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1395::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 211) } 688 => { - // ParameterList = "*", StarUntypedParameter, "," => ActionFn(1384); + // ParameterList = "*", StarUntypedParameter, "," => ActionFn(1396); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1384::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1396::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 211) } 689 => { - // ParameterList = "*", "," => ActionFn(1385); + // ParameterList = "*", "," => ActionFn(1397); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1385::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1397::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 211) } 690 => { - // ParameterList = "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1386); + // ParameterList = "*", StarUntypedParameter, ("," >)+, "," => ActionFn(1398); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1386::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1398::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 691 => { - // ParameterList = "*", ("," >)+, "," => ActionFn(1387); + // ParameterList = "*", ("," >)+, "," => ActionFn(1399); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant11(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1387::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1399::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 211) } 692 => { - // ParameterList = "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1388); + // ParameterList = "*", StarUntypedParameter, ",", KwargParameter => ActionFn(1400); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1388::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1400::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 693 => { - // ParameterList = "*", ",", KwargParameter => ActionFn(1389); + // ParameterList = "*", ",", KwargParameter => ActionFn(1401); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1389::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1401::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 211) } 694 => { - // ParameterList = "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1390); + // ParameterList = "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(1402); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action1390::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action1402::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (5, 211) } 695 => { - // ParameterList = "*", ("," >)+, ",", KwargParameter => ActionFn(1391); + // ParameterList = "*", ("," >)+, ",", KwargParameter => ActionFn(1403); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -16607,66 +16609,66 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action1391::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action1403::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (4, 211) } 696 => { - // ParameterList = "*", StarUntypedParameter => ActionFn(1392); + // ParameterList = "*", StarUntypedParameter => ActionFn(1404); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1392::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1404::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 211) } 697 => { - // ParameterList = "*" => ActionFn(1393); + // ParameterList = "*" => ActionFn(1405); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action1393::<>(mode, __sym0) { + let __nt = match super::__action1405::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 211) } 698 => { - // ParameterList = "*", StarUntypedParameter, ("," >)+ => ActionFn(1394); + // ParameterList = "*", StarUntypedParameter, ("," >)+ => ActionFn(1406); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1394::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1406::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 211) } 699 => { - // ParameterList = "*", ("," >)+ => ActionFn(1395); + // ParameterList = "*", ("," >)+ => ActionFn(1407); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant11(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1395::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1407::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 211) } 700 => { @@ -16682,15 +16684,15 @@ mod __parse__Top { __reduce703(mode, __lookahead_start, __symbols, core::marker::PhantomData::<()>) } 704 => { - // ParameterListStarArgs = "*", StarTypedParameter, ",", KwargParameter => ActionFn(859); + // ParameterListStarArgs = "*", StarTypedParameter, ",", KwargParameter => ActionFn(861); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action859::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action861::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16698,14 +16700,14 @@ mod __parse__Top { (4, 213) } 705 => { - // ParameterListStarArgs = "*", ",", KwargParameter => ActionFn(860); + // ParameterListStarArgs = "*", ",", KwargParameter => ActionFn(862); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action860::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action862::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16713,16 +16715,16 @@ mod __parse__Top { (3, 213) } 706 => { - // ParameterListStarArgs = "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(861); + // ParameterListStarArgs = "*", StarTypedParameter, ("," >)+, ",", KwargParameter => ActionFn(863); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action861::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action863::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16730,7 +16732,7 @@ mod __parse__Top { (5, 213) } 707 => { - // ParameterListStarArgs = "*", ("," >)+, ",", KwargParameter => ActionFn(862); + // ParameterListStarArgs = "*", ("," >)+, ",", KwargParameter => ActionFn(864); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -16738,7 +16740,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action862::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action864::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16746,13 +16748,13 @@ mod __parse__Top { (4, 213) } 708 => { - // ParameterListStarArgs = "*", StarTypedParameter => ActionFn(863); + // ParameterListStarArgs = "*", StarTypedParameter => ActionFn(865); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action863::<>(mode, __sym0, __sym1) { + let __nt = match super::__action865::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16760,11 +16762,11 @@ mod __parse__Top { (2, 213) } 709 => { - // ParameterListStarArgs = "*" => ActionFn(864); + // ParameterListStarArgs = "*" => ActionFn(866); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action864::<>(mode, __sym0) { + let __nt = match super::__action866::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16772,14 +16774,14 @@ mod __parse__Top { (1, 213) } 710 => { - // ParameterListStarArgs = "*", StarTypedParameter, ("," >)+ => ActionFn(865); + // ParameterListStarArgs = "*", StarTypedParameter, ("," >)+ => ActionFn(867); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action865::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action867::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16787,13 +16789,13 @@ mod __parse__Top { (3, 213) } 711 => { - // ParameterListStarArgs = "*", ("," >)+ => ActionFn(866); + // ParameterListStarArgs = "*", ("," >)+ => ActionFn(868); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant11(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action866::<>(mode, __sym0, __sym1) { + let __nt = match super::__action868::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16801,15 +16803,15 @@ mod __parse__Top { (2, 213) } 712 => { - // ParameterListStarArgs = "*", StarUntypedParameter, ",", KwargParameter => ActionFn(989); + // ParameterListStarArgs = "*", StarUntypedParameter, ",", KwargParameter => ActionFn(987); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action989::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action987::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16817,14 +16819,14 @@ mod __parse__Top { (4, 214) } 713 => { - // ParameterListStarArgs = "*", ",", KwargParameter => ActionFn(990); + // ParameterListStarArgs = "*", ",", KwargParameter => ActionFn(988); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant8(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action990::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action988::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16832,16 +16834,16 @@ mod __parse__Top { (3, 214) } 714 => { - // ParameterListStarArgs = "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(991); + // ParameterListStarArgs = "*", StarUntypedParameter, ("," >)+, ",", KwargParameter => ActionFn(989); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant8(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = match super::__action991::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { + let __nt = match super::__action989::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16849,7 +16851,7 @@ mod __parse__Top { (5, 214) } 715 => { - // ParameterListStarArgs = "*", ("," >)+, ",", KwargParameter => ActionFn(992); + // ParameterListStarArgs = "*", ("," >)+, ",", KwargParameter => ActionFn(990); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant8(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -16857,7 +16859,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = match super::__action992::<>(mode, __sym0, __sym1, __sym2, __sym3) { + let __nt = match super::__action990::<>(mode, __sym0, __sym1, __sym2, __sym3) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16865,13 +16867,13 @@ mod __parse__Top { (4, 214) } 716 => { - // ParameterListStarArgs = "*", StarUntypedParameter => ActionFn(993); + // ParameterListStarArgs = "*", StarUntypedParameter => ActionFn(991); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action993::<>(mode, __sym0, __sym1) { + let __nt = match super::__action991::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16879,11 +16881,11 @@ mod __parse__Top { (2, 214) } 717 => { - // ParameterListStarArgs = "*" => ActionFn(994); + // ParameterListStarArgs = "*" => ActionFn(992); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = match super::__action994::<>(mode, __sym0) { + let __nt = match super::__action992::<>(mode, __sym0) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16891,14 +16893,14 @@ mod __parse__Top { (1, 214) } 718 => { - // ParameterListStarArgs = "*", StarUntypedParameter, ("," >)+ => ActionFn(995); + // ParameterListStarArgs = "*", StarUntypedParameter, ("," >)+ => ActionFn(993); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant11(__symbols); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action995::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action993::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16906,13 +16908,13 @@ mod __parse__Top { (3, 214) } 719 => { - // ParameterListStarArgs = "*", ("," >)+ => ActionFn(996); + // ParameterListStarArgs = "*", ("," >)+ => ActionFn(994); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant11(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action996::<>(mode, __sym0, __sym1) { + let __nt = match super::__action994::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; @@ -16920,32 +16922,32 @@ mod __parse__Top { (2, 214) } 720 => { - // Parameters = "(", ParameterList, ")" => ActionFn(1490); + // Parameters = "(", ParameterList, ")" => ActionFn(1486); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant45(__symbols); + let __sym1 = __pop_Variant47(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = match super::__action1490::<>(mode, __sym0, __sym1, __sym2) { + let __nt = match super::__action1486::<>(mode, __sym0, __sym1, __sym2) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (3, 215) } 721 => { - // Parameters = "(", ")" => ActionFn(1491); + // Parameters = "(", ")" => ActionFn(1487); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = match super::__action1491::<>(mode, __sym0, __sym1) { + let __nt = match super::__action1487::<>(mode, __sym0, __sym1) { Ok(v) => v, Err(e) => return Some(Err(e)), }; - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 215) } 722 => { @@ -17532,7 +17534,7 @@ mod __parse__Top { } 916 => { // __Top = Top => ActionFn(0); - let __sym0 = __pop_Variant90(__symbols); + let __sym0 = __pop_Variant92(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action0::<>(mode, __sym0); @@ -17571,16 +17573,6 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant59< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (Option>, ast::Expr), TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant59(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } fn __pop_Variant12< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> @@ -17591,13 +17583,23 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant72< + fn __pop_Variant61< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, (Option>, ast::ParenthesizedExpr), TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant61(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant74< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, (Option, Option), TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant72(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant74(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -17624,7 +17626,7 @@ mod __parse__Top { fn __pop_Variant26< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (TextSize, ast::Expr, ast::Suite), TextSize) + ) -> (TextSize, (TextSize, ast::ParenthesizedExpr, ast::Suite), TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant26(__v), __r)) => (__l, __v, __r), @@ -17641,53 +17643,53 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant82< + fn __pop_Variant84< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, (Vec, Vec), TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant82(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant84(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant43< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (ast::CmpOp, ast::Expr), TextSize) + ) -> (TextSize, (ast::CmpOp, ast::ParenthesizedExpr), TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant43(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant60< + fn __pop_Variant78< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (ast::Expr, ast::Expr), TextSize) + ) -> (TextSize, (ast::Expr, ast::Pattern), TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant60(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant78(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant38< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (ast::Expr, ast::Identifier), TextSize) + ) -> (TextSize, (ast::ParenthesizedExpr, ast::Identifier), TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant38(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant76< + fn __pop_Variant62< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, (ast::Expr, ast::Pattern), TextSize) + ) -> (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant76(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant62(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -17731,13 +17733,13 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant87< + fn __pop_Variant89< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Option, TextSize) + ) -> (TextSize, Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant87(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant89(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -17751,136 +17753,136 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant47< + fn __pop_Variant49< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, TextSize, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant47(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant51< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant51(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant61< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec<(Option>, ast::Expr)>, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant61(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant79< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec<(ast::Expr, ast::Pattern)>, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant79(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant69< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant69(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant49(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant53< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) + ) -> (TextSize, Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant53(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant32< + fn __pop_Variant63< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) + ) -> (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant32(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant77< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant77(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant80< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant80(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant52< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant52(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant78< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant78(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant89< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant89(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant63(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant81< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, Vec, TextSize) + ) -> (TextSize, Vec<(ast::Expr, ast::Pattern)>, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant81(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } + fn __pop_Variant71< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant71(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant55< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant55(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant79< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant79(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant82< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant82(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant32< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant32(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant54< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant54(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant80< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant80(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant91< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant91(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant83< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant83(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } fn __pop_Variant39< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> @@ -17914,7 +17916,7 @@ mod __parse__Top { fn __pop_Variant27< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize) + ) -> (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant27(__v), __r)) => (__l, __v, __r), @@ -17924,7 +17926,7 @@ mod __parse__Top { fn __pop_Variant44< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize) + ) -> (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant44(__v), __r)) => (__l, __v, __r), @@ -17941,63 +17943,53 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant86< + fn __pop_Variant88< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, alloc::vec::Vec, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant86(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant88(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant58< + fn __pop_Variant60< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, alloc::vec::Vec, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant58(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant60(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant66< + fn __pop_Variant68< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, alloc::vec::Vec, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant66(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant68(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant16< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, alloc::vec::Vec, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant16(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant71< + fn __pop_Variant73< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, alloc::vec::Vec, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant71(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant73(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant74< + fn __pop_Variant76< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, alloc::vec::Vec, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant74(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant76(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18011,6 +18003,16 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } + fn __pop_Variant16< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, alloc::vec::Vec, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant16(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } fn __pop_Variant35< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> @@ -18051,83 +18053,83 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant68< + fn __pop_Variant70< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Alias, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant68(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant70(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant49< + fn __pop_Variant51< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Arguments, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant49(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant55< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, ast::CmpOp, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant55(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant85< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, ast::Comprehension, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant85(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant56< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, ast::Constant, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant56(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant51(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant57< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, ast::Decorator, TextSize) + ) -> (TextSize, ast::CmpOp, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant57(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant65< + fn __pop_Variant87< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, ast::Comprehension, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant87(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant58< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, ast::Constant, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant58(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant59< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, ast::Decorator, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant59(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant67< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::ExceptHandler, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant65(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant67(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant14< + fn __pop_Variant45< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Expr, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant45(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18141,53 +18143,53 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant70< + fn __pop_Variant72< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Int, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant70(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant72(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant73< + fn __pop_Variant75< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::MatchCase, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant73(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant75(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant90< + fn __pop_Variant92< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Mod, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant90(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant92(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant48< + fn __pop_Variant50< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Operator, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant48(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant50(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant63< + fn __pop_Variant65< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Parameter, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant63(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant65(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18201,13 +18203,23 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant45< + fn __pop_Variant47< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::Parameters, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant45(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant47(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant14< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, ast::ParenthesizedExpr, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant14(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18221,23 +18233,23 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant84< + fn __pop_Variant86< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::PatternArguments, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant84(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant86(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant75< + fn __pop_Variant77< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::PatternKeyword, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant75(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant77(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18261,36 +18273,36 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant91< + fn __pop_Variant93< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, ast::TypeParam, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant91(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant92< - >( - __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, ast::TypeParams, TextSize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant92(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant93(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant94< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, ast::UnaryOp, TextSize) + ) -> (TextSize, ast::TypeParams, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant94(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } + fn __pop_Variant96< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, ast::UnaryOp, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant96(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } fn __pop_Variant17< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> @@ -18301,13 +18313,13 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant67< + fn __pop_Variant69< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant67(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant69(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18341,40 +18353,40 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant88< + fn __pop_Variant90< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, core::option::Option>, TextSize) + ) -> (TextSize, core::option::Option>, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant88(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant90(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant62< + fn __pop_Variant64< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, core::option::Option>, ast::Expr)>>, TextSize) + ) -> (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant62(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant64(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant54< + fn __pop_Variant56< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option>, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant54(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant56(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } fn __pop_Variant33< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> - ) -> (TextSize, core::option::Option>, TextSize) + ) -> (TextSize, core::option::Option>, TextSize) { match __symbols.pop() { Some((__l, __Symbol::Variant33(__v), __r)) => (__l, __v, __r), @@ -18391,23 +18403,23 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant50< + fn __pop_Variant52< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant50(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant52(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant15< + fn __pop_Variant46< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant15(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant46(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18421,33 +18433,43 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant64< + fn __pop_Variant66< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant64(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant66(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant46< + fn __pop_Variant48< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant46(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant48(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } - fn __pop_Variant83< + fn __pop_Variant15< + >( + __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> + ) -> (TextSize, core::option::Option, TextSize) + { + match __symbols.pop() { + Some((__l, __Symbol::Variant15(__v), __r)) => (__l, __v, __r), + _ => __symbol_type_mismatch() + } + } + fn __pop_Variant85< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant83(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant85(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18461,13 +18483,13 @@ mod __parse__Top { _ => __symbol_type_mismatch() } } - fn __pop_Variant93< + fn __pop_Variant95< >( __symbols: &mut alloc::vec::Vec<(TextSize,__Symbol<>,TextSize)> ) -> (TextSize, core::option::Option, TextSize) { match __symbols.pop() { - Some((__l, __Symbol::Variant93(__v), __r)) => (__l, __v, __r), + Some((__l, __Symbol::Variant95(__v), __r)) => (__l, __v, __r), _ => __symbol_type_mismatch() } } @@ -18924,13 +18946,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("," >)? = ",", Test<"all"> => ActionFn(1047); + // ("," >)? = ",", Test<"all"> => ActionFn(1045); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1047::<>(mode, __sym0, __sym1); + let __nt = super::__action1045::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 18) } @@ -19006,13 +19028,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("," )+ = ",", TestOrStarNamedExpr => ActionFn(1050); + // ("," )+ = ",", TestOrStarNamedExpr => ActionFn(1048); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1050::<>(mode, __sym0, __sym1); + let __nt = super::__action1048::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 21) } @@ -19024,14 +19046,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("," )+ = ("," )+, ",", TestOrStarNamedExpr => ActionFn(1051); + // ("," )+ = ("," )+, ",", TestOrStarNamedExpr => ActionFn(1049); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1051::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1049::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (3, 21) } @@ -19092,13 +19114,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("," >)+ = ",", WithItem<"all"> => ActionFn(1060); + // ("," >)+ = ",", WithItem<"all"> => ActionFn(1058); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant17(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1060::<>(mode, __sym0, __sym1); + let __nt = super::__action1058::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (2, 24) } @@ -19110,14 +19132,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("," >)+ = ("," >)+, ",", WithItem<"all"> => ActionFn(1061); + // ("," >)+ = ("," >)+, ",", WithItem<"all"> => ActionFn(1059); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant17(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant18(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1061::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1059::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant18(__nt), __end)); (3, 24) } @@ -19147,13 +19169,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("->" >)? = "->", Test<"all"> => ActionFn(1066); + // ("->" >)? = "->", Test<"all"> => ActionFn(1064); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1066::<>(mode, __sym0, __sym1); + let __nt = super::__action1064::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 26) } @@ -19198,13 +19220,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("." Identifier)+ = ".", Identifier => ActionFn(1071); + // ("." Identifier)+ = ".", Identifier => ActionFn(1069); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1071::<>(mode, __sym0, __sym1); + let __nt = super::__action1069::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (2, 28) } @@ -19216,14 +19238,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("." Identifier)+ = ("." Identifier)+, ".", Identifier => ActionFn(1072); + // ("." Identifier)+ = ("." Identifier)+, ".", Identifier => ActionFn(1070); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant20(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1072::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1070::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant20(__nt), __end)); (3, 28) } @@ -19253,13 +19275,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (":" >)? = ":", Test<"all"> => ActionFn(1073); + // (":" >)? = ":", Test<"all"> => ActionFn(1071); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1073::<>(mode, __sym0, __sym1); + let __nt = super::__action1071::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 30) } @@ -19304,13 +19326,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (":" )? = ":", TestOrStarExpr => ActionFn(1080); + // (":" )? = ":", TestOrStarExpr => ActionFn(1078); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1080::<>(mode, __sym0, __sym1); + let __nt = super::__action1078::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 32) } @@ -19353,11 +19375,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("?")+ = "?" => ActionFn(1083); + // ("?")+ = "?" => ActionFn(1081); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1083::<>(mode, __sym0); + let __nt = super::__action1081::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 34) } @@ -19369,13 +19391,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("?")+ = ("?")+, "?" => ActionFn(1084); + // ("?")+ = ("?")+, "?" => ActionFn(1082); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant21(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1084::<>(mode, __sym0, __sym1); + let __nt = super::__action1082::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 34) } @@ -19434,11 +19456,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("\n")+ = "\n" => ActionFn(1085); + // ("\n")+ = "\n" => ActionFn(1083); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1085::<>(mode, __sym0); + let __nt = super::__action1083::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (1, 37) } @@ -19450,13 +19472,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("\n")+ = ("\n")+, "\n" => ActionFn(1086); + // ("\n")+ = ("\n")+, "\n" => ActionFn(1084); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant21(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1086::<>(mode, __sym0, __sym1); + let __nt = super::__action1084::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant21(__nt), __end)); (2, 37) } @@ -19486,13 +19508,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("as" )? = "as", Identifier => ActionFn(1089); + // ("as" )? = "as", Identifier => ActionFn(1087); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1089::<>(mode, __sym0, __sym1); + let __nt = super::__action1087::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant23(__nt), __end)); (2, 39) } @@ -19538,14 +19560,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("else" ":" )? = "else", ":", Suite => ActionFn(1094); + // ("else" ":" )? = "else", ":", Suite => ActionFn(1092); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1094::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1092::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (3, 41) } @@ -19591,14 +19613,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("finally" ":" )? = "finally", ":", Suite => ActionFn(1105); + // ("finally" ":" )? = "finally", ":", Suite => ActionFn(1103); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1105::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1103::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant25(__nt), __end)); (3, 43) } @@ -19643,13 +19665,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ("from" >)? = "from", Test<"all"> => ActionFn(1115); + // ("from" >)? = "from", Test<"all"> => ActionFn(1113); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1115::<>(mode, __sym0, __sym1); + let __nt = super::__action1113::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (2, 45) } @@ -19727,7 +19749,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (<@L> "elif" ":" )+ = "elif", NamedExpressionTest, ":", Suite => ActionFn(1118); + // (<@L> "elif" ":" )+ = "elif", NamedExpressionTest, ":", Suite => ActionFn(1116); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -19735,7 +19757,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1118::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1116::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (4, 48) } @@ -19747,7 +19769,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (<@L> "elif" ":" )+ = (<@L> "elif" ":" )+, "elif", NamedExpressionTest, ":", Suite => ActionFn(1119); + // (<@L> "elif" ":" )+ = (<@L> "elif" ":" )+, "elif", NamedExpressionTest, ":", Suite => ActionFn(1117); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -19756,7 +19778,7 @@ mod __parse__Top { let __sym0 = __pop_Variant27(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1119::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1117::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant27(__nt), __end)); (5, 48) } @@ -19787,14 +19809,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (<@L> "else" ":" )? = "else", ":", Suite => ActionFn(1122); + // (<@L> "else" ":" )? = "else", ":", Suite => ActionFn(1120); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1122::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1120::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant29(__nt), __end)); (3, 50) } @@ -19839,13 +19861,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (> "or")+ = AndTest<"all">, "or" => ActionFn(1127); + // (> "or")+ = AndTest<"all">, "or" => ActionFn(1125); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1127::<>(mode, __sym0, __sym1); + let __nt = super::__action1125::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 52) } @@ -19857,14 +19879,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (> "or")+ = (> "or")+, AndTest<"all">, "or" => ActionFn(1128); + // (> "or")+ = (> "or")+, AndTest<"all">, "or" => ActionFn(1126); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1128::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1126::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (3, 52) } @@ -19925,13 +19947,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ",")+ = FunctionArgument, "," => ActionFn(1129); + // ( ",")+ = FunctionArgument, "," => ActionFn(1127); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant30(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1129::<>(mode, __sym0, __sym1); + let __nt = super::__action1127::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant31(__nt), __end)); (2, 55) } @@ -19943,14 +19965,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ",")+ = ( ",")+, FunctionArgument, "," => ActionFn(1130); + // ( ",")+ = ( ",")+, FunctionArgument, "," => ActionFn(1128); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant30(__symbols); let __sym0 = __pop_Variant31(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1130::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1128::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant31(__nt), __end)); (3, 55) } @@ -19980,13 +20002,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (> "and")+ = NotTest<"all">, "and" => ActionFn(1133); + // (> "and")+ = NotTest<"all">, "and" => ActionFn(1131); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1133::<>(mode, __sym0, __sym1); + let __nt = super::__action1131::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (2, 57) } @@ -19998,14 +20020,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (> "and")+ = (> "and")+, NotTest<"all">, "and" => ActionFn(1134); + // (> "and")+ = (> "and")+, NotTest<"all">, "and" => ActionFn(1132); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1134::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1132::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (3, 57) } @@ -20035,13 +20057,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (>> ",")? = OneOrMore>, "," => ActionFn(1135); + // (>> ",")? = OneOrMore>, "," => ActionFn(1133); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1135::<>(mode, __sym0, __sym1); + let __nt = super::__action1133::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant33(__nt), __end)); (2, 59) } @@ -20117,13 +20139,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ",")+ = Pattern, "," => ActionFn(1152); + // ( ",")+ = Pattern, "," => ActionFn(1150); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant34(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1152::<>(mode, __sym0, __sym1); + let __nt = super::__action1150::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant35(__nt), __end)); (2, 62) } @@ -20135,14 +20157,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ",")+ = ( ",")+, Pattern, "," => ActionFn(1153); + // ( ",")+ = ( ",")+, Pattern, "," => ActionFn(1151); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant34(__symbols); let __sym0 = __pop_Variant35(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1153::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1151::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant35(__nt), __end)); (3, 62) } @@ -20203,13 +20225,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ";")+ = SmallStatement, ";" => ActionFn(1156); + // ( ";")+ = SmallStatement, ";" => ActionFn(1154); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1156::<>(mode, __sym0, __sym1); + let __nt = super::__action1154::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant37(__nt), __end)); (2, 65) } @@ -20221,14 +20243,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ";")+ = ( ";")+, SmallStatement, ";" => ActionFn(1157); + // ( ";")+ = ( ";")+, SmallStatement, ";" => ActionFn(1155); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant36(__symbols); let __sym0 = __pop_Variant37(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1157::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1155::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant37(__nt), __end)); (3, 65) } @@ -20259,13 +20281,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ",") = OneOrMore>, "," => ActionFn(1470); + // ( ",") = OneOrMore>, "," => ActionFn(1174); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1470::<>(mode, __sym0, __sym1); + let __nt = super::__action1174::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (2, 67) } @@ -20277,13 +20299,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ( ",")? = OneOrMore>, "," => ActionFn(1473); + // ( ",")? = OneOrMore>, "," => ActionFn(1177); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1473::<>(mode, __sym0, __sym1); + let __nt = super::__action1177::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant40(__nt), __end)); (2, 68) } @@ -20310,11 +20332,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (@L string @R) = string => ActionFn(1176); + // (@L string @R) = string => ActionFn(1186); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1176::<>(mode, __sym0); + let __nt = super::__action1186::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant41(__nt), __end)); (1, 69) } @@ -20326,11 +20348,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (@L string @R)+ = string => ActionFn(1482); + // (@L string @R)+ = string => ActionFn(1478); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1482::<>(mode, __sym0); + let __nt = super::__action1478::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant42(__nt), __end)); (1, 70) } @@ -20342,13 +20364,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (@L string @R)+ = (@L string @R)+, string => ActionFn(1483); + // (@L string @R)+ = (@L string @R)+, string => ActionFn(1479); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant6(__symbols); let __sym0 = __pop_Variant42(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1483::<>(mode, __sym0, __sym1); + let __nt = super::__action1479::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant42(__nt), __end)); (2, 70) } @@ -20363,7 +20385,7 @@ mod __parse__Top { // (CompOp Expression<"all">) = CompOp, Expression<"all"> => ActionFn(493); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); - let __sym0 = __pop_Variant55(__symbols); + let __sym0 = __pop_Variant57(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action493::<>(mode, __sym0, __sym1); @@ -20378,13 +20400,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (CompOp Expression<"all">)+ = CompOp, Expression<"all"> => ActionFn(1484); + // (CompOp Expression<"all">)+ = CompOp, Expression<"all"> => ActionFn(1480); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); - let __sym0 = __pop_Variant55(__symbols); + let __sym0 = __pop_Variant57(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1484::<>(mode, __sym0, __sym1); + let __nt = super::__action1480::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant44(__nt), __end)); (2, 72) } @@ -20396,14 +20418,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (CompOp Expression<"all">)+ = (CompOp Expression<"all">)+, CompOp, Expression<"all"> => ActionFn(1485); + // (CompOp Expression<"all">)+ = (CompOp Expression<"all">)+, CompOp, Expression<"all"> => ActionFn(1481); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant55(__symbols); + let __sym1 = __pop_Variant57(__symbols); let __sym0 = __pop_Variant44(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1485::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1481::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant44(__nt), __end)); (3, 72) } @@ -20416,11 +20438,11 @@ mod __parse__Top { ) -> (usize, usize) { // (Guard) = Guard => ActionFn(342); - let __sym0 = __pop_Variant14(__symbols); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action342::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 73) } pub(crate) fn __reduce144< @@ -20431,12 +20453,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (Guard)? = Guard => ActionFn(1486); - let __sym0 = __pop_Variant14(__symbols); + // (Guard)? = Guard => ActionFn(1482); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1486::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant15(__nt), __end)); + let __nt = super::__action1482::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant46(__nt), __end)); (1, 74) } pub(crate) fn __reduce145< @@ -20451,7 +20473,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action341::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant15(__nt), __end)); + __symbols.push((__start, __Symbol::Variant46(__nt), __end)); (0, 74) } pub(crate) fn __reduce146< @@ -20463,11 +20485,11 @@ mod __parse__Top { ) -> (usize, usize) { // (ParameterList) = ParameterList => ActionFn(276); - let __sym0 = __pop_Variant45(__symbols); + let __sym0 = __pop_Variant47(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action276::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 75) } pub(crate) fn __reduce147< @@ -20478,12 +20500,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // (ParameterList)? = ParameterList => ActionFn(1489); - let __sym0 = __pop_Variant45(__symbols); + // (ParameterList)? = ParameterList => ActionFn(1485); + let __sym0 = __pop_Variant47(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1489::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant46(__nt), __end)); + let __nt = super::__action1485::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant48(__nt), __end)); (1, 76) } pub(crate) fn __reduce148< @@ -20498,7 +20520,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action275::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant46(__nt), __end)); + __symbols.push((__start, __Symbol::Variant48(__nt), __end)); (0, 76) } pub(crate) fn __reduce149< @@ -20513,7 +20535,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action393::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + __symbols.push((__start, __Symbol::Variant49(__nt), __end)); (0, 77) } pub(crate) fn __reduce150< @@ -20528,7 +20550,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action392::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant47(__nt), __end)); + __symbols.push((__start, __Symbol::Variant49(__nt), __end)); (0, 78) } pub(crate) fn __reduce151< @@ -20544,7 +20566,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action196::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 79) } pub(crate) fn __reduce152< @@ -20560,7 +20582,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action197::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 79) } pub(crate) fn __reduce153< @@ -20571,14 +20593,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AddOpExpr = ConstantExpr, AddOp, ConstantAtom => ActionFn(1177); + // AddOpExpr = ConstantExpr, AddOp, ConstantAtom => ActionFn(1187); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1177::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1187::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 80) } @@ -20590,14 +20612,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AndExpression<"all"> = AndExpression<"all">, "&", ShiftExpression<"all"> => ActionFn(1178); + // AndExpression<"all"> = AndExpression<"all">, "&", ShiftExpression<"all"> => ActionFn(1188); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1178::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1188::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 81) } @@ -20625,14 +20647,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AndExpression<"no-withitems"> = AndExpression<"all">, "&", ShiftExpression<"all"> => ActionFn(1179); + // AndExpression<"no-withitems"> = AndExpression<"all">, "&", ShiftExpression<"all"> => ActionFn(1189); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1179::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1189::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 82) } @@ -20660,13 +20682,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AndTest<"all"> = (> "and")+, NotTest<"all"> => ActionFn(1180); + // AndTest<"all"> = (> "and")+, NotTest<"all"> => ActionFn(1190); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1180::<>(mode, __sym0, __sym1); + let __nt = super::__action1190::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 83) } @@ -20694,13 +20716,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AndTest<"no-withitems"> = (> "and")+, NotTest<"all"> => ActionFn(1181); + // AndTest<"no-withitems"> = (> "and")+, NotTest<"all"> => ActionFn(1191); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1181::<>(mode, __sym0, __sym1); + let __nt = super::__action1191::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 84) } @@ -20729,11 +20751,11 @@ mod __parse__Top { ) -> (usize, usize) { // Arguments? = Arguments => ActionFn(266); - let __sym0 = __pop_Variant49(__symbols); + let __sym0 = __pop_Variant51(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action266::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant50(__nt), __end)); + __symbols.push((__start, __Symbol::Variant52(__nt), __end)); (1, 86) } pub(crate) fn __reduce167< @@ -20748,7 +20770,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action267::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant50(__nt), __end)); + __symbols.push((__start, __Symbol::Variant52(__nt), __end)); (0, 86) } pub(crate) fn __reduce168< @@ -20759,14 +20781,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ArithmeticExpression<"all"> = ArithmeticExpression<"all">, AddOp, Term<"all"> => ActionFn(1183); + // ArithmeticExpression<"all"> = ArithmeticExpression<"all">, AddOp, Term<"all"> => ActionFn(1193); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1183::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1193::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 87) } @@ -20794,14 +20816,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ArithmeticExpression<"no-withitems"> = ArithmeticExpression<"all">, AddOp, Term<"all"> => ActionFn(1184); + // ArithmeticExpression<"no-withitems"> = ArithmeticExpression<"all">, AddOp, Term<"all"> => ActionFn(1194); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1184::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1194::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 88) } @@ -20829,7 +20851,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AssertStatement = "assert", Test<"all">, ",", Test<"all"> => ActionFn(1186); + // AssertStatement = "assert", Test<"all">, ",", Test<"all"> => ActionFn(1196); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -20837,7 +20859,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1186::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1196::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 90) } @@ -20849,13 +20871,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AssertStatement = "assert", Test<"all"> => ActionFn(1187); + // AssertStatement = "assert", Test<"all"> => ActionFn(1197); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1187::<>(mode, __sym0, __sym1); + let __nt = super::__action1197::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 90) } @@ -20999,11 +21021,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = Constant => ActionFn(1188); - let __sym0 = __pop_Variant56(__symbols); + // Atom<"all"> = Constant => ActionFn(1198); + let __sym0 = __pop_Variant58(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1188::<>(mode, __sym0); + let __nt = super::__action1198::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 95) } @@ -21015,11 +21037,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = Identifier => ActionFn(1189); + // Atom<"all"> = Identifier => ActionFn(1199); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1189::<>(mode, __sym0); + let __nt = super::__action1199::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 95) } @@ -21031,14 +21053,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "[", ListLiteralValues, "]" => ActionFn(1548); + // Atom<"all"> = "[", ListLiteralValues, "]" => ActionFn(1544); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1548::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1544::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 95) } @@ -21050,13 +21072,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "[", "]" => ActionFn(1549); + // Atom<"all"> = "[", "]" => ActionFn(1545); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1549::<>(mode, __sym0, __sym1); + let __nt = super::__action1545::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 95) } @@ -21068,15 +21090,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "[", TestOrStarNamedExpr, CompFor, "]" => ActionFn(1191); + // Atom<"all"> = "[", TestOrStarNamedExpr, CompFor, "]" => ActionFn(1201); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); + let __sym2 = __pop_Variant55(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1191::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1201::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 95) } @@ -21088,7 +21110,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "(", OneOrMore>, ",", ")" => ActionFn(1192); + // Atom<"all"> = "(", OneOrMore>, ",", ")" => ActionFn(1202); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -21096,7 +21118,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1192::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1202::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 95) } @@ -21108,14 +21130,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "(", OneOrMore>, ")" => ActionFn(1193); + // Atom<"all"> = "(", OneOrMore>, ")" => ActionFn(1203); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1193::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1203::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 95) } @@ -21127,13 +21149,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "(", ")" => ActionFn(1202); + // Atom<"all"> = "(", ")" => ActionFn(1212); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1202::<>(mode, __sym0, __sym1); + let __nt = super::__action1212::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 95) } @@ -21145,14 +21167,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "(", YieldExpr, ")" => ActionFn(530); + // Atom<"all"> = "(", YieldExpr, ")" => ActionFn(1213); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action530::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1213::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 95) } @@ -21164,15 +21186,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "(", NamedExpressionTest, CompFor, ")" => ActionFn(1203); + // Atom<"all"> = "(", NamedExpressionTest, CompFor, ")" => ActionFn(1214); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); + let __sym2 = __pop_Variant55(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1203::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1214::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 95) } @@ -21184,14 +21206,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "{", DictLiteralValues, "}" => ActionFn(1532); + // Atom<"all"> = "{", DictLiteralValues, "}" => ActionFn(1528); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant61(__symbols); + let __sym1 = __pop_Variant63(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1532::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1528::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 95) } @@ -21203,13 +21225,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "{", "}" => ActionFn(1533); + // Atom<"all"> = "{", "}" => ActionFn(1529); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1533::<>(mode, __sym0, __sym1); + let __nt = super::__action1529::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 95) } @@ -21221,15 +21243,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "{", DictEntry, CompFor, "}" => ActionFn(1206); + // Atom<"all"> = "{", DictEntry, CompFor, "}" => ActionFn(1217); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); - let __sym1 = __pop_Variant60(__symbols); + let __sym2 = __pop_Variant55(__symbols); + let __sym1 = __pop_Variant62(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1206::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1217::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 95) } @@ -21241,14 +21263,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "{", SetLiteralValues, "}" => ActionFn(1207); + // Atom<"all"> = "{", SetLiteralValues, "}" => ActionFn(1218); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1207::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1218::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 95) } @@ -21260,15 +21282,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "{", NamedExpressionTest, CompFor, "}" => ActionFn(1208); + // Atom<"all"> = "{", NamedExpressionTest, CompFor, "}" => ActionFn(1219); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); + let __sym2 = __pop_Variant55(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1208::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1219::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 95) } @@ -21280,11 +21302,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "True" => ActionFn(1209); + // Atom<"all"> = "True" => ActionFn(1220); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1209::<>(mode, __sym0); + let __nt = super::__action1220::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 95) } @@ -21296,11 +21318,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "False" => ActionFn(1210); + // Atom<"all"> = "False" => ActionFn(1221); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1210::<>(mode, __sym0); + let __nt = super::__action1221::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 95) } @@ -21312,11 +21334,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "None" => ActionFn(1211); + // Atom<"all"> = "None" => ActionFn(1222); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1211::<>(mode, __sym0); + let __nt = super::__action1222::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 95) } @@ -21328,11 +21350,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"all"> = "..." => ActionFn(1212); + // Atom<"all"> = "..." => ActionFn(1223); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1212::<>(mode, __sym0); + let __nt = super::__action1223::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 95) } @@ -21344,11 +21366,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = Constant => ActionFn(1213); - let __sym0 = __pop_Variant56(__symbols); + // Atom<"no-withitems"> = Constant => ActionFn(1224); + let __sym0 = __pop_Variant58(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1213::<>(mode, __sym0); + let __nt = super::__action1224::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 96) } @@ -21360,11 +21382,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = Identifier => ActionFn(1214); + // Atom<"no-withitems"> = Identifier => ActionFn(1225); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1214::<>(mode, __sym0); + let __nt = super::__action1225::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 96) } @@ -21376,14 +21398,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "[", ListLiteralValues, "]" => ActionFn(1550); + // Atom<"no-withitems"> = "[", ListLiteralValues, "]" => ActionFn(1546); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1550::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1546::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 96) } @@ -21395,13 +21417,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "[", "]" => ActionFn(1551); + // Atom<"no-withitems"> = "[", "]" => ActionFn(1547); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1551::<>(mode, __sym0, __sym1); + let __nt = super::__action1547::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 96) } @@ -21413,15 +21435,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "[", TestOrStarNamedExpr, CompFor, "]" => ActionFn(1216); + // Atom<"no-withitems"> = "[", TestOrStarNamedExpr, CompFor, "]" => ActionFn(1227); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); + let __sym2 = __pop_Variant55(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1216::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1227::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 96) } @@ -21433,13 +21455,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "(", ")" => ActionFn(1225); + // Atom<"no-withitems"> = "(", ")" => ActionFn(1236); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1225::<>(mode, __sym0, __sym1); + let __nt = super::__action1236::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 96) } @@ -21451,14 +21473,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "(", YieldExpr, ")" => ActionFn(572); + // Atom<"no-withitems"> = "(", YieldExpr, ")" => ActionFn(1237); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action572::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1237::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 96) } @@ -21470,15 +21492,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "(", NamedExpressionTest, CompFor, ")" => ActionFn(1226); + // Atom<"no-withitems"> = "(", NamedExpressionTest, CompFor, ")" => ActionFn(1238); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); + let __sym2 = __pop_Variant55(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1226::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1238::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 96) } @@ -21490,14 +21512,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "{", DictLiteralValues, "}" => ActionFn(1534); + // Atom<"no-withitems"> = "{", DictLiteralValues, "}" => ActionFn(1530); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant61(__symbols); + let __sym1 = __pop_Variant63(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1534::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1530::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 96) } @@ -21509,13 +21531,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "{", "}" => ActionFn(1535); + // Atom<"no-withitems"> = "{", "}" => ActionFn(1531); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1535::<>(mode, __sym0, __sym1); + let __nt = super::__action1531::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 96) } @@ -21527,15 +21549,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "{", DictEntry, CompFor, "}" => ActionFn(1229); + // Atom<"no-withitems"> = "{", DictEntry, CompFor, "}" => ActionFn(1241); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); - let __sym1 = __pop_Variant60(__symbols); + let __sym2 = __pop_Variant55(__symbols); + let __sym1 = __pop_Variant62(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1229::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1241::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 96) } @@ -21547,14 +21569,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "{", SetLiteralValues, "}" => ActionFn(1230); + // Atom<"no-withitems"> = "{", SetLiteralValues, "}" => ActionFn(1242); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1230::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1242::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 96) } @@ -21566,15 +21588,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "{", NamedExpressionTest, CompFor, "}" => ActionFn(1231); + // Atom<"no-withitems"> = "{", NamedExpressionTest, CompFor, "}" => ActionFn(1243); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant53(__symbols); + let __sym2 = __pop_Variant55(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1231::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1243::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 96) } @@ -21586,11 +21608,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "True" => ActionFn(1232); + // Atom<"no-withitems"> = "True" => ActionFn(1244); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1232::<>(mode, __sym0); + let __nt = super::__action1244::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 96) } @@ -21602,11 +21624,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "False" => ActionFn(1233); + // Atom<"no-withitems"> = "False" => ActionFn(1245); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1233::<>(mode, __sym0); + let __nt = super::__action1245::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 96) } @@ -21618,11 +21640,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "None" => ActionFn(1234); + // Atom<"no-withitems"> = "None" => ActionFn(1246); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1234::<>(mode, __sym0); + let __nt = super::__action1246::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 96) } @@ -21634,11 +21656,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Atom<"no-withitems"> = "..." => ActionFn(1235); + // Atom<"no-withitems"> = "..." => ActionFn(1247); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1235::<>(mode, __sym0); + let __nt = super::__action1247::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 96) } @@ -21666,13 +21688,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr2<"all"> = AtomExpr2<"all">, Arguments => ActionFn(1236); + // AtomExpr2<"all"> = AtomExpr2<"all">, Arguments => ActionFn(1248); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant49(__symbols); + let __sym1 = __pop_Variant51(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1236::<>(mode, __sym0, __sym1); + let __nt = super::__action1248::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 97) } @@ -21684,7 +21706,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr2<"all"> = AtomExpr2<"all">, "[", SubscriptList, "]" => ActionFn(1237); + // AtomExpr2<"all"> = AtomExpr2<"all">, "[", SubscriptList, "]" => ActionFn(1249); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant14(__symbols); @@ -21692,7 +21714,7 @@ mod __parse__Top { let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1237::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1249::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 97) } @@ -21704,14 +21726,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr2<"all"> = AtomExpr2<"all">, ".", Identifier => ActionFn(1238); + // AtomExpr2<"all"> = AtomExpr2<"all">, ".", Identifier => ActionFn(1250); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1238::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1250::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 97) } @@ -21739,13 +21761,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr2<"no-withitems"> = AtomExpr2<"all">, Arguments => ActionFn(1239); + // AtomExpr2<"no-withitems"> = AtomExpr2<"all">, Arguments => ActionFn(1251); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant49(__symbols); + let __sym1 = __pop_Variant51(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1239::<>(mode, __sym0, __sym1); + let __nt = super::__action1251::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 98) } @@ -21757,7 +21779,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr2<"no-withitems"> = AtomExpr2<"all">, "[", SubscriptList, "]" => ActionFn(1240); + // AtomExpr2<"no-withitems"> = AtomExpr2<"all">, "[", SubscriptList, "]" => ActionFn(1252); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant14(__symbols); @@ -21765,7 +21787,7 @@ mod __parse__Top { let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1240::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1252::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 98) } @@ -21777,14 +21799,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr2<"no-withitems"> = AtomExpr2<"all">, ".", Identifier => ActionFn(1241); + // AtomExpr2<"no-withitems"> = AtomExpr2<"all">, ".", Identifier => ActionFn(1253); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1241::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1253::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 98) } @@ -21796,13 +21818,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr<"all"> = "await", AtomExpr2<"all"> => ActionFn(1242); + // AtomExpr<"all"> = "await", AtomExpr2<"all"> => ActionFn(1254); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1242::<>(mode, __sym0, __sym1); + let __nt = super::__action1254::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 99) } @@ -21830,13 +21852,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // AtomExpr<"no-withitems"> = "await", AtomExpr2<"all"> => ActionFn(1243); + // AtomExpr<"no-withitems"> = "await", AtomExpr2<"all"> => ActionFn(1255); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1243::<>(mode, __sym0, __sym1); + let __nt = super::__action1255::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 100) } @@ -21869,7 +21891,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action40::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce252< @@ -21885,7 +21907,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action41::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce253< @@ -21901,7 +21923,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action42::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce254< @@ -21917,7 +21939,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action43::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce255< @@ -21933,7 +21955,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action44::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce256< @@ -21949,7 +21971,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action45::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce257< @@ -21965,7 +21987,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action46::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce258< @@ -21981,7 +22003,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action47::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce259< @@ -21997,7 +22019,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action48::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce260< @@ -22013,7 +22035,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action49::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce261< @@ -22029,7 +22051,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action50::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce262< @@ -22045,7 +22067,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action51::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce263< @@ -22061,7 +22083,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action52::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 101) } pub(crate) fn __reduce264< @@ -22072,11 +22094,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // CapturePattern = Identifier => ActionFn(1244); + // CapturePattern = Identifier => ActionFn(1256); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1244::<>(mode, __sym0); + let __nt = super::__action1256::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 102) } @@ -22088,17 +22110,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = "class", Identifier, TypeParams, Arguments, ":", Suite => ActionFn(1704); + // ClassDef = "class", Identifier, TypeParams, Arguments, ":", Suite => ActionFn(1700); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant49(__symbols); - let __sym2 = __pop_Variant92(__symbols); + let __sym3 = __pop_Variant51(__symbols); + let __sym2 = __pop_Variant94(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1704::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1700::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 103) } @@ -22110,16 +22132,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = "class", Identifier, Arguments, ":", Suite => ActionFn(1705); + // ClassDef = "class", Identifier, Arguments, ":", Suite => ActionFn(1701); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant49(__symbols); + let __sym2 = __pop_Variant51(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1705::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1701::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 103) } @@ -22131,18 +22153,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = Decorator+, "class", Identifier, TypeParams, Arguments, ":", Suite => ActionFn(1706); + // ClassDef = Decorator+, "class", Identifier, TypeParams, Arguments, ":", Suite => ActionFn(1702); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant49(__symbols); - let __sym3 = __pop_Variant92(__symbols); + let __sym4 = __pop_Variant51(__symbols); + let __sym3 = __pop_Variant94(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1706::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1702::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 103) } @@ -22154,17 +22176,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = Decorator+, "class", Identifier, Arguments, ":", Suite => ActionFn(1707); + // ClassDef = Decorator+, "class", Identifier, Arguments, ":", Suite => ActionFn(1703); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant49(__symbols); + let __sym3 = __pop_Variant51(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1707::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1703::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 103) } @@ -22176,16 +22198,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = "class", Identifier, TypeParams, ":", Suite => ActionFn(1708); + // ClassDef = "class", Identifier, TypeParams, ":", Suite => ActionFn(1704); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant92(__symbols); + let __sym2 = __pop_Variant94(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1708::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1704::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 103) } @@ -22197,7 +22219,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = "class", Identifier, ":", Suite => ActionFn(1709); + // ClassDef = "class", Identifier, ":", Suite => ActionFn(1705); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -22205,7 +22227,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1709::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1705::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 103) } @@ -22217,17 +22239,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = Decorator+, "class", Identifier, TypeParams, ":", Suite => ActionFn(1710); + // ClassDef = Decorator+, "class", Identifier, TypeParams, ":", Suite => ActionFn(1706); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant92(__symbols); + let __sym3 = __pop_Variant94(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1710::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1706::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 103) } @@ -22239,16 +22261,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassDef = Decorator+, "class", Identifier, ":", Suite => ActionFn(1711); + // ClassDef = Decorator+, "class", Identifier, ":", Suite => ActionFn(1707); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1711::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1707::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 103) } @@ -22260,13 +22282,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassPattern = MatchName, PatternArguments => ActionFn(1245); + // ClassPattern = MatchName, PatternArguments => ActionFn(1257); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant84(__symbols); - let __sym0 = __pop_Variant14(__symbols); + let __sym1 = __pop_Variant86(__symbols); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1245::<>(mode, __sym0, __sym1); + let __nt = super::__action1257::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 104) } @@ -22278,13 +22300,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ClassPattern = MatchNameOrAttr, PatternArguments => ActionFn(1246); + // ClassPattern = MatchNameOrAttr, PatternArguments => ActionFn(1258); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant84(__symbols); - let __sym0 = __pop_Variant14(__symbols); + let __sym1 = __pop_Variant86(__symbols); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1246::<>(mode, __sym0, __sym1); + let __nt = super::__action1258::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 104) } @@ -22408,12 +22430,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = FunctionArgument => ActionFn(1498); + // Comma = FunctionArgument => ActionFn(1494); let __sym0 = __pop_Variant30(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1498::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant51(__nt), __end)); + let __nt = super::__action1494::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant53(__nt), __end)); (1, 106) } pub(crate) fn __reduce283< @@ -22424,11 +22446,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = => ActionFn(1499); + // Comma = => ActionFn(1495); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action1499::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant51(__nt), __end)); + let __nt = super::__action1495::<>(mode, &__start, &__end); + __symbols.push((__start, __Symbol::Variant53(__nt), __end)); (0, 106) } pub(crate) fn __reduce284< @@ -22439,14 +22461,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = ( ",")+, FunctionArgument => ActionFn(1500); + // Comma = ( ",")+, FunctionArgument => ActionFn(1496); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant30(__symbols); let __sym0 = __pop_Variant31(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1500::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant51(__nt), __end)); + let __nt = super::__action1496::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant53(__nt), __end)); (2, 106) } pub(crate) fn __reduce285< @@ -22457,12 +22479,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = ( ",")+ => ActionFn(1501); + // Comma = ( ",")+ => ActionFn(1497); let __sym0 = __pop_Variant31(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1501::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant51(__nt), __end)); + let __nt = super::__action1497::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant53(__nt), __end)); (1, 106) } pub(crate) fn __reduce286< @@ -22473,12 +22495,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = Pattern => ActionFn(1506); + // Comma = Pattern => ActionFn(1502); let __sym0 = __pop_Variant34(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1506::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + let __nt = super::__action1502::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (1, 107) } pub(crate) fn __reduce287< @@ -22489,11 +22511,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = => ActionFn(1507); + // Comma = => ActionFn(1503); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action1507::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + let __nt = super::__action1503::<>(mode, &__start, &__end); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (0, 107) } pub(crate) fn __reduce288< @@ -22504,14 +22526,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = ( ",")+, Pattern => ActionFn(1508); + // Comma = ( ",")+, Pattern => ActionFn(1504); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant34(__symbols); let __sym0 = __pop_Variant35(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1508::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + let __nt = super::__action1504::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (2, 107) } pub(crate) fn __reduce289< @@ -22522,12 +22544,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comma = ( ",")+ => ActionFn(1509); + // Comma = ( ",")+ => ActionFn(1505); let __sym0 = __pop_Variant35(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1509::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + let __nt = super::__action1505::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (1, 107) } pub(crate) fn __reduce290< @@ -22539,11 +22561,11 @@ mod __parse__Top { ) -> (usize, usize) { // CompFor = SingleForComprehension+ => ActionFn(224); - let __sym0 = __pop_Variant86(__symbols); + let __sym0 = __pop_Variant88(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action224::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant53(__nt), __end)); + __symbols.push((__start, __Symbol::Variant55(__nt), __end)); (1, 108) } pub(crate) fn __reduce291< @@ -22555,11 +22577,11 @@ mod __parse__Top { ) -> (usize, usize) { // CompFor? = CompFor => ActionFn(237); - let __sym0 = __pop_Variant53(__symbols); + let __sym0 = __pop_Variant55(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action237::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant54(__nt), __end)); + __symbols.push((__start, __Symbol::Variant56(__nt), __end)); (1, 109) } pub(crate) fn __reduce292< @@ -22574,7 +22596,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action238::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant54(__nt), __end)); + __symbols.push((__start, __Symbol::Variant56(__nt), __end)); (0, 109) } pub(crate) fn __reduce293< @@ -22590,7 +22612,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action184::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce294< @@ -22606,7 +22628,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action185::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce295< @@ -22622,7 +22644,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action186::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce296< @@ -22638,7 +22660,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action187::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce297< @@ -22654,7 +22676,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action188::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce298< @@ -22670,7 +22692,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action189::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce299< @@ -22686,7 +22708,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action190::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce300< @@ -22704,7 +22726,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action191::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (2, 110) } pub(crate) fn __reduce301< @@ -22720,7 +22742,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action192::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (1, 110) } pub(crate) fn __reduce302< @@ -22738,7 +22760,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action193::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant55(__nt), __end)); + __symbols.push((__start, __Symbol::Variant57(__nt), __end)); (2, 110) } pub(crate) fn __reduce303< @@ -22749,13 +22771,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comparison<"all"> = Expression<"all">, (CompOp Expression<"all">)+ => ActionFn(1247); + // Comparison<"all"> = Expression<"all">, (CompOp Expression<"all">)+ => ActionFn(1259); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant44(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1247::<>(mode, __sym0, __sym1); + let __nt = super::__action1259::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 111) } @@ -22783,13 +22805,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Comparison<"no-withitems"> = Expression<"all">, (CompOp Expression<"all">)+ => ActionFn(1248); + // Comparison<"no-withitems"> = Expression<"all">, (CompOp Expression<"all">)+ => ActionFn(1260); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant44(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1248::<>(mode, __sym0, __sym1); + let __nt = super::__action1260::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 112) } @@ -23033,7 +23055,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action233::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant56(__nt), __end)); + __symbols.push((__start, __Symbol::Variant58(__nt), __end)); (1, 117) } pub(crate) fn __reduce321< @@ -23049,7 +23071,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action234::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant56(__nt), __end)); + __symbols.push((__start, __Symbol::Variant58(__nt), __end)); (1, 117) } pub(crate) fn __reduce322< @@ -23065,7 +23087,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action235::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant56(__nt), __end)); + __symbols.push((__start, __Symbol::Variant58(__nt), __end)); (1, 117) } pub(crate) fn __reduce323< @@ -23076,11 +23098,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ConstantAtom = Constant => ActionFn(1249); - let __sym0 = __pop_Variant56(__symbols); + // ConstantAtom = Constant => ActionFn(1261); + let __sym0 = __pop_Variant58(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1249::<>(mode, __sym0); + let __nt = super::__action1261::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 118) } @@ -23108,13 +23130,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ConstantExpr = "-", ConstantAtom => ActionFn(1250); + // ConstantExpr = "-", ConstantAtom => ActionFn(1262); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1250::<>(mode, __sym0, __sym1); + let __nt = super::__action1262::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 119) } @@ -23126,15 +23148,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Decorator = "@", NamedExpressionTest, "\n" => ActionFn(1251); + // Decorator = "@", NamedExpressionTest, "\n" => ActionFn(1263); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1251::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant57(__nt), __end)); + let __nt = super::__action1263::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant59(__nt), __end)); (3, 120) } pub(crate) fn __reduce327< @@ -23149,7 +23171,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action286::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant58(__nt), __end)); + __symbols.push((__start, __Symbol::Variant60(__nt), __end)); (0, 121) } pub(crate) fn __reduce328< @@ -23161,11 +23183,11 @@ mod __parse__Top { ) -> (usize, usize) { // Decorator* = Decorator+ => ActionFn(287); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action287::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant58(__nt), __end)); + __symbols.push((__start, __Symbol::Variant60(__nt), __end)); (1, 121) } pub(crate) fn __reduce329< @@ -23177,11 +23199,11 @@ mod __parse__Top { ) -> (usize, usize) { // Decorator+ = Decorator => ActionFn(414); - let __sym0 = __pop_Variant57(__symbols); + let __sym0 = __pop_Variant59(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action414::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant58(__nt), __end)); + __symbols.push((__start, __Symbol::Variant60(__nt), __end)); (1, 122) } pub(crate) fn __reduce330< @@ -23194,12 +23216,12 @@ mod __parse__Top { { // Decorator+ = Decorator+, Decorator => ActionFn(415); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant57(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym1 = __pop_Variant59(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action415::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant58(__nt), __end)); + __symbols.push((__start, __Symbol::Variant60(__nt), __end)); (2, 122) } pub(crate) fn __reduce331< @@ -23210,13 +23232,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // DelStatement = "del", ExpressionList2 => ActionFn(1252); + // DelStatement = "del", ExpressionList2 => ActionFn(1264); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1252::<>(mode, __sym0, __sym1); + let __nt = super::__action1264::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 123) } @@ -23229,11 +23251,11 @@ mod __parse__Top { ) -> (usize, usize) { // DictElement = DictEntry => ActionFn(215); - let __sym0 = __pop_Variant60(__symbols); + let __sym0 = __pop_Variant62(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action215::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant59(__nt), __end)); + __symbols.push((__start, __Symbol::Variant61(__nt), __end)); (1, 124) } pub(crate) fn __reduce333< @@ -23251,7 +23273,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action216::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant59(__nt), __end)); + __symbols.push((__start, __Symbol::Variant61(__nt), __end)); (2, 124) } pub(crate) fn __reduce334< @@ -23270,7 +23292,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action214::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant60(__nt), __end)); + __symbols.push((__start, __Symbol::Variant62(__nt), __end)); (3, 125) } pub(crate) fn __reduce335< @@ -23284,11 +23306,11 @@ mod __parse__Top { // DictLiteralValues = OneOrMore, "," => ActionFn(589); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant61(__symbols); + let __sym0 = __pop_Variant63(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action589::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant61(__nt), __end)); + __symbols.push((__start, __Symbol::Variant63(__nt), __end)); (2, 126) } pub(crate) fn __reduce336< @@ -23300,11 +23322,11 @@ mod __parse__Top { ) -> (usize, usize) { // DictLiteralValues = OneOrMore => ActionFn(590); - let __sym0 = __pop_Variant61(__symbols); + let __sym0 = __pop_Variant63(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action590::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant61(__nt), __end)); + __symbols.push((__start, __Symbol::Variant63(__nt), __end)); (1, 126) } pub(crate) fn __reduce337< @@ -23316,11 +23338,11 @@ mod __parse__Top { ) -> (usize, usize) { // DictLiteralValues? = DictLiteralValues => ActionFn(541); - let __sym0 = __pop_Variant61(__symbols); + let __sym0 = __pop_Variant63(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action541::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant62(__nt), __end)); + __symbols.push((__start, __Symbol::Variant64(__nt), __end)); (1, 127) } pub(crate) fn __reduce338< @@ -23335,7 +23357,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action542::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant62(__nt), __end)); + __symbols.push((__start, __Symbol::Variant64(__nt), __end)); (0, 127) } pub(crate) fn __reduce339< @@ -23346,11 +23368,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // DottedName = name => ActionFn(1253); + // DottedName = name => ActionFn(1265); let __sym0 = __pop_Variant5(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1253::<>(mode, __sym0); + let __nt = super::__action1265::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 128) } @@ -23362,13 +23384,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // DottedName = name, ("." Identifier)+ => ActionFn(1254); + // DottedName = name, ("." Identifier)+ => ActionFn(1266); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant20(__symbols); let __sym0 = __pop_Variant5(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1254::<>(mode, __sym0, __sym1); + let __nt = super::__action1266::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (2, 128) } @@ -23380,15 +23402,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // DoubleStarTypedParameter = Identifier, ":", Test<"all"> => ActionFn(1255); + // DoubleStarTypedParameter = Identifier, ":", Test<"all"> => ActionFn(1267); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1255::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant63(__nt), __end)); + let __nt = super::__action1267::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant65(__nt), __end)); (3, 129) } pub(crate) fn __reduce342< @@ -23399,12 +23421,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // DoubleStarTypedParameter = Identifier => ActionFn(1256); + // DoubleStarTypedParameter = Identifier => ActionFn(1268); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1256::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant63(__nt), __end)); + let __nt = super::__action1268::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant65(__nt), __end)); (1, 129) } pub(crate) fn __reduce343< @@ -23416,11 +23438,11 @@ mod __parse__Top { ) -> (usize, usize) { // DoubleStarTypedParameter? = DoubleStarTypedParameter => ActionFn(475); - let __sym0 = __pop_Variant63(__symbols); + let __sym0 = __pop_Variant65(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action475::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant64(__nt), __end)); + __symbols.push((__start, __Symbol::Variant66(__nt), __end)); (1, 130) } pub(crate) fn __reduce344< @@ -23435,7 +23457,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action476::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant64(__nt), __end)); + __symbols.push((__start, __Symbol::Variant66(__nt), __end)); (0, 130) } pub(crate) fn __reduce345< @@ -23446,7 +23468,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExceptClause = "except", Test<"all">, ":", Suite => ActionFn(1676); + // ExceptClause = "except", Test<"all">, ":", Suite => ActionFn(1672); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -23454,8 +23476,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1676::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant65(__nt), __end)); + let __nt = super::__action1672::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant67(__nt), __end)); (4, 131) } pub(crate) fn __reduce346< @@ -23466,15 +23488,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExceptClause = "except", ":", Suite => ActionFn(1677); + // ExceptClause = "except", ":", Suite => ActionFn(1673); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1677::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant65(__nt), __end)); + let __nt = super::__action1673::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant67(__nt), __end)); (3, 131) } pub(crate) fn __reduce347< @@ -23485,7 +23507,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExceptClause = "except", Test<"all">, "as", Identifier, ":", Suite => ActionFn(1174); + // ExceptClause = "except", Test<"all">, "as", Identifier, ":", Suite => ActionFn(1172); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); @@ -23495,8 +23517,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1174::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); - __symbols.push((__start, __Symbol::Variant65(__nt), __end)); + let __nt = super::__action1172::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + __symbols.push((__start, __Symbol::Variant67(__nt), __end)); (6, 131) } pub(crate) fn __reduce348< @@ -23508,11 +23530,11 @@ mod __parse__Top { ) -> (usize, usize) { // ExceptClause+ = ExceptClause => ActionFn(310); - let __sym0 = __pop_Variant65(__symbols); + let __sym0 = __pop_Variant67(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action310::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant66(__nt), __end)); + __symbols.push((__start, __Symbol::Variant68(__nt), __end)); (1, 132) } pub(crate) fn __reduce349< @@ -23525,12 +23547,12 @@ mod __parse__Top { { // ExceptClause+ = ExceptClause+, ExceptClause => ActionFn(311); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant65(__symbols); - let __sym0 = __pop_Variant66(__symbols); + let __sym1 = __pop_Variant67(__symbols); + let __sym0 = __pop_Variant68(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action311::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant66(__nt), __end)); + __symbols.push((__start, __Symbol::Variant68(__nt), __end)); (2, 132) } pub(crate) fn __reduce350< @@ -23541,7 +23563,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExceptStarClause = "except", "*", Test<"all">, ":", Suite => ActionFn(769); + // ExceptStarClause = "except", "*", Test<"all">, ":", Suite => ActionFn(771); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -23550,8 +23572,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action769::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant65(__nt), __end)); + let __nt = super::__action771::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant67(__nt), __end)); (5, 133) } pub(crate) fn __reduce351< @@ -23562,7 +23584,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExceptStarClause = "except", "*", Test<"all">, "as", Identifier, ":", Suite => ActionFn(1175); + // ExceptStarClause = "except", "*", Test<"all">, "as", Identifier, ":", Suite => ActionFn(1173); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -23573,8 +23595,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1175::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); - __symbols.push((__start, __Symbol::Variant65(__nt), __end)); + let __nt = super::__action1173::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + __symbols.push((__start, __Symbol::Variant67(__nt), __end)); (7, 133) } pub(crate) fn __reduce352< @@ -23586,11 +23608,11 @@ mod __parse__Top { ) -> (usize, usize) { // ExceptStarClause+ = ExceptStarClause => ActionFn(305); - let __sym0 = __pop_Variant65(__symbols); + let __sym0 = __pop_Variant67(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action305::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant66(__nt), __end)); + __symbols.push((__start, __Symbol::Variant68(__nt), __end)); (1, 134) } pub(crate) fn __reduce353< @@ -23603,12 +23625,12 @@ mod __parse__Top { { // ExceptStarClause+ = ExceptStarClause+, ExceptStarClause => ActionFn(306); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant65(__symbols); - let __sym0 = __pop_Variant66(__symbols); + let __sym1 = __pop_Variant67(__symbols); + let __sym0 = __pop_Variant68(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action306::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant66(__nt), __end)); + __symbols.push((__start, __Symbol::Variant68(__nt), __end)); (2, 134) } pub(crate) fn __reduce354< @@ -23619,14 +23641,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Expression<"all"> = Expression<"all">, "|", XorExpression<"all"> => ActionFn(1257); + // Expression<"all"> = Expression<"all">, "|", XorExpression<"all"> => ActionFn(1269); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1257::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1269::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 135) } @@ -23654,14 +23676,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Expression<"no-withitems"> = Expression<"all">, "|", XorExpression<"all"> => ActionFn(1258); + // Expression<"no-withitems"> = Expression<"all">, "|", XorExpression<"all"> => ActionFn(1270); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1258::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1270::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 136) } @@ -23787,11 +23809,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExpressionStatement = GenericList => ActionFn(1701); + // ExpressionStatement = GenericList => ActionFn(1697); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1701::<>(mode, __sym0); + let __nt = super::__action1697::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 141) } @@ -23803,13 +23825,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExpressionStatement = GenericList, AssignSuffix+ => ActionFn(1702); + // ExpressionStatement = GenericList, AssignSuffix+ => ActionFn(1698); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant16(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1702::<>(mode, __sym0, __sym1); + let __nt = super::__action1698::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 141) } @@ -23821,14 +23843,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExpressionStatement = GenericList, AugAssign, TestListOrYieldExpr => ActionFn(1703); + // ExpressionStatement = GenericList, AugAssign, TestListOrYieldExpr => ActionFn(1699); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1703::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1699::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (3, 141) } @@ -23840,7 +23862,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExpressionStatement = Test<"all">, ":", Test<"all">, AssignSuffix => ActionFn(1496); + // ExpressionStatement = Test<"all">, ":", Test<"all">, AssignSuffix => ActionFn(1492); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); let __sym2 = __pop_Variant14(__symbols); @@ -23848,7 +23870,7 @@ mod __parse__Top { let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1496::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1492::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 141) } @@ -23860,14 +23882,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ExpressionStatement = Test<"all">, ":", Test<"all"> => ActionFn(1497); + // ExpressionStatement = Test<"all">, ":", Test<"all"> => ActionFn(1493); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1497::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1493::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (3, 141) } @@ -23879,13 +23901,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Factor<"all"> = UnaryOp, Factor<"all"> => ActionFn(1262); + // Factor<"all"> = UnaryOp, Factor<"all"> => ActionFn(1274); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); - let __sym0 = __pop_Variant94(__symbols); + let __sym0 = __pop_Variant96(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1262::<>(mode, __sym0, __sym1); + let __nt = super::__action1274::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 142) } @@ -23913,13 +23935,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Factor<"no-withitems"> = UnaryOp, Factor<"all"> => ActionFn(1263); + // Factor<"no-withitems"> = UnaryOp, Factor<"all"> => ActionFn(1275); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); - let __sym0 = __pop_Variant94(__symbols); + let __sym0 = __pop_Variant96(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1263::<>(mode, __sym0, __sym1); + let __nt = super::__action1275::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 143) } @@ -23947,11 +23969,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FlowStatement = "break" => ActionFn(1264); + // FlowStatement = "break" => ActionFn(1276); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1264::<>(mode, __sym0); + let __nt = super::__action1276::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 144) } @@ -23963,11 +23985,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FlowStatement = "continue" => ActionFn(1265); + // FlowStatement = "continue" => ActionFn(1277); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1265::<>(mode, __sym0); + let __nt = super::__action1277::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 144) } @@ -23979,13 +24001,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FlowStatement = "return", GenericList => ActionFn(1697); + // FlowStatement = "return", GenericList => ActionFn(1693); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1697::<>(mode, __sym0, __sym1); + let __nt = super::__action1693::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 144) } @@ -23997,11 +24019,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FlowStatement = "return" => ActionFn(1698); + // FlowStatement = "return" => ActionFn(1694); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1698::<>(mode, __sym0); + let __nt = super::__action1694::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 144) } @@ -24013,11 +24035,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FlowStatement = YieldExpr => ActionFn(1267); + // FlowStatement = YieldExpr => ActionFn(1279); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1267::<>(mode, __sym0); + let __nt = super::__action1279::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 144) } @@ -24045,7 +24067,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ForStatement = "async", "for", ExpressionList, "in", GenericList, ":", Suite, "else", ":", Suite => ActionFn(1688); + // ForStatement = "async", "for", ExpressionList, "in", GenericList, ":", Suite, "else", ":", Suite => ActionFn(1684); assert!(__symbols.len() >= 10); let __sym9 = __pop_Variant24(__symbols); let __sym8 = __pop_Variant0(__symbols); @@ -24059,7 +24081,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym9.2; - let __nt = super::__action1688::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); + let __nt = super::__action1684::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (10, 145) } @@ -24071,7 +24093,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ForStatement = "async", "for", ExpressionList, "in", GenericList, ":", Suite => ActionFn(1689); + // ForStatement = "async", "for", ExpressionList, "in", GenericList, ":", Suite => ActionFn(1685); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -24082,7 +24104,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1689::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1685::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 145) } @@ -24094,7 +24116,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ForStatement = "for", ExpressionList, "in", GenericList, ":", Suite, "else", ":", Suite => ActionFn(1690); + // ForStatement = "for", ExpressionList, "in", GenericList, ":", Suite, "else", ":", Suite => ActionFn(1686); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant24(__symbols); let __sym7 = __pop_Variant0(__symbols); @@ -24107,7 +24129,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym8.2; - let __nt = super::__action1690::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); + let __nt = super::__action1686::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (9, 145) } @@ -24119,7 +24141,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ForStatement = "for", ExpressionList, "in", GenericList, ":", Suite => ActionFn(1691); + // ForStatement = "for", ExpressionList, "in", GenericList, ":", Suite => ActionFn(1687); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); @@ -24129,7 +24151,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1691::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1687::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 145) } @@ -24141,20 +24163,20 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "async", "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1712); + // FuncDef = "async", "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1708); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant24(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant14(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant45(__symbols); - let __sym3 = __pop_Variant92(__symbols); + let __sym4 = __pop_Variant47(__symbols); + let __sym3 = __pop_Variant94(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym8.2; - let __nt = super::__action1712::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); + let __nt = super::__action1708::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (9, 146) } @@ -24166,19 +24188,19 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "async", "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1713); + // FuncDef = "async", "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1709); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant24(__symbols); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant14(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant45(__symbols); + let __sym3 = __pop_Variant47(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action1713::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action1709::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 146) } @@ -24190,21 +24212,21 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "async", "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1714); + // FuncDef = Decorator+, "async", "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1710); assert!(__symbols.len() >= 10); let __sym9 = __pop_Variant24(__symbols); let __sym8 = __pop_Variant0(__symbols); let __sym7 = __pop_Variant14(__symbols); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant45(__symbols); - let __sym4 = __pop_Variant92(__symbols); + let __sym5 = __pop_Variant47(__symbols); + let __sym4 = __pop_Variant94(__symbols); let __sym3 = __pop_Variant22(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym9.2; - let __nt = super::__action1714::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); + let __nt = super::__action1710::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (10, 146) } @@ -24216,20 +24238,20 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "async", "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1715); + // FuncDef = Decorator+, "async", "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1711); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant24(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant14(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant45(__symbols); + let __sym4 = __pop_Variant47(__symbols); let __sym3 = __pop_Variant22(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym8.2; - let __nt = super::__action1715::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); + let __nt = super::__action1711::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (9, 146) } @@ -24241,18 +24263,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "async", "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1716); + // FuncDef = "async", "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1712); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant45(__symbols); - let __sym3 = __pop_Variant92(__symbols); + let __sym4 = __pop_Variant47(__symbols); + let __sym3 = __pop_Variant94(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1716::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1712::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 146) } @@ -24264,17 +24286,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "async", "def", Identifier, Parameters, ":", Suite => ActionFn(1717); + // FuncDef = "async", "def", Identifier, Parameters, ":", Suite => ActionFn(1713); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant45(__symbols); + let __sym3 = __pop_Variant47(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1717::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1713::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 146) } @@ -24286,19 +24308,19 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "async", "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1718); + // FuncDef = Decorator+, "async", "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1714); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant24(__symbols); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant45(__symbols); - let __sym4 = __pop_Variant92(__symbols); + let __sym5 = __pop_Variant47(__symbols); + let __sym4 = __pop_Variant94(__symbols); let __sym3 = __pop_Variant22(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action1718::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action1714::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 146) } @@ -24310,18 +24332,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "async", "def", Identifier, Parameters, ":", Suite => ActionFn(1719); + // FuncDef = Decorator+, "async", "def", Identifier, Parameters, ":", Suite => ActionFn(1715); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant45(__symbols); + let __sym4 = __pop_Variant47(__symbols); let __sym3 = __pop_Variant22(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1719::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1715::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 146) } @@ -24333,19 +24355,19 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1720); + // FuncDef = "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1716); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant24(__symbols); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant14(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant45(__symbols); - let __sym2 = __pop_Variant92(__symbols); + let __sym3 = __pop_Variant47(__symbols); + let __sym2 = __pop_Variant94(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action1720::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action1716::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 146) } @@ -24357,18 +24379,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1721); + // FuncDef = "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1717); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant14(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant45(__symbols); + let __sym2 = __pop_Variant47(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1721::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1717::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 146) } @@ -24380,20 +24402,20 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1722); + // FuncDef = Decorator+, "def", Identifier, TypeParams, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1718); assert!(__symbols.len() >= 9); let __sym8 = __pop_Variant24(__symbols); let __sym7 = __pop_Variant0(__symbols); let __sym6 = __pop_Variant14(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant45(__symbols); - let __sym3 = __pop_Variant92(__symbols); + let __sym4 = __pop_Variant47(__symbols); + let __sym3 = __pop_Variant94(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym8.2; - let __nt = super::__action1722::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); + let __nt = super::__action1718::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (9, 146) } @@ -24405,19 +24427,19 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1723); + // FuncDef = Decorator+, "def", Identifier, Parameters, "->", Test<"all">, ":", Suite => ActionFn(1719); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant24(__symbols); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant14(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant45(__symbols); + let __sym3 = __pop_Variant47(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action1723::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action1719::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 146) } @@ -24429,17 +24451,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1724); + // FuncDef = "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1720); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant45(__symbols); - let __sym2 = __pop_Variant92(__symbols); + let __sym3 = __pop_Variant47(__symbols); + let __sym2 = __pop_Variant94(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1724::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1720::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 146) } @@ -24451,16 +24473,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = "def", Identifier, Parameters, ":", Suite => ActionFn(1725); + // FuncDef = "def", Identifier, Parameters, ":", Suite => ActionFn(1721); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant45(__symbols); + let __sym2 = __pop_Variant47(__symbols); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1725::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1721::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 146) } @@ -24472,18 +24494,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1726); + // FuncDef = Decorator+, "def", Identifier, TypeParams, Parameters, ":", Suite => ActionFn(1722); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant45(__symbols); - let __sym3 = __pop_Variant92(__symbols); + let __sym4 = __pop_Variant47(__symbols); + let __sym3 = __pop_Variant94(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1726::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1722::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 146) } @@ -24495,17 +24517,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FuncDef = Decorator+, "def", Identifier, Parameters, ":", Suite => ActionFn(1727); + // FuncDef = Decorator+, "def", Identifier, Parameters, ":", Suite => ActionFn(1723); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant45(__symbols); + let __sym3 = __pop_Variant47(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant58(__symbols); + let __sym0 = __pop_Variant60(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1727::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1723::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 146) } @@ -24517,13 +24539,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FunctionArgument = NamedExpressionTest, CompFor => ActionFn(1514); + // FunctionArgument = NamedExpressionTest, CompFor => ActionFn(1510); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant53(__symbols); + let __sym1 = __pop_Variant55(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1514::<>(mode, __sym0, __sym1); + let __nt = super::__action1510::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (2, 147) } @@ -24535,11 +24557,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FunctionArgument = NamedExpressionTest => ActionFn(1515); + // FunctionArgument = NamedExpressionTest => ActionFn(1511); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1515::<>(mode, __sym0); + let __nt = super::__action1511::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (1, 147) } @@ -24551,14 +24573,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FunctionArgument = Identifier, "=", Test<"all"> => ActionFn(1269); + // FunctionArgument = Identifier, "=", Test<"all"> => ActionFn(1281); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1269::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1281::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (3, 147) } @@ -24570,13 +24592,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FunctionArgument = "*", Test<"all"> => ActionFn(1270); + // FunctionArgument = "*", Test<"all"> => ActionFn(1282); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1270::<>(mode, __sym0, __sym1); + let __nt = super::__action1282::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (2, 147) } @@ -24588,13 +24610,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // FunctionArgument = "**", Test<"all"> => ActionFn(1271); + // FunctionArgument = "**", Test<"all"> => ActionFn(1283); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1271::<>(mode, __sym0, __sym1); + let __nt = super::__action1283::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant30(__nt), __end)); (2, 147) } @@ -24611,7 +24633,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action441::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant67(__nt), __end)); + __symbols.push((__start, __Symbol::Variant69(__nt), __end)); (1, 148) } pub(crate) fn __reduce405< @@ -24626,7 +24648,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action442::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant67(__nt), __end)); + __symbols.push((__start, __Symbol::Variant69(__nt), __end)); (0, 148) } pub(crate) fn __reduce406< @@ -24637,13 +24659,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // GenericList = OneOrMore, "," => ActionFn(1272); + // GenericList = OneOrMore, "," => ActionFn(1284); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1272::<>(mode, __sym0, __sym1); + let __nt = super::__action1284::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 149) } @@ -24655,11 +24677,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // GenericList = OneOrMore => ActionFn(1273); + // GenericList = OneOrMore => ActionFn(1285); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1273::<>(mode, __sym0); + let __nt = super::__action1285::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 149) } @@ -24671,13 +24693,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // GenericList = OneOrMore, "," => ActionFn(1274); + // GenericList = OneOrMore, "," => ActionFn(1286); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1274::<>(mode, __sym0, __sym1); + let __nt = super::__action1286::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 150) } @@ -24689,11 +24711,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // GenericList = OneOrMore => ActionFn(1275); + // GenericList = OneOrMore => ActionFn(1287); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1275::<>(mode, __sym0); + let __nt = super::__action1287::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 150) } @@ -24705,13 +24727,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // GlobalStatement = "global", OneOrMore => ActionFn(1276); + // GlobalStatement = "global", OneOrMore => ActionFn(1288); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant77(__symbols); + let __sym1 = __pop_Variant79(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1276::<>(mode, __sym0, __sym1); + let __nt = super::__action1288::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 151) } @@ -24730,7 +24752,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action89::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (2, 152) } pub(crate) fn __reduce412< @@ -24741,11 +24763,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Identifier = name => ActionFn(1277); + // Identifier = name => ActionFn(1289); let __sym0 = __pop_Variant5(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1277::<>(mode, __sym0); + let __nt = super::__action1289::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant22(__nt), __end)); (1, 153) } @@ -24757,7 +24779,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // IfStatement = "if", NamedExpressionTest, ":", Suite, "else", ":", Suite => ActionFn(1123); + // IfStatement = "if", NamedExpressionTest, ":", Suite, "else", ":", Suite => ActionFn(1121); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -24768,7 +24790,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1123::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1121::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 154) } @@ -24780,7 +24802,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // IfStatement = "if", NamedExpressionTest, ":", Suite => ActionFn(1124); + // IfStatement = "if", NamedExpressionTest, ":", Suite => ActionFn(1122); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -24788,7 +24810,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1124::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1122::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 154) } @@ -24800,7 +24822,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // IfStatement = "if", NamedExpressionTest, ":", Suite, (<@L> "elif" ":" )+, "else", ":", Suite => ActionFn(1125); + // IfStatement = "if", NamedExpressionTest, ":", Suite, (<@L> "elif" ":" )+, "else", ":", Suite => ActionFn(1123); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant24(__symbols); let __sym6 = __pop_Variant0(__symbols); @@ -24812,7 +24834,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action1125::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action1123::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 154) } @@ -24824,7 +24846,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // IfStatement = "if", NamedExpressionTest, ":", Suite, (<@L> "elif" ":" )+ => ActionFn(1126); + // IfStatement = "if", NamedExpressionTest, ":", Suite, (<@L> "elif" ":" )+ => ActionFn(1124); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant27(__symbols); let __sym3 = __pop_Variant24(__symbols); @@ -24833,7 +24855,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1126::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1124::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 154) } @@ -24845,15 +24867,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = DottedName, "as", Identifier => ActionFn(1278); + // ImportAsAlias = DottedName, "as", Identifier => ActionFn(1290); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1278::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant68(__nt), __end)); + let __nt = super::__action1290::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant70(__nt), __end)); (3, 155) } pub(crate) fn __reduce418< @@ -24864,12 +24886,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = DottedName => ActionFn(1279); + // ImportAsAlias = DottedName => ActionFn(1291); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1279::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant68(__nt), __end)); + let __nt = super::__action1291::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant70(__nt), __end)); (1, 155) } pub(crate) fn __reduce419< @@ -24880,15 +24902,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = Identifier, "as", Identifier => ActionFn(1280); + // ImportAsAlias = Identifier, "as", Identifier => ActionFn(1292); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1280::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant68(__nt), __end)); + let __nt = super::__action1292::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant70(__nt), __end)); (3, 156) } pub(crate) fn __reduce420< @@ -24899,12 +24921,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsAlias = Identifier => ActionFn(1281); + // ImportAsAlias = Identifier => ActionFn(1293); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1281::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant68(__nt), __end)); + let __nt = super::__action1293::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant70(__nt), __end)); (1, 156) } pub(crate) fn __reduce421< @@ -24915,12 +24937,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = OneOrMore> => ActionFn(1282); - let __sym0 = __pop_Variant69(__symbols); + // ImportAsNames = OneOrMore> => ActionFn(1294); + let __sym0 = __pop_Variant71(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1282::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1294::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (1, 157) } pub(crate) fn __reduce422< @@ -24931,16 +24953,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = "(", OneOrMore>, ",", ")" => ActionFn(1283); + // ImportAsNames = "(", OneOrMore>, ",", ")" => ActionFn(1295); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant69(__symbols); + let __sym1 = __pop_Variant71(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1283::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1295::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (4, 157) } pub(crate) fn __reduce423< @@ -24951,15 +24973,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = "(", OneOrMore>, ")" => ActionFn(1284); + // ImportAsNames = "(", OneOrMore>, ")" => ActionFn(1296); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant69(__symbols); + let __sym1 = __pop_Variant71(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1284::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1296::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (3, 157) } pub(crate) fn __reduce424< @@ -24970,12 +24992,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportAsNames = "*" => ActionFn(1285); + // ImportAsNames = "*" => ActionFn(1297); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1285::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1297::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (1, 157) } pub(crate) fn __reduce425< @@ -24991,7 +25013,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action64::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant70(__nt), __end)); + __symbols.push((__start, __Symbol::Variant72(__nt), __end)); (1, 158) } pub(crate) fn __reduce426< @@ -25007,7 +25029,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action65::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant70(__nt), __end)); + __symbols.push((__start, __Symbol::Variant72(__nt), __end)); (1, 158) } pub(crate) fn __reduce427< @@ -25022,7 +25044,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action367::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant71(__nt), __end)); + __symbols.push((__start, __Symbol::Variant73(__nt), __end)); (0, 159) } pub(crate) fn __reduce428< @@ -25034,11 +25056,11 @@ mod __parse__Top { ) -> (usize, usize) { // ImportDots* = ImportDots+ => ActionFn(368); - let __sym0 = __pop_Variant71(__symbols); + let __sym0 = __pop_Variant73(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action368::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant71(__nt), __end)); + __symbols.push((__start, __Symbol::Variant73(__nt), __end)); (1, 159) } pub(crate) fn __reduce429< @@ -25050,11 +25072,11 @@ mod __parse__Top { ) -> (usize, usize) { // ImportDots+ = ImportDots => ActionFn(365); - let __sym0 = __pop_Variant70(__symbols); + let __sym0 = __pop_Variant72(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action365::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant71(__nt), __end)); + __symbols.push((__start, __Symbol::Variant73(__nt), __end)); (1, 160) } pub(crate) fn __reduce430< @@ -25067,12 +25089,12 @@ mod __parse__Top { { // ImportDots+ = ImportDots+, ImportDots => ActionFn(366); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant70(__symbols); - let __sym0 = __pop_Variant71(__symbols); + let __sym1 = __pop_Variant72(__symbols); + let __sym0 = __pop_Variant73(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action366::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant71(__nt), __end)); + __symbols.push((__start, __Symbol::Variant73(__nt), __end)); (2, 160) } pub(crate) fn __reduce431< @@ -25083,12 +25105,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportFromLocation = DottedName => ActionFn(1546); + // ImportFromLocation = DottedName => ActionFn(1542); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1546::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant72(__nt), __end)); + let __nt = super::__action1542::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant74(__nt), __end)); (1, 161) } pub(crate) fn __reduce432< @@ -25099,14 +25121,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportFromLocation = ImportDots+, DottedName => ActionFn(1547); + // ImportFromLocation = ImportDots+, DottedName => ActionFn(1543); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant22(__symbols); - let __sym0 = __pop_Variant71(__symbols); + let __sym0 = __pop_Variant73(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1547::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant72(__nt), __end)); + let __nt = super::__action1543::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant74(__nt), __end)); (2, 161) } pub(crate) fn __reduce433< @@ -25118,11 +25140,11 @@ mod __parse__Top { ) -> (usize, usize) { // ImportFromLocation = ImportDots+ => ActionFn(63); - let __sym0 = __pop_Variant71(__symbols); + let __sym0 = __pop_Variant73(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action63::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant72(__nt), __end)); + __symbols.push((__start, __Symbol::Variant74(__nt), __end)); (1, 161) } pub(crate) fn __reduce434< @@ -25133,13 +25155,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportStatement = "import", OneOrMore> => ActionFn(1286); + // ImportStatement = "import", OneOrMore> => ActionFn(1298); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant69(__symbols); + let __sym1 = __pop_Variant71(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1286::<>(mode, __sym0, __sym1); + let __nt = super::__action1298::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 162) } @@ -25151,15 +25173,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ImportStatement = "from", ImportFromLocation, "import", ImportAsNames => ActionFn(1287); + // ImportStatement = "from", ImportFromLocation, "import", ImportAsNames => ActionFn(1299); assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant69(__symbols); + let __sym3 = __pop_Variant71(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant72(__symbols); + let __sym1 = __pop_Variant74(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1287::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1299::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 162) } @@ -25171,13 +25193,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // KwargParameter = "**", DoubleStarTypedParameter => ActionFn(1536); + // KwargParameter = "**", DoubleStarTypedParameter => ActionFn(1532); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1536::<>(mode, __sym0, __sym1); + let __nt = super::__action1532::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (2, 166) } @@ -25189,11 +25211,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // KwargParameter = "**" => ActionFn(1537); + // KwargParameter = "**" => ActionFn(1533); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1537::<>(mode, __sym0); + let __nt = super::__action1533::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 166) } @@ -25205,13 +25227,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // KwargParameter = "**", StarUntypedParameter => ActionFn(987); + // KwargParameter = "**", StarUntypedParameter => ActionFn(985); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant63(__symbols); + let __sym1 = __pop_Variant65(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action987::<>(mode, __sym0, __sym1); + let __nt = super::__action985::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (2, 167) } @@ -25223,11 +25245,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // KwargParameter = "**" => ActionFn(988); + // KwargParameter = "**" => ActionFn(986); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action988::<>(mode, __sym0); + let __nt = super::__action986::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (1, 167) } @@ -25304,11 +25326,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // LiteralPattern = "None" => ActionFn(1292); + // LiteralPattern = "None" => ActionFn(1304); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1292::<>(mode, __sym0); + let __nt = super::__action1304::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 171) } @@ -25320,11 +25342,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // LiteralPattern = "True" => ActionFn(1293); + // LiteralPattern = "True" => ActionFn(1305); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1293::<>(mode, __sym0); + let __nt = super::__action1305::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 171) } @@ -25336,11 +25358,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // LiteralPattern = "False" => ActionFn(1294); + // LiteralPattern = "False" => ActionFn(1306); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1294::<>(mode, __sym0); + let __nt = super::__action1306::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 171) } @@ -25352,11 +25374,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // LiteralPattern = ConstantExpr => ActionFn(1295); + // LiteralPattern = ConstantExpr => ActionFn(1307); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1295::<>(mode, __sym0); + let __nt = super::__action1307::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 171) } @@ -25368,11 +25390,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // LiteralPattern = AddOpExpr => ActionFn(1296); + // LiteralPattern = AddOpExpr => ActionFn(1308); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1296::<>(mode, __sym0); + let __nt = super::__action1308::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 171) } @@ -25384,12 +25406,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingKey = ConstantExpr => ActionFn(126); - let __sym0 = __pop_Variant14(__symbols); + // MappingKey = MatchNameOrAttr => ActionFn(126); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action126::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } pub(crate) fn __reduce456< @@ -25400,12 +25422,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingKey = AddOpExpr => ActionFn(127); + // MappingKey = ConstantExpr => ActionFn(127); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action127::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } pub(crate) fn __reduce457< @@ -25416,12 +25438,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingKey = MatchNameOrAttr => ActionFn(128); + // MappingKey = AddOpExpr => ActionFn(128); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action128::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } pub(crate) fn __reduce458< @@ -25432,12 +25454,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingKey = "None" => ActionFn(1298); + // MappingKey = "None" => ActionFn(1310); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1298::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1310::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } pub(crate) fn __reduce459< @@ -25448,12 +25470,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingKey = "True" => ActionFn(1299); + // MappingKey = "True" => ActionFn(1311); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1299::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1311::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } pub(crate) fn __reduce460< @@ -25464,12 +25486,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingKey = "False" => ActionFn(1300); + // MappingKey = "False" => ActionFn(1312); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1300::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1312::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 172) } pub(crate) fn __reduce462< @@ -25480,13 +25502,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", "}" => ActionFn(1301); + // MappingPattern = "{", "}" => ActionFn(1313); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1301::<>(mode, __sym0, __sym1); + let __nt = super::__action1313::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 173) } @@ -25498,15 +25520,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", OneOrMore, ",", "}" => ActionFn(1302); + // MappingPattern = "{", OneOrMore, ",", "}" => ActionFn(1314); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant79(__symbols); + let __sym1 = __pop_Variant81(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1302::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1314::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (4, 173) } @@ -25518,14 +25540,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", OneOrMore, "}" => ActionFn(1303); + // MappingPattern = "{", OneOrMore, "}" => ActionFn(1315); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant79(__symbols); + let __sym1 = __pop_Variant81(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1303::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1315::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (3, 173) } @@ -25537,7 +25559,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", "**", Identifier, ",", "}" => ActionFn(1304); + // MappingPattern = "{", "**", Identifier, ",", "}" => ActionFn(1316); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -25546,7 +25568,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1304::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1316::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (5, 173) } @@ -25558,7 +25580,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", "**", Identifier, "}" => ActionFn(1305); + // MappingPattern = "{", "**", Identifier, "}" => ActionFn(1317); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant22(__symbols); @@ -25566,7 +25588,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1305::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1317::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (4, 173) } @@ -25578,18 +25600,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", OneOrMore, ",", "**", Identifier, ",", "}" => ActionFn(1306); + // MappingPattern = "{", OneOrMore, ",", "**", Identifier, ",", "}" => ActionFn(1318); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant22(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant79(__symbols); + let __sym1 = __pop_Variant81(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1306::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1318::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (7, 173) } @@ -25601,17 +25623,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MappingPattern = "{", OneOrMore, ",", "**", Identifier, "}" => ActionFn(1307); + // MappingPattern = "{", OneOrMore, ",", "**", Identifier, "}" => ActionFn(1319); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant22(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant79(__symbols); + let __sym1 = __pop_Variant81(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1307::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1319::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (6, 173) } @@ -25623,17 +25645,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchCase = "case", Patterns, Guard, ":", Suite => ActionFn(1487); + // MatchCase = "case", Patterns, Guard, ":", Suite => ActionFn(1483); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant14(__symbols); + let __sym2 = __pop_Variant45(__symbols); let __sym1 = __pop_Variant34(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1487::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant73(__nt), __end)); + let __nt = super::__action1483::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant75(__nt), __end)); (5, 174) } pub(crate) fn __reduce470< @@ -25644,7 +25666,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchCase = "case", Patterns, ":", Suite => ActionFn(1488); + // MatchCase = "case", Patterns, ":", Suite => ActionFn(1484); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -25652,8 +25674,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1488::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant73(__nt), __end)); + let __nt = super::__action1484::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant75(__nt), __end)); (4, 174) } pub(crate) fn __reduce471< @@ -25665,11 +25687,11 @@ mod __parse__Top { ) -> (usize, usize) { // MatchCase+ = MatchCase => ActionFn(345); - let __sym0 = __pop_Variant73(__symbols); + let __sym0 = __pop_Variant75(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action345::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant74(__nt), __end)); + __symbols.push((__start, __Symbol::Variant76(__nt), __end)); (1, 175) } pub(crate) fn __reduce472< @@ -25682,12 +25704,12 @@ mod __parse__Top { { // MatchCase+ = MatchCase+, MatchCase => ActionFn(346); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant73(__symbols); - let __sym0 = __pop_Variant74(__symbols); + let __sym1 = __pop_Variant75(__symbols); + let __sym0 = __pop_Variant76(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action346::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant74(__nt), __end)); + __symbols.push((__start, __Symbol::Variant76(__nt), __end)); (2, 175) } pub(crate) fn __reduce473< @@ -25698,15 +25720,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchKeywordEntry = Identifier, "=", Pattern => ActionFn(1308); + // MatchKeywordEntry = Identifier, "=", Pattern => ActionFn(1320); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant34(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1308::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant75(__nt), __end)); + let __nt = super::__action1320::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant77(__nt), __end)); (3, 176) } pub(crate) fn __reduce474< @@ -25721,11 +25743,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant34(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant14(__symbols); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action133::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant76(__nt), __end)); + __symbols.push((__start, __Symbol::Variant78(__nt), __end)); (3, 177) } pub(crate) fn __reduce475< @@ -25736,12 +25758,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchName = Identifier => ActionFn(1309); + // MatchName = Identifier => ActionFn(1321); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1309::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1321::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 178) } pub(crate) fn __reduce476< @@ -25752,15 +25774,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchNameOrAttr = MatchName, ".", Identifier => ActionFn(1310); + // MatchNameOrAttr = MatchName, ".", Identifier => ActionFn(1322); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant14(__symbols); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1310::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1322::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (3, 179) } pub(crate) fn __reduce477< @@ -25771,15 +25793,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchNameOrAttr = MatchNameOrAttr, ".", Identifier => ActionFn(1311); + // MatchNameOrAttr = MatchNameOrAttr, ".", Identifier => ActionFn(1323); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant14(__symbols); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1311::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1323::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (3, 179) } pub(crate) fn __reduce478< @@ -25790,10 +25812,10 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchStatement = "match", TestOrStarNamedExpr, ":", "\n", Indent, MatchCase+, Dedent => ActionFn(831); + // MatchStatement = "match", TestOrStarNamedExpr, ":", "\n", Indent, MatchCase+, Dedent => ActionFn(833); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant74(__symbols); + let __sym5 = __pop_Variant76(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -25801,7 +25823,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action831::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action833::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 180) } @@ -25813,10 +25835,10 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchStatement = "match", TestOrStarNamedExpr, ",", ":", "\n", Indent, MatchCase+, Dedent => ActionFn(832); + // MatchStatement = "match", TestOrStarNamedExpr, ",", ":", "\n", Indent, MatchCase+, Dedent => ActionFn(834); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant74(__symbols); + let __sym6 = __pop_Variant76(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -25825,7 +25847,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action832::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action834::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 180) } @@ -25837,10 +25859,10 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchStatement = "match", TwoOrMore, ",", ":", "\n", Indent, MatchCase+, Dedent => ActionFn(833); + // MatchStatement = "match", TwoOrMore, ",", ":", "\n", Indent, MatchCase+, Dedent => ActionFn(835); assert!(__symbols.len() >= 8); let __sym7 = __pop_Variant0(__symbols); - let __sym6 = __pop_Variant74(__symbols); + let __sym6 = __pop_Variant76(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -25849,7 +25871,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym7.2; - let __nt = super::__action833::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); + let __nt = super::__action835::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (8, 180) } @@ -25861,10 +25883,10 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // MatchStatement = "match", TwoOrMore, ":", "\n", Indent, MatchCase+, Dedent => ActionFn(834); + // MatchStatement = "match", TwoOrMore, ":", "\n", Indent, MatchCase+, Dedent => ActionFn(836); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant74(__symbols); + let __sym5 = __pop_Variant76(__symbols); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -25872,7 +25894,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action834::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action836::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 180) } @@ -25889,7 +25911,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action198::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 181) } pub(crate) fn __reduce483< @@ -25905,7 +25927,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action199::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 181) } pub(crate) fn __reduce484< @@ -25921,7 +25943,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action200::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 181) } pub(crate) fn __reduce485< @@ -25937,7 +25959,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action201::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 181) } pub(crate) fn __reduce486< @@ -25953,7 +25975,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action202::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 181) } pub(crate) fn __reduce487< @@ -25964,14 +25986,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // NamedExpression = NamedExpressionName, ":=", Test<"all"> => ActionFn(1312); + // NamedExpression = NamedExpressionName, ":=", Test<"all"> => ActionFn(1324); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1312::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1324::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 182) } @@ -25983,11 +26005,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // NamedExpressionName = Identifier => ActionFn(1313); + // NamedExpressionName = Identifier => ActionFn(1325); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1313::<>(mode, __sym0); + let __nt = super::__action1325::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 183) } @@ -26063,13 +26085,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // NonlocalStatement = "nonlocal", OneOrMore => ActionFn(1314); + // NonlocalStatement = "nonlocal", OneOrMore => ActionFn(1326); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant77(__symbols); + let __sym1 = __pop_Variant79(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1314::<>(mode, __sym0, __sym1); + let __nt = super::__action1326::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 186) } @@ -26081,13 +26103,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // NotTest<"all"> = "not", NotTest<"all"> => ActionFn(1315); + // NotTest<"all"> = "not", NotTest<"all"> => ActionFn(1327); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1315::<>(mode, __sym0, __sym1); + let __nt = super::__action1327::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 187) } @@ -26115,13 +26137,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // NotTest<"no-withitems"> = "not", NotTest<"all"> => ActionFn(1316); + // NotTest<"no-withitems"> = "not", NotTest<"all"> => ActionFn(1328); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1316::<>(mode, __sym0, __sym1); + let __nt = super::__action1328::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 188) } @@ -26150,11 +26172,11 @@ mod __parse__Top { ) -> (usize, usize) { // OneOrMore = DictElement => ActionFn(250); - let __sym0 = __pop_Variant59(__symbols); + let __sym0 = __pop_Variant61(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action250::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant61(__nt), __end)); + __symbols.push((__start, __Symbol::Variant63(__nt), __end)); (1, 189) } pub(crate) fn __reduce499< @@ -26167,13 +26189,13 @@ mod __parse__Top { { // OneOrMore = OneOrMore, ",", DictElement => ActionFn(251); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant59(__symbols); + let __sym2 = __pop_Variant61(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant61(__symbols); + let __sym0 = __pop_Variant63(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action251::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant61(__nt), __end)); + __symbols.push((__start, __Symbol::Variant63(__nt), __end)); (3, 189) } pub(crate) fn __reduce500< @@ -26224,7 +26246,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action355::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant77(__nt), __end)); + __symbols.push((__start, __Symbol::Variant79(__nt), __end)); (1, 191) } pub(crate) fn __reduce503< @@ -26239,11 +26261,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant77(__symbols); + let __sym0 = __pop_Variant79(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action356::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant77(__nt), __end)); + __symbols.push((__start, __Symbol::Variant79(__nt), __end)); (3, 191) } pub(crate) fn __reduce504< @@ -26254,15 +26276,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = DottedName, "as", Identifier => ActionFn(1538); + // OneOrMore> = DottedName, "as", Identifier => ActionFn(1534); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1538::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1534::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (3, 192) } pub(crate) fn __reduce505< @@ -26273,12 +26295,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = DottedName => ActionFn(1539); + // OneOrMore> = DottedName => ActionFn(1535); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1539::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1535::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (1, 192) } pub(crate) fn __reduce506< @@ -26289,17 +26311,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = OneOrMore>, ",", DottedName, "as", Identifier => ActionFn(1540); + // OneOrMore> = OneOrMore>, ",", DottedName, "as", Identifier => ActionFn(1536); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant22(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant69(__symbols); + let __sym0 = __pop_Variant71(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1540::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1536::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (5, 192) } pub(crate) fn __reduce507< @@ -26310,15 +26332,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = OneOrMore>, ",", DottedName => ActionFn(1541); + // OneOrMore> = OneOrMore>, ",", DottedName => ActionFn(1537); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant69(__symbols); + let __sym0 = __pop_Variant71(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1541::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1537::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (3, 192) } pub(crate) fn __reduce508< @@ -26329,15 +26351,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = Identifier, "as", Identifier => ActionFn(1542); + // OneOrMore> = Identifier, "as", Identifier => ActionFn(1538); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1542::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1538::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (3, 193) } pub(crate) fn __reduce509< @@ -26348,12 +26370,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = Identifier => ActionFn(1543); + // OneOrMore> = Identifier => ActionFn(1539); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1543::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1539::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (1, 193) } pub(crate) fn __reduce510< @@ -26364,17 +26386,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = OneOrMore>, ",", Identifier, "as", Identifier => ActionFn(1544); + // OneOrMore> = OneOrMore>, ",", Identifier, "as", Identifier => ActionFn(1540); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant22(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant69(__symbols); + let __sym0 = __pop_Variant71(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1544::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1540::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (5, 193) } pub(crate) fn __reduce511< @@ -26385,15 +26407,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OneOrMore> = OneOrMore>, ",", Identifier => ActionFn(1545); + // OneOrMore> = OneOrMore>, ",", Identifier => ActionFn(1541); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant22(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant69(__symbols); + let __sym0 = __pop_Variant71(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1545::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant69(__nt), __end)); + let __nt = super::__action1541::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant71(__nt), __end)); (3, 193) } pub(crate) fn __reduce512< @@ -26405,11 +26427,11 @@ mod __parse__Top { ) -> (usize, usize) { // OneOrMore = MatchKeywordEntry => ActionFn(323); - let __sym0 = __pop_Variant75(__symbols); + let __sym0 = __pop_Variant77(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action323::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant78(__nt), __end)); + __symbols.push((__start, __Symbol::Variant80(__nt), __end)); (1, 194) } pub(crate) fn __reduce513< @@ -26422,13 +26444,13 @@ mod __parse__Top { { // OneOrMore = OneOrMore, ",", MatchKeywordEntry => ActionFn(324); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant75(__symbols); + let __sym2 = __pop_Variant77(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant78(__symbols); + let __sym0 = __pop_Variant80(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action324::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant78(__nt), __end)); + __symbols.push((__start, __Symbol::Variant80(__nt), __end)); (3, 194) } pub(crate) fn __reduce514< @@ -26440,11 +26462,11 @@ mod __parse__Top { ) -> (usize, usize) { // OneOrMore = MatchMappingEntry => ActionFn(327); - let __sym0 = __pop_Variant76(__symbols); + let __sym0 = __pop_Variant78(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action327::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant79(__nt), __end)); + __symbols.push((__start, __Symbol::Variant81(__nt), __end)); (1, 195) } pub(crate) fn __reduce515< @@ -26457,13 +26479,13 @@ mod __parse__Top { { // OneOrMore = OneOrMore, ",", MatchMappingEntry => ActionFn(328); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant76(__symbols); + let __sym2 = __pop_Variant78(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant79(__symbols); + let __sym0 = __pop_Variant81(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action328::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant79(__nt), __end)); + __symbols.push((__start, __Symbol::Variant81(__nt), __end)); (3, 195) } pub(crate) fn __reduce516< @@ -26479,7 +26501,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action464::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant80(__nt), __end)); + __symbols.push((__start, __Symbol::Variant82(__nt), __end)); (1, 196) } pub(crate) fn __reduce517< @@ -26494,11 +26516,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant10(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action465::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant80(__nt), __end)); + __symbols.push((__start, __Symbol::Variant82(__nt), __end)); (3, 196) } pub(crate) fn __reduce518< @@ -26514,7 +26536,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action453::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant80(__nt), __end)); + __symbols.push((__start, __Symbol::Variant82(__nt), __end)); (1, 197) } pub(crate) fn __reduce519< @@ -26529,11 +26551,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant10(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action454::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant80(__nt), __end)); + __symbols.push((__start, __Symbol::Variant82(__nt), __end)); (3, 197) } pub(crate) fn __reduce520< @@ -26549,7 +26571,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action325::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (1, 198) } pub(crate) fn __reduce521< @@ -26564,11 +26586,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant34(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant52(__symbols); + let __sym0 = __pop_Variant54(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action326::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (3, 198) } pub(crate) fn __reduce522< @@ -26685,11 +26707,11 @@ mod __parse__Top { ) -> (usize, usize) { // OneOrMore = TypeParam => ActionFn(264); - let __sym0 = __pop_Variant91(__symbols); + let __sym0 = __pop_Variant93(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action264::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant81(__nt), __end)); + __symbols.push((__start, __Symbol::Variant83(__nt), __end)); (1, 202) } pub(crate) fn __reduce529< @@ -26702,13 +26724,13 @@ mod __parse__Top { { // OneOrMore = OneOrMore, ",", TypeParam => ActionFn(265); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant91(__symbols); + let __sym2 = __pop_Variant93(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant81(__symbols); + let __sym0 = __pop_Variant83(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action265::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant81(__nt), __end)); + __symbols.push((__start, __Symbol::Variant83(__nt), __end)); (3, 202) } pub(crate) fn __reduce530< @@ -26735,11 +26757,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OrPattern = TwoOrMore => ActionFn(1317); - let __sym0 = __pop_Variant52(__symbols); + // OrPattern = TwoOrMore => ActionFn(1329); + let __sym0 = __pop_Variant54(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1317::<>(mode, __sym0); + let __nt = super::__action1329::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 203) } @@ -26751,13 +26773,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OrTest<"all"> = (> "or")+, AndTest<"all"> => ActionFn(1318); + // OrTest<"all"> = (> "or")+, AndTest<"all"> => ActionFn(1330); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1318::<>(mode, __sym0, __sym1); + let __nt = super::__action1330::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 204) } @@ -26785,13 +26807,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // OrTest<"no-withitems"> = (> "or")+, AndTest<"all"> => ActionFn(1319); + // OrTest<"no-withitems"> = (> "or")+, AndTest<"all"> => ActionFn(1331); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant16(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1319::<>(mode, __sym0, __sym1); + let __nt = super::__action1331::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 205) } @@ -26835,14 +26857,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ParameterDef = TypedParameter, "=", Test<"all"> => ActionFn(1320); + // ParameterDef = TypedParameter, "=", Test<"all"> => ActionFn(1332); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant10(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1320::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1332::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (3, 206) } @@ -26870,14 +26892,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ParameterDef = UntypedParameter, "=", Test<"all"> => ActionFn(1321); + // ParameterDef = UntypedParameter, "=", Test<"all"> => ActionFn(1333); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant10(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1321::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1333::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (3, 207) } @@ -26890,11 +26912,11 @@ mod __parse__Top { ) -> (usize, usize) { // ParameterDefs = OneOrMore> => ActionFn(422); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action422::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant82(__nt), __end)); + __symbols.push((__start, __Symbol::Variant84(__nt), __end)); (1, 208) } pub(crate) fn __reduce541< @@ -26909,11 +26931,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action673::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant82(__nt), __end)); + __symbols.push((__start, __Symbol::Variant84(__nt), __end)); (3, 208) } pub(crate) fn __reduce542< @@ -26929,11 +26951,11 @@ mod __parse__Top { let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; let __nt = super::__action674::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant82(__nt), __end)); + __symbols.push((__start, __Symbol::Variant84(__nt), __end)); (4, 208) } pub(crate) fn __reduce543< @@ -26945,11 +26967,11 @@ mod __parse__Top { ) -> (usize, usize) { // ParameterDefs = OneOrMore> => ActionFn(430); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action430::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant82(__nt), __end)); + __symbols.push((__start, __Symbol::Variant84(__nt), __end)); (1, 209) } pub(crate) fn __reduce544< @@ -26964,11 +26986,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action681::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant82(__nt), __end)); + __symbols.push((__start, __Symbol::Variant84(__nt), __end)); (3, 209) } pub(crate) fn __reduce545< @@ -26984,11 +27006,11 @@ mod __parse__Top { let __sym3 = __pop_Variant11(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant80(__symbols); + let __sym0 = __pop_Variant82(__symbols); let __start = __sym0.0; let __end = __sym3.2; let __nt = super::__action682::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant82(__nt), __end)); + __symbols.push((__start, __Symbol::Variant84(__nt), __end)); (4, 209) } pub(crate) fn __reduce622< @@ -26999,14 +27021,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ParameterList = KwargParameter, "," => ActionFn(1358); + // ParameterList = KwargParameter, "," => ActionFn(1370); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1358::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + let __nt = super::__action1370::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 210) } pub(crate) fn __reduce623< @@ -27017,12 +27039,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ParameterList = KwargParameter => ActionFn(1359); + // ParameterList = KwargParameter => ActionFn(1371); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1359::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + let __nt = super::__action1371::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 210) } pub(crate) fn __reduce700< @@ -27033,14 +27055,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ParameterList = KwargParameter, "," => ActionFn(1396); + // ParameterList = KwargParameter, "," => ActionFn(1408); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1396::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + let __nt = super::__action1408::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (2, 211) } pub(crate) fn __reduce701< @@ -27051,12 +27073,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ParameterList = KwargParameter => ActionFn(1397); + // ParameterList = KwargParameter => ActionFn(1409); let __sym0 = __pop_Variant8(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1397::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant45(__nt), __end)); + let __nt = super::__action1409::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant47(__nt), __end)); (1, 211) } pub(crate) fn __reduce702< @@ -27068,11 +27090,11 @@ mod __parse__Top { ) -> (usize, usize) { // ParameterList? = ParameterList => ActionFn(258); - let __sym0 = __pop_Variant45(__symbols); + let __sym0 = __pop_Variant47(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action258::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant46(__nt), __end)); + __symbols.push((__start, __Symbol::Variant48(__nt), __end)); (1, 212) } pub(crate) fn __reduce703< @@ -27087,7 +27109,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action259::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant46(__nt), __end)); + __symbols.push((__start, __Symbol::Variant48(__nt), __end)); (0, 212) } pub(crate) fn __reduce722< @@ -27098,11 +27120,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PassStatement = "pass" => ActionFn(1399); + // PassStatement = "pass" => ActionFn(1411); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1399::<>(mode, __sym0); + let __nt = super::__action1411::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 216) } @@ -27151,7 +27173,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action405::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant83(__nt), __end)); + __symbols.push((__start, __Symbol::Variant85(__nt), __end)); (1, 218) } pub(crate) fn __reduce726< @@ -27166,7 +27188,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action406::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant83(__nt), __end)); + __symbols.push((__start, __Symbol::Variant85(__nt), __end)); (0, 218) } pub(crate) fn __reduce727< @@ -27177,18 +27199,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", OneOrMore, ",", OneOrMore, ",", ")" => ActionFn(1400); + // PatternArguments = "(", OneOrMore, ",", OneOrMore, ",", ")" => ActionFn(1412); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant78(__symbols); + let __sym3 = __pop_Variant80(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant52(__symbols); + let __sym1 = __pop_Variant54(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1400::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1412::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (6, 219) } pub(crate) fn __reduce728< @@ -27199,17 +27221,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", OneOrMore, ",", OneOrMore, ")" => ActionFn(1401); + // PatternArguments = "(", OneOrMore, ",", OneOrMore, ")" => ActionFn(1413); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant78(__symbols); + let __sym3 = __pop_Variant80(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant52(__symbols); + let __sym1 = __pop_Variant54(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1401::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1413::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (5, 219) } pub(crate) fn __reduce729< @@ -27220,16 +27242,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", OneOrMore, ",", ")" => ActionFn(1402); + // PatternArguments = "(", OneOrMore, ",", ")" => ActionFn(1414); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant52(__symbols); + let __sym1 = __pop_Variant54(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1402::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1414::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (4, 219) } pub(crate) fn __reduce730< @@ -27240,15 +27262,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", OneOrMore, ")" => ActionFn(1403); + // PatternArguments = "(", OneOrMore, ")" => ActionFn(1415); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant52(__symbols); + let __sym1 = __pop_Variant54(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1403::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1415::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (3, 219) } pub(crate) fn __reduce731< @@ -27259,16 +27281,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", OneOrMore, ",", ")" => ActionFn(1404); + // PatternArguments = "(", OneOrMore, ",", ")" => ActionFn(1416); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant78(__symbols); + let __sym1 = __pop_Variant80(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1404::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1416::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (4, 219) } pub(crate) fn __reduce732< @@ -27279,15 +27301,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", OneOrMore, ")" => ActionFn(1405); + // PatternArguments = "(", OneOrMore, ")" => ActionFn(1417); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant78(__symbols); + let __sym1 = __pop_Variant80(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1405::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1417::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (3, 219) } pub(crate) fn __reduce733< @@ -27298,14 +27320,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // PatternArguments = "(", ")" => ActionFn(1406); + // PatternArguments = "(", ")" => ActionFn(1418); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1406::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant84(__nt), __end)); + let __nt = super::__action1418::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant86(__nt), __end)); (2, 219) } pub(crate) fn __reduce734< @@ -27316,13 +27338,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Patterns = Pattern, "," => ActionFn(1407); + // Patterns = Pattern, "," => ActionFn(1419); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant34(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1407::<>(mode, __sym0, __sym1); + let __nt = super::__action1419::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 220) } @@ -27334,13 +27356,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Patterns = TwoOrMore, "," => ActionFn(1408); + // Patterns = TwoOrMore, "," => ActionFn(1420); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant52(__symbols); + let __sym0 = __pop_Variant54(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1408::<>(mode, __sym0, __sym1); + let __nt = super::__action1420::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 220) } @@ -27352,11 +27374,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Patterns = TwoOrMore => ActionFn(1409); - let __sym0 = __pop_Variant52(__symbols); + // Patterns = TwoOrMore => ActionFn(1421); + let __sym0 = __pop_Variant54(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1409::<>(mode, __sym0); + let __nt = super::__action1421::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 220) } @@ -27384,14 +27406,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Power<"all"> = AtomExpr<"all">, "**", Factor<"all"> => ActionFn(1410); + // Power<"all"> = AtomExpr<"all">, "**", Factor<"all"> => ActionFn(1422); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1410::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1422::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 221) } @@ -27419,14 +27441,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Power<"no-withitems"> = AtomExpr<"all">, "**", Factor<"all"> => ActionFn(1411); + // Power<"no-withitems"> = AtomExpr<"all">, "**", Factor<"all"> => ActionFn(1423); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1411::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1423::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 222) } @@ -27487,7 +27509,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Program = Program, SmallStatement, ";", "\n" => ActionFn(1158); + // Program = Program, SmallStatement, ";", "\n" => ActionFn(1156); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -27495,7 +27517,7 @@ mod __parse__Top { let __sym0 = __pop_Variant24(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1158::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1156::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (4, 223) } @@ -27507,7 +27529,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Program = Program, ( ";")+, SmallStatement, ";", "\n" => ActionFn(1159); + // Program = Program, ( ";")+, SmallStatement, ";", "\n" => ActionFn(1157); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -27516,7 +27538,7 @@ mod __parse__Top { let __sym0 = __pop_Variant24(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1159::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1157::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (5, 223) } @@ -27528,14 +27550,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Program = Program, SmallStatement, "\n" => ActionFn(1160); + // Program = Program, SmallStatement, "\n" => ActionFn(1158); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant36(__symbols); let __sym0 = __pop_Variant24(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1160::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1158::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (3, 223) } @@ -27547,7 +27569,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Program = Program, ( ";")+, SmallStatement, "\n" => ActionFn(1161); + // Program = Program, ( ";")+, SmallStatement, "\n" => ActionFn(1159); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant36(__symbols); @@ -27555,7 +27577,7 @@ mod __parse__Top { let __sym0 = __pop_Variant24(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1161::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1159::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (4, 223) } @@ -27585,11 +27607,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // RaiseStatement = "raise" => ActionFn(1412); + // RaiseStatement = "raise" => ActionFn(1424); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1412::<>(mode, __sym0); + let __nt = super::__action1424::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (1, 224) } @@ -27601,7 +27623,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // RaiseStatement = "raise", Test<"all">, "from", Test<"all"> => ActionFn(1413); + // RaiseStatement = "raise", Test<"all">, "from", Test<"all"> => ActionFn(1425); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -27609,7 +27631,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1413::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1425::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 224) } @@ -27621,13 +27643,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // RaiseStatement = "raise", Test<"all"> => ActionFn(1414); + // RaiseStatement = "raise", Test<"all"> => ActionFn(1426); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1414::<>(mode, __sym0, __sym1); + let __nt = super::__action1426::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (2, 224) } @@ -27639,14 +27661,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "(", Pattern, ")" => ActionFn(1415); + // SequencePattern = "(", Pattern, ")" => ActionFn(1427); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant34(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1415::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1427::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (3, 225) } @@ -27658,13 +27680,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "(", ")" => ActionFn(1416); + // SequencePattern = "(", ")" => ActionFn(1428); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1416::<>(mode, __sym0, __sym1); + let __nt = super::__action1428::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 225) } @@ -27676,7 +27698,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "(", Pattern, ",", ")" => ActionFn(1417); + // SequencePattern = "(", Pattern, ",", ")" => ActionFn(1429); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -27684,7 +27706,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1417::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1429::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (4, 225) } @@ -27696,7 +27718,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "(", ( ",")+, Pattern, ",", ")" => ActionFn(1418); + // SequencePattern = "(", ( ",")+, Pattern, ",", ")" => ActionFn(1430); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -27705,7 +27727,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1418::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1430::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (5, 225) } @@ -27717,7 +27739,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "(", ( ",")+, Pattern, ")" => ActionFn(1419); + // SequencePattern = "(", ( ",")+, Pattern, ")" => ActionFn(1431); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant34(__symbols); @@ -27725,7 +27747,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1419::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1431::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (4, 225) } @@ -27737,14 +27759,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "[", Pattern, "]" => ActionFn(1510); + // SequencePattern = "[", Pattern, "]" => ActionFn(1506); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant34(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1510::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1506::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (3, 225) } @@ -27756,13 +27778,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "[", "]" => ActionFn(1511); + // SequencePattern = "[", "]" => ActionFn(1507); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1511::<>(mode, __sym0, __sym1); + let __nt = super::__action1507::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 225) } @@ -27774,7 +27796,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "[", ( ",")+, Pattern, "]" => ActionFn(1512); + // SequencePattern = "[", ( ",")+, Pattern, "]" => ActionFn(1508); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant34(__symbols); @@ -27782,7 +27804,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1512::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1508::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (4, 225) } @@ -27794,14 +27816,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SequencePattern = "[", ( ",")+, "]" => ActionFn(1513); + // SequencePattern = "[", ( ",")+, "]" => ActionFn(1509); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant35(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1513::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1509::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (3, 225) } @@ -27847,14 +27869,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ShiftExpression<"all"> = ShiftExpression<"all">, ShiftOp, ArithmeticExpression<"all"> => ActionFn(1421); + // ShiftExpression<"all"> = ShiftExpression<"all">, ShiftOp, ArithmeticExpression<"all"> => ActionFn(1433); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1421::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1433::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 227) } @@ -27882,14 +27904,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ShiftExpression<"no-withitems"> = ShiftExpression<"all">, ShiftOp, ArithmeticExpression<"all"> => ActionFn(1422); + // ShiftExpression<"no-withitems"> = ShiftExpression<"all">, ShiftOp, ArithmeticExpression<"all"> => ActionFn(1434); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1422::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1434::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 228) } @@ -27922,7 +27944,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action194::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 229) } pub(crate) fn __reduce768< @@ -27938,7 +27960,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action195::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant48(__nt), __end)); + __symbols.push((__start, __Symbol::Variant50(__nt), __end)); (1, 229) } pub(crate) fn __reduce769< @@ -27949,7 +27971,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SingleForComprehension = "async", "for", ExpressionList, "in", OrTest<"all"> => ActionFn(1516); + // SingleForComprehension = "async", "for", ExpressionList, "in", OrTest<"all"> => ActionFn(1512); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant14(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -27958,8 +27980,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1516::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant85(__nt), __end)); + let __nt = super::__action1512::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant87(__nt), __end)); (5, 230) } pub(crate) fn __reduce770< @@ -27970,7 +27992,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SingleForComprehension = "async", "for", ExpressionList, "in", OrTest<"all">, ComprehensionIf+ => ActionFn(1517); + // SingleForComprehension = "async", "for", ExpressionList, "in", OrTest<"all">, ComprehensionIf+ => ActionFn(1513); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant16(__symbols); let __sym4 = __pop_Variant14(__symbols); @@ -27980,8 +28002,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1517::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); - __symbols.push((__start, __Symbol::Variant85(__nt), __end)); + let __nt = super::__action1513::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + __symbols.push((__start, __Symbol::Variant87(__nt), __end)); (6, 230) } pub(crate) fn __reduce771< @@ -27992,7 +28014,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SingleForComprehension = "for", ExpressionList, "in", OrTest<"all"> => ActionFn(1518); + // SingleForComprehension = "for", ExpressionList, "in", OrTest<"all"> => ActionFn(1514); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -28000,8 +28022,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1518::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant85(__nt), __end)); + let __nt = super::__action1514::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant87(__nt), __end)); (4, 230) } pub(crate) fn __reduce772< @@ -28012,7 +28034,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SingleForComprehension = "for", ExpressionList, "in", OrTest<"all">, ComprehensionIf+ => ActionFn(1519); + // SingleForComprehension = "for", ExpressionList, "in", OrTest<"all">, ComprehensionIf+ => ActionFn(1515); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant16(__symbols); let __sym3 = __pop_Variant14(__symbols); @@ -28021,8 +28043,8 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1519::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant85(__nt), __end)); + let __nt = super::__action1515::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant87(__nt), __end)); (5, 230) } pub(crate) fn __reduce773< @@ -28034,11 +28056,11 @@ mod __parse__Top { ) -> (usize, usize) { // SingleForComprehension+ = SingleForComprehension => ActionFn(244); - let __sym0 = __pop_Variant85(__symbols); + let __sym0 = __pop_Variant87(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action244::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant86(__nt), __end)); + __symbols.push((__start, __Symbol::Variant88(__nt), __end)); (1, 231) } pub(crate) fn __reduce774< @@ -28051,12 +28073,12 @@ mod __parse__Top { { // SingleForComprehension+ = SingleForComprehension+, SingleForComprehension => ActionFn(245); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant85(__symbols); - let __sym0 = __pop_Variant86(__symbols); + let __sym1 = __pop_Variant87(__symbols); + let __sym0 = __pop_Variant88(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action245::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant86(__nt), __end)); + __symbols.push((__start, __Symbol::Variant88(__nt), __end)); (2, 231) } pub(crate) fn __reduce775< @@ -28067,14 +28089,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SliceOp = ":", Test<"all"> => ActionFn(1678); + // SliceOp = ":", Test<"all"> => ActionFn(1674); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1678::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant87(__nt), __end)); + let __nt = super::__action1674::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant89(__nt), __end)); (2, 232) } pub(crate) fn __reduce776< @@ -28085,12 +28107,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SliceOp = ":" => ActionFn(1679); + // SliceOp = ":" => ActionFn(1675); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1679::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant87(__nt), __end)); + let __nt = super::__action1675::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant89(__nt), __end)); (1, 232) } pub(crate) fn __reduce777< @@ -28102,11 +28124,11 @@ mod __parse__Top { ) -> (usize, usize) { // SliceOp? = SliceOp => ActionFn(254); - let __sym0 = __pop_Variant87(__symbols); + let __sym0 = __pop_Variant89(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action254::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant88(__nt), __end)); + __symbols.push((__start, __Symbol::Variant90(__nt), __end)); (1, 233) } pub(crate) fn __reduce778< @@ -28121,7 +28143,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action255::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant88(__nt), __end)); + __symbols.push((__start, __Symbol::Variant90(__nt), __end)); (0, 233) } pub(crate) fn __reduce779< @@ -28308,13 +28330,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // StarExpr = "*", Expression<"all"> => ActionFn(1425); + // StarExpr = "*", Expression<"all"> => ActionFn(1437); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1425::<>(mode, __sym0, __sym1); + let __nt = super::__action1437::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 235) } @@ -28326,13 +28348,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // StarPattern = "*", Identifier => ActionFn(1426); + // StarPattern = "*", Identifier => ActionFn(1438); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1426::<>(mode, __sym0, __sym1); + let __nt = super::__action1438::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (2, 236) } @@ -28344,15 +28366,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // StarTypedParameter = Identifier, ":", TestOrStarExpr => ActionFn(1427); + // StarTypedParameter = Identifier, ":", TestOrStarExpr => ActionFn(1439); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1427::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant63(__nt), __end)); + let __nt = super::__action1439::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant65(__nt), __end)); (3, 237) } pub(crate) fn __reduce793< @@ -28363,12 +28385,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // StarTypedParameter = Identifier => ActionFn(1428); + // StarTypedParameter = Identifier => ActionFn(1440); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1428::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant63(__nt), __end)); + let __nt = super::__action1440::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant65(__nt), __end)); (1, 237) } pub(crate) fn __reduce794< @@ -28380,11 +28402,11 @@ mod __parse__Top { ) -> (usize, usize) { // StarTypedParameter? = StarTypedParameter => ActionFn(473); - let __sym0 = __pop_Variant63(__symbols); + let __sym0 = __pop_Variant65(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action473::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant64(__nt), __end)); + __symbols.push((__start, __Symbol::Variant66(__nt), __end)); (1, 238) } pub(crate) fn __reduce795< @@ -28399,7 +28421,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action474::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant64(__nt), __end)); + __symbols.push((__start, __Symbol::Variant66(__nt), __end)); (0, 238) } pub(crate) fn __reduce796< @@ -28410,12 +28432,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // StarUntypedParameter = Identifier => ActionFn(1429); + // StarUntypedParameter = Identifier => ActionFn(1441); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1429::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant63(__nt), __end)); + let __nt = super::__action1441::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant65(__nt), __end)); (1, 239) } pub(crate) fn __reduce797< @@ -28427,11 +28449,11 @@ mod __parse__Top { ) -> (usize, usize) { // StarUntypedParameter? = StarUntypedParameter => ActionFn(462); - let __sym0 = __pop_Variant63(__symbols); + let __sym0 = __pop_Variant65(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action462::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant64(__nt), __end)); + __symbols.push((__start, __Symbol::Variant66(__nt), __end)); (1, 240) } pub(crate) fn __reduce798< @@ -28446,7 +28468,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action463::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant64(__nt), __end)); + __symbols.push((__start, __Symbol::Variant66(__nt), __end)); (0, 240) } pub(crate) fn __reduce799< @@ -28457,15 +28479,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = SmallStatement, ";", "\n" => ActionFn(1162); + // Statements = SmallStatement, ";", "\n" => ActionFn(1160); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1162::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1160::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (3, 241) } pub(crate) fn __reduce800< @@ -28476,7 +28498,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = ( ";")+, SmallStatement, ";", "\n" => ActionFn(1163); + // Statements = ( ";")+, SmallStatement, ";", "\n" => ActionFn(1161); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -28484,8 +28506,8 @@ mod __parse__Top { let __sym0 = __pop_Variant37(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1163::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1161::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (4, 241) } pub(crate) fn __reduce801< @@ -28496,14 +28518,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = SmallStatement, "\n" => ActionFn(1164); + // Statements = SmallStatement, "\n" => ActionFn(1162); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1164::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1162::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (2, 241) } pub(crate) fn __reduce802< @@ -28514,15 +28536,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = ( ";")+, SmallStatement, "\n" => ActionFn(1165); + // Statements = ( ";")+, SmallStatement, "\n" => ActionFn(1163); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant36(__symbols); let __sym0 = __pop_Variant37(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1165::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1163::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (3, 241) } pub(crate) fn __reduce803< @@ -28538,7 +28560,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action10::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (1, 241) } pub(crate) fn __reduce804< @@ -28552,11 +28574,11 @@ mod __parse__Top { // Statements = Statements, CompoundStatement => ActionFn(11); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant36(__symbols); - let __sym0 = __pop_Variant89(__symbols); + let __sym0 = __pop_Variant91(__symbols); let __start = __sym0.0; let __end = __sym1.2; let __nt = super::__action11::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (2, 241) } pub(crate) fn __reduce805< @@ -28567,16 +28589,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = Statements, SmallStatement, ";", "\n" => ActionFn(1166); + // Statements = Statements, SmallStatement, ";", "\n" => ActionFn(1164); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant36(__symbols); - let __sym0 = __pop_Variant89(__symbols); + let __sym0 = __pop_Variant91(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1166::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1164::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (4, 241) } pub(crate) fn __reduce806< @@ -28587,17 +28609,17 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = Statements, ( ";")+, SmallStatement, ";", "\n" => ActionFn(1167); + // Statements = Statements, ( ";")+, SmallStatement, ";", "\n" => ActionFn(1165); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant36(__symbols); let __sym1 = __pop_Variant37(__symbols); - let __sym0 = __pop_Variant89(__symbols); + let __sym0 = __pop_Variant91(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1167::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1165::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (5, 241) } pub(crate) fn __reduce807< @@ -28608,15 +28630,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = Statements, SmallStatement, "\n" => ActionFn(1168); + // Statements = Statements, SmallStatement, "\n" => ActionFn(1166); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant36(__symbols); - let __sym0 = __pop_Variant89(__symbols); + let __sym0 = __pop_Variant91(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1168::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1166::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (3, 241) } pub(crate) fn __reduce808< @@ -28627,16 +28649,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Statements = Statements, ( ";")+, SmallStatement, "\n" => ActionFn(1169); + // Statements = Statements, ( ";")+, SmallStatement, "\n" => ActionFn(1167); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant36(__symbols); let __sym1 = __pop_Variant37(__symbols); - let __sym0 = __pop_Variant89(__symbols); + let __sym0 = __pop_Variant91(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1169::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant89(__nt), __end)); + let __nt = super::__action1167::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant91(__nt), __end)); (4, 241) } pub(crate) fn __reduce809< @@ -28663,15 +28685,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = Test<"all">, ":", Test<"all">, SliceOp => ActionFn(1680); + // Subscript = Test<"all">, ":", Test<"all">, SliceOp => ActionFn(1676); assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant87(__symbols); + let __sym3 = __pop_Variant89(__symbols); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1680::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1676::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (4, 242) } @@ -28683,14 +28705,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = Test<"all">, ":", SliceOp => ActionFn(1681); + // Subscript = Test<"all">, ":", SliceOp => ActionFn(1677); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant87(__symbols); + let __sym2 = __pop_Variant89(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1681::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1677::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 242) } @@ -28702,14 +28724,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = ":", Test<"all">, SliceOp => ActionFn(1682); + // Subscript = ":", Test<"all">, SliceOp => ActionFn(1678); assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant87(__symbols); + let __sym2 = __pop_Variant89(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1682::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1678::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 242) } @@ -28721,13 +28743,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = ":", SliceOp => ActionFn(1683); + // Subscript = ":", SliceOp => ActionFn(1679); assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant87(__symbols); + let __sym1 = __pop_Variant89(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1683::<>(mode, __sym0, __sym1); + let __nt = super::__action1679::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 242) } @@ -28739,14 +28761,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = Test<"all">, ":", Test<"all"> => ActionFn(1684); + // Subscript = Test<"all">, ":", Test<"all"> => ActionFn(1680); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1684::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1680::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 242) } @@ -28758,13 +28780,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = Test<"all">, ":" => ActionFn(1685); + // Subscript = Test<"all">, ":" => ActionFn(1681); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1685::<>(mode, __sym0, __sym1); + let __nt = super::__action1681::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 242) } @@ -28776,13 +28798,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = ":", Test<"all"> => ActionFn(1686); + // Subscript = ":", Test<"all"> => ActionFn(1682); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1686::<>(mode, __sym0, __sym1); + let __nt = super::__action1682::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 242) } @@ -28794,11 +28816,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Subscript = ":" => ActionFn(1687); + // Subscript = ":" => ActionFn(1683); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1687::<>(mode, __sym0); + let __nt = super::__action1683::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 242) } @@ -28810,11 +28832,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SubscriptList = Subscript => ActionFn(1431); + // SubscriptList = Subscript => ActionFn(206); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1431::<>(mode, __sym0); + let __nt = super::__action206::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 243) } @@ -28826,13 +28848,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SubscriptList = Subscript, "," => ActionFn(1432); + // SubscriptList = Subscript, "," => ActionFn(1443); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1432::<>(mode, __sym0, __sym1); + let __nt = super::__action1443::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 243) } @@ -28844,13 +28866,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SubscriptList = TwoOrMore, "," => ActionFn(1433); + // SubscriptList = TwoOrMore, "," => ActionFn(1444); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1433::<>(mode, __sym0, __sym1); + let __nt = super::__action1444::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 243) } @@ -28862,11 +28884,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // SubscriptList = TwoOrMore => ActionFn(1434); + // SubscriptList = TwoOrMore => ActionFn(1445); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1434::<>(mode, __sym0); + let __nt = super::__action1445::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 243) } @@ -28878,14 +28900,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Suite = SmallStatement, ";", "\n" => ActionFn(1170); + // Suite = SmallStatement, ";", "\n" => ActionFn(1168); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1170::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1168::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (3, 244) } @@ -28897,7 +28919,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Suite = ( ";")+, SmallStatement, ";", "\n" => ActionFn(1171); + // Suite = ( ";")+, SmallStatement, ";", "\n" => ActionFn(1169); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -28905,7 +28927,7 @@ mod __parse__Top { let __sym0 = __pop_Variant37(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1171::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1169::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (4, 244) } @@ -28917,13 +28939,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Suite = SmallStatement, "\n" => ActionFn(1172); + // Suite = SmallStatement, "\n" => ActionFn(1170); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant36(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1172::<>(mode, __sym0, __sym1); + let __nt = super::__action1170::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (2, 244) } @@ -28935,14 +28957,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Suite = ( ";")+, SmallStatement, "\n" => ActionFn(1173); + // Suite = ( ";")+, SmallStatement, "\n" => ActionFn(1171); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant36(__symbols); let __sym0 = __pop_Variant37(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1173::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1171::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant24(__nt), __end)); (3, 244) } @@ -28957,7 +28979,7 @@ mod __parse__Top { // Suite = "\n", Indent, Statements, Dedent => ActionFn(8); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant89(__symbols); + let __sym2 = __pop_Variant91(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; @@ -28974,14 +28996,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Term<"all"> = Term<"all">, MulOp, Factor<"all"> => ActionFn(1435); + // Term<"all"> = Term<"all">, MulOp, Factor<"all"> => ActionFn(1446); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1435::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1446::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 245) } @@ -29009,14 +29031,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Term<"no-withitems"> = Term<"all">, MulOp, Factor<"all"> => ActionFn(1436); + // Term<"no-withitems"> = Term<"all">, MulOp, Factor<"all"> => ActionFn(1447); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); - let __sym1 = __pop_Variant48(__symbols); + let __sym1 = __pop_Variant50(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1436::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1447::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 246) } @@ -29044,7 +29066,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Test<"all"> = OrTest<"all">, "if", OrTest<"all">, "else", Test<"all"> => ActionFn(1437); + // Test<"all"> = OrTest<"all">, "if", OrTest<"all">, "else", Test<"all"> => ActionFn(1448); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant14(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -29053,7 +29075,7 @@ mod __parse__Top { let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1437::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1448::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (5, 247) } @@ -29128,7 +29150,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Test<"no-withitems"> = OrTest<"all">, "if", OrTest<"all">, "else", Test<"all"> => ActionFn(1438); + // Test<"no-withitems"> = OrTest<"all">, "if", OrTest<"all">, "else", Test<"all"> => ActionFn(1449); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant14(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -29137,7 +29159,7 @@ mod __parse__Top { let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1438::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1449::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (5, 249) } @@ -29197,11 +29219,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TestList? = GenericList => ActionFn(1692); + // TestList? = GenericList => ActionFn(1688); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1692::<>(mode, __sym0); + let __nt = super::__action1688::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 251) } @@ -29228,11 +29250,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TestListOrYieldExpr = GenericList => ActionFn(1693); + // TestListOrYieldExpr = GenericList => ActionFn(1689); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1693::<>(mode, __sym0); + let __nt = super::__action1689::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 252) } @@ -29292,11 +29314,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TestOrStarExprList = GenericList => ActionFn(1694); + // TestOrStarExprList = GenericList => ActionFn(1690); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1694::<>(mode, __sym0); + let __nt = super::__action1690::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 254) } @@ -29340,14 +29362,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Top = StartModule, Program => ActionFn(1439); + // Top = StartModule, Program => ActionFn(1450); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant24(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1439::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant90(__nt), __end)); + let __nt = super::__action1450::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant92(__nt), __end)); (2, 256) } pub(crate) fn __reduce850< @@ -29358,14 +29380,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Top = StartExpression, GenericList => ActionFn(1695); + // Top = StartExpression, GenericList => ActionFn(1691); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1695::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant90(__nt), __end)); + let __nt = super::__action1691::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant92(__nt), __end)); (2, 256) } pub(crate) fn __reduce851< @@ -29376,15 +29398,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // Top = StartExpression, GenericList, ("\n")+ => ActionFn(1696); + // Top = StartExpression, GenericList, ("\n")+ => ActionFn(1692); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant21(__symbols); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1696::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant90(__nt), __end)); + let __nt = super::__action1692::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant92(__nt), __end)); (3, 256) } pub(crate) fn __reduce852< @@ -29395,7 +29417,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptClause+, "else", ":", Suite, "finally", ":", Suite => ActionFn(1442); + // TryStatement = "try", ":", Suite, ExceptClause+, "else", ":", Suite, "finally", ":", Suite => ActionFn(1453); assert!(__symbols.len() >= 10); let __sym9 = __pop_Variant24(__symbols); let __sym8 = __pop_Variant0(__symbols); @@ -29403,13 +29425,13 @@ mod __parse__Top { let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym9.2; - let __nt = super::__action1442::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); + let __nt = super::__action1453::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (10, 257) } @@ -29421,18 +29443,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptClause+, "else", ":", Suite => ActionFn(1443); + // TryStatement = "try", ":", Suite, ExceptClause+, "else", ":", Suite => ActionFn(1454); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1443::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1454::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 257) } @@ -29444,18 +29466,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptClause+, "finally", ":", Suite => ActionFn(1444); + // TryStatement = "try", ":", Suite, ExceptClause+, "finally", ":", Suite => ActionFn(1455); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1444::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1455::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 257) } @@ -29467,15 +29489,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptClause+ => ActionFn(1445); + // TryStatement = "try", ":", Suite, ExceptClause+ => ActionFn(1456); assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1445::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1456::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 257) } @@ -29487,7 +29509,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptStarClause+, "else", ":", Suite, "finally", ":", Suite => ActionFn(1446); + // TryStatement = "try", ":", Suite, ExceptStarClause+, "else", ":", Suite, "finally", ":", Suite => ActionFn(1457); assert!(__symbols.len() >= 10); let __sym9 = __pop_Variant24(__symbols); let __sym8 = __pop_Variant0(__symbols); @@ -29495,13 +29517,13 @@ mod __parse__Top { let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym9.2; - let __nt = super::__action1446::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); + let __nt = super::__action1457::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6, __sym7, __sym8, __sym9); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (10, 257) } @@ -29513,18 +29535,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptStarClause+, "else", ":", Suite => ActionFn(1447); + // TryStatement = "try", ":", Suite, ExceptStarClause+, "else", ":", Suite => ActionFn(1458); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1447::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1458::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 257) } @@ -29536,18 +29558,18 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptStarClause+, "finally", ":", Suite => ActionFn(1448); + // TryStatement = "try", ":", Suite, ExceptStarClause+, "finally", ":", Suite => ActionFn(1459); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1448::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1459::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 257) } @@ -29559,15 +29581,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, ExceptStarClause+ => ActionFn(1449); + // TryStatement = "try", ":", Suite, ExceptStarClause+ => ActionFn(1460); assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant66(__symbols); + let __sym3 = __pop_Variant68(__symbols); let __sym2 = __pop_Variant24(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1449::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1460::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 257) } @@ -29579,7 +29601,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TryStatement = "try", ":", Suite, "finally", ":", Suite => ActionFn(1106); + // TryStatement = "try", ":", Suite, "finally", ":", Suite => ActionFn(1104); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant24(__symbols); let __sym4 = __pop_Variant0(__symbols); @@ -29589,7 +29611,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1106::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1104::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (6, 257) } @@ -29609,7 +29631,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action336::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (3, 258) } pub(crate) fn __reduce862< @@ -29624,11 +29646,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant34(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant52(__symbols); + let __sym0 = __pop_Variant54(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action337::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (3, 258) } pub(crate) fn __reduce863< @@ -29647,7 +29669,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action338::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (3, 259) } pub(crate) fn __reduce864< @@ -29662,11 +29684,11 @@ mod __parse__Top { assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant34(__symbols); let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant52(__symbols); + let __sym0 = __pop_Variant54(__symbols); let __start = __sym0.0; let __end = __sym2.2; let __nt = super::__action339::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant52(__nt), __end)); + __symbols.push((__start, __Symbol::Variant54(__nt), __end)); (3, 259) } pub(crate) fn __reduce865< @@ -29753,12 +29775,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeAliasName = Identifier => ActionFn(1450); + // TypeAliasName = Identifier => ActionFn(1461); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1450::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant14(__nt), __end)); + let __nt = super::__action1461::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant45(__nt), __end)); (1, 262) } pub(crate) fn __reduce870< @@ -29769,16 +29791,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeAliasStatement = "type", TypeAliasName, TypeParams, "=", Test<"all"> => ActionFn(1728); + // TypeAliasStatement = "type", TypeAliasName, TypeParams, "=", Test<"all"> => ActionFn(1724); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant14(__symbols); let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant92(__symbols); - let __sym1 = __pop_Variant14(__symbols); + let __sym2 = __pop_Variant94(__symbols); + let __sym1 = __pop_Variant45(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1728::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1724::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 263) } @@ -29790,15 +29812,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeAliasStatement = "type", TypeAliasName, "=", Test<"all"> => ActionFn(1729); + // TypeAliasStatement = "type", TypeAliasName, "=", Test<"all"> => ActionFn(1725); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant14(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant14(__symbols); + let __sym1 = __pop_Variant45(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1729::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1725::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 263) } @@ -29810,15 +29832,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeParam = Identifier, ":", Test<"all"> => ActionFn(1452); + // TypeParam = Identifier, ":", Test<"all"> => ActionFn(1463); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1452::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant91(__nt), __end)); + let __nt = super::__action1463::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant93(__nt), __end)); (3, 264) } pub(crate) fn __reduce873< @@ -29829,12 +29851,12 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeParam = Identifier => ActionFn(1453); + // TypeParam = Identifier => ActionFn(1464); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1453::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant91(__nt), __end)); + let __nt = super::__action1464::<>(mode, __sym0); + __symbols.push((__start, __Symbol::Variant93(__nt), __end)); (1, 264) } pub(crate) fn __reduce874< @@ -29845,14 +29867,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeParam = "*", Identifier => ActionFn(1454); + // TypeParam = "*", Identifier => ActionFn(1465); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1454::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant91(__nt), __end)); + let __nt = super::__action1465::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant93(__nt), __end)); (2, 264) } pub(crate) fn __reduce875< @@ -29863,14 +29885,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeParam = "**", Identifier => ActionFn(1455); + // TypeParam = "**", Identifier => ActionFn(1466); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant22(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1455::<>(mode, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant91(__nt), __end)); + let __nt = super::__action1466::<>(mode, __sym0, __sym1); + __symbols.push((__start, __Symbol::Variant93(__nt), __end)); (2, 264) } pub(crate) fn __reduce876< @@ -29881,16 +29903,16 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeParams = "[", OneOrMore, ",", "]" => ActionFn(1456); + // TypeParams = "[", OneOrMore, ",", "]" => ActionFn(1467); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant81(__symbols); + let __sym1 = __pop_Variant83(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1456::<>(mode, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant92(__nt), __end)); + let __nt = super::__action1467::<>(mode, __sym0, __sym1, __sym2, __sym3); + __symbols.push((__start, __Symbol::Variant94(__nt), __end)); (4, 265) } pub(crate) fn __reduce877< @@ -29901,15 +29923,15 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypeParams = "[", OneOrMore, "]" => ActionFn(1457); + // TypeParams = "[", OneOrMore, "]" => ActionFn(1468); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant81(__symbols); + let __sym1 = __pop_Variant83(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1457::<>(mode, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant92(__nt), __end)); + let __nt = super::__action1468::<>(mode, __sym0, __sym1, __sym2); + __symbols.push((__start, __Symbol::Variant94(__nt), __end)); (3, 265) } pub(crate) fn __reduce878< @@ -29921,11 +29943,11 @@ mod __parse__Top { ) -> (usize, usize) { // TypeParams? = TypeParams => ActionFn(284); - let __sym0 = __pop_Variant92(__symbols); + let __sym0 = __pop_Variant94(__symbols); let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action284::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant93(__nt), __end)); + __symbols.push((__start, __Symbol::Variant95(__nt), __end)); (1, 266) } pub(crate) fn __reduce879< @@ -29940,7 +29962,7 @@ mod __parse__Top { let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); let __nt = super::__action285::<>(mode, &__start, &__end); - __symbols.push((__start, __Symbol::Variant93(__nt), __end)); + __symbols.push((__start, __Symbol::Variant95(__nt), __end)); (0, 266) } pub(crate) fn __reduce880< @@ -29951,14 +29973,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypedParameter = Identifier, ":", Test<"all"> => ActionFn(1458); + // TypedParameter = Identifier, ":", Test<"all"> => ActionFn(1469); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1458::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1469::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (3, 267) } @@ -29970,11 +29992,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // TypedParameter = Identifier => ActionFn(1459); + // TypedParameter = Identifier => ActionFn(1470); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1459::<>(mode, __sym0); + let __nt = super::__action1470::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 267) } @@ -29991,7 +30013,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action203::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant94(__nt), __end)); + __symbols.push((__start, __Symbol::Variant96(__nt), __end)); (1, 268) } pub(crate) fn __reduce883< @@ -30007,7 +30029,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action204::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant94(__nt), __end)); + __symbols.push((__start, __Symbol::Variant96(__nt), __end)); (1, 268) } pub(crate) fn __reduce884< @@ -30023,7 +30045,7 @@ mod __parse__Top { let __start = __sym0.0; let __end = __sym0.2; let __nt = super::__action205::<>(mode, __sym0); - __symbols.push((__start, __Symbol::Variant94(__nt), __end)); + __symbols.push((__start, __Symbol::Variant96(__nt), __end)); (1, 268) } pub(crate) fn __reduce885< @@ -30034,11 +30056,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // UntypedParameter = Identifier => ActionFn(1460); + // UntypedParameter = Identifier => ActionFn(1471); let __sym0 = __pop_Variant22(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1460::<>(mode, __sym0); + let __nt = super::__action1471::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 269) } @@ -30050,11 +30072,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // ValuePattern = MatchNameOrAttr => ActionFn(1461); - let __sym0 = __pop_Variant14(__symbols); + // ValuePattern = MatchNameOrAttr => ActionFn(1472); + let __sym0 = __pop_Variant45(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1461::<>(mode, __sym0); + let __nt = super::__action1472::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant34(__nt), __end)); (1, 270) } @@ -30066,7 +30088,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WhileStatement = "while", NamedExpressionTest, ":", Suite, "else", ":", Suite => ActionFn(1103); + // WhileStatement = "while", NamedExpressionTest, ":", Suite, "else", ":", Suite => ActionFn(1101); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant24(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -30077,7 +30099,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1103::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1101::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (7, 271) } @@ -30089,7 +30111,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WhileStatement = "while", NamedExpressionTest, ":", Suite => ActionFn(1104); + // WhileStatement = "while", NamedExpressionTest, ":", Suite => ActionFn(1102); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -30097,7 +30119,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1104::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1102::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 271) } @@ -30109,11 +30131,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItem<"all"> = Test<"all"> => ActionFn(1462); + // WithItem<"all"> = Test<"all"> => ActionFn(297); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1462::<>(mode, __sym0); + let __nt = super::__action297::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 272) } @@ -30141,11 +30163,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItem<"no-withitems"> = Test<"no-withitems"> => ActionFn(1463); + // WithItem<"no-withitems"> = Test<"no-withitems"> => ActionFn(292); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1463::<>(mode, __sym0); + let __nt = super::__action292::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 273) } @@ -30173,14 +30195,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItemAs = Test<"all">, "as", Expression<"all"> => ActionFn(1464); + // WithItemAs = Test<"all">, "as", Expression<"all"> => ActionFn(1473); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1464::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1473::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (3, 274) } @@ -30192,7 +30214,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", OneOrMore>, ",", ")" => ActionFn(1471); + // WithItems = "(", OneOrMore>, ",", ")" => ActionFn(1175); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -30200,7 +30222,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1471::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1175::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (4, 275) } @@ -30212,14 +30234,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", OneOrMore>, ")" => ActionFn(1472); + // WithItems = "(", OneOrMore>, ")" => ActionFn(1176); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant32(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1472::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1176::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (3, 275) } @@ -30231,7 +30253,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", OneOrMore>, ",", WithItemAs, ",", ")" => ActionFn(1474); + // WithItems = "(", OneOrMore>, ",", WithItemAs, ",", ")" => ActionFn(1178); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant0(__symbols); @@ -30241,7 +30263,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1474::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1178::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (6, 275) } @@ -30253,7 +30275,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", WithItemAs, ",", ")" => ActionFn(1475); + // WithItems = "(", WithItemAs, ",", ")" => ActionFn(1179); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -30261,7 +30283,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1475::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1179::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (4, 275) } @@ -30273,7 +30295,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", OneOrMore>, ",", WithItemAs, ("," >)+, ",", ")" => ActionFn(1476); + // WithItems = "(", OneOrMore>, ",", WithItemAs, ("," >)+, ",", ")" => ActionFn(1180); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant0(__symbols); @@ -30284,7 +30306,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym6.2; - let __nt = super::__action1476::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action1180::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (7, 275) } @@ -30296,7 +30318,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", WithItemAs, ("," >)+, ",", ")" => ActionFn(1477); + // WithItems = "(", WithItemAs, ("," >)+, ",", ")" => ActionFn(1181); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -30305,7 +30327,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1477::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1181::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (5, 275) } @@ -30317,7 +30339,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", OneOrMore>, ",", WithItemAs, ")" => ActionFn(1478); + // WithItems = "(", OneOrMore>, ",", WithItemAs, ")" => ActionFn(1182); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant0(__symbols); let __sym3 = __pop_Variant17(__symbols); @@ -30326,7 +30348,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action1478::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action1182::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (5, 275) } @@ -30338,14 +30360,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", WithItemAs, ")" => ActionFn(1479); + // WithItems = "(", WithItemAs, ")" => ActionFn(1183); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant0(__symbols); let __sym1 = __pop_Variant17(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1479::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1183::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (3, 275) } @@ -30357,7 +30379,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", OneOrMore>, ",", WithItemAs, ("," >)+, ")" => ActionFn(1480); + // WithItems = "(", OneOrMore>, ",", WithItemAs, ("," >)+, ")" => ActionFn(1184); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant18(__symbols); @@ -30367,7 +30389,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym5.2; - let __nt = super::__action1480::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action1184::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (6, 275) } @@ -30379,7 +30401,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItems = "(", WithItemAs, ("," >)+, ")" => ActionFn(1481); + // WithItems = "(", WithItemAs, ("," >)+, ")" => ActionFn(1185); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant18(__symbols); @@ -30387,7 +30409,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action1481::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action1185::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (4, 275) } @@ -30433,11 +30455,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithItemsNoAs = OneOrMore> => ActionFn(1465); + // WithItemsNoAs = OneOrMore> => ActionFn(160); let __sym0 = __pop_Variant32(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1465::<>(mode, __sym0); + let __nt = super::__action160::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant39(__nt), __end)); (1, 276) } @@ -30449,7 +30471,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithStatement = "async", "with", WithItems, ":", Suite => ActionFn(931); + // WithStatement = "async", "with", WithItems, ":", Suite => ActionFn(929); assert!(__symbols.len() >= 5); let __sym4 = __pop_Variant24(__symbols); let __sym3 = __pop_Variant0(__symbols); @@ -30458,7 +30480,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym4.2; - let __nt = super::__action931::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action929::<>(mode, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (5, 277) } @@ -30470,7 +30492,7 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // WithStatement = "with", WithItems, ":", Suite => ActionFn(932); + // WithStatement = "with", WithItems, ":", Suite => ActionFn(930); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant24(__symbols); let __sym2 = __pop_Variant0(__symbols); @@ -30478,7 +30500,7 @@ mod __parse__Top { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym3.2; - let __nt = super::__action932::<>(mode, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action930::<>(mode, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant36(__nt), __end)); (4, 277) } @@ -30490,14 +30512,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // XorExpression<"all"> = XorExpression<"all">, "^", AndExpression<"all"> => ActionFn(1466); + // XorExpression<"all"> = XorExpression<"all">, "^", AndExpression<"all"> => ActionFn(1474); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1466::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1474::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 278) } @@ -30525,14 +30547,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // XorExpression<"no-withitems"> = XorExpression<"all">, "^", AndExpression<"all"> => ActionFn(1467); + // XorExpression<"no-withitems"> = XorExpression<"all">, "^", AndExpression<"all"> => ActionFn(1475); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant14(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1467::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1475::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 279) } @@ -30560,13 +30582,13 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // YieldExpr = "yield", GenericList => ActionFn(1699); + // YieldExpr = "yield", GenericList => ActionFn(1695); assert!(__symbols.len() >= 2); let __sym1 = __pop_Variant14(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym1.2; - let __nt = super::__action1699::<>(mode, __sym0, __sym1); + let __nt = super::__action1695::<>(mode, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (2, 280) } @@ -30578,11 +30600,11 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // YieldExpr = "yield" => ActionFn(1700); + // YieldExpr = "yield" => ActionFn(1696); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym0.2; - let __nt = super::__action1700::<>(mode, __sym0); + let __nt = super::__action1696::<>(mode, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 280) } @@ -30594,14 +30616,14 @@ mod __parse__Top { _: core::marker::PhantomData<()>, ) -> (usize, usize) { - // YieldExpr = "yield", "from", Test<"all"> => ActionFn(1469); + // YieldExpr = "yield", "from", Test<"all"> => ActionFn(1477); assert!(__symbols.len() >= 3); let __sym2 = __pop_Variant14(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0; let __end = __sym2.2; - let __nt = super::__action1469::<>(mode, __sym0, __sym1, __sym2); + let __nt = super::__action1477::<>(mode, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (3, 280) } @@ -30640,12 +30662,12 @@ fn __action2< mode: Mode, (_, start, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, body, _): (TextSize, ast::Expr, TextSize), + (_, body, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, alloc::vec::Vec, TextSize), (_, end, _): (TextSize, TextSize, TextSize), ) -> ast::Mod { - ast::ModExpression { body: Box::new(body), range: (start..end).into() }.into() + ast::ModExpression { body: Box::new(body.into()), range: (start..end).into() }.into() } #[allow(unused_variables)] @@ -30942,13 +30964,13 @@ fn __action25< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, targets, _): (TextSize, Vec, TextSize), + (_, targets, _): (TextSize, Vec, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { ast::Stmt::Delete( - ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr, ast::ExprContext::Del)).collect(), range: (location..end_location).into() } + ast::StmtDelete { targets: targets.into_iter().map(|expr| set_context(expr.into(), ast::ExprContext::Del)).collect(), range: (location..end_location).into() } ) } } @@ -30959,8 +30981,8 @@ fn __action26< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, expression, _): (TextSize, ast::Expr, TextSize), - (_, suffix, _): (TextSize, alloc::vec::Vec, TextSize), + (_, expression, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, suffix, _): (TextSize, alloc::vec::Vec, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -30968,16 +30990,16 @@ fn __action26< // Just an expression, no assignment: if suffix.is_empty() { ast::Stmt::Expr( - ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() } + ast::StmtExpr { value: Box::new(expression.into()), range: (location..end_location).into() } ) } else { - let mut targets = vec![set_context(expression, ast::ExprContext::Store)]; + let mut targets = vec![set_context(expression.into(), ast::ExprContext::Store)]; let mut values = suffix; - let value = Box::new(values.pop().unwrap()); + let value = Box::new(values.pop().unwrap().into()); for target in values { - targets.push(set_context(target, ast::ExprContext::Store)); + targets.push(set_context(target.into(), ast::ExprContext::Store)); } ast::Stmt::Assign( @@ -30993,18 +31015,18 @@ fn __action27< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, target, _): (TextSize, ast::Expr, TextSize), + (_, target, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, rhs, _): (TextSize, ast::Expr, TextSize), + (_, rhs, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { ast::Stmt::AugAssign( ast::StmtAugAssign { - target: Box::new(set_context(target, ast::ExprContext::Store)), + target: Box::new(set_context(target.into(), ast::ExprContext::Store)), op, - value: Box::new(rhs), + value: Box::new(rhs.into()), range: (location..end_location).into() }, ) @@ -31017,20 +31039,20 @@ fn __action28< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, target, _): (TextSize, ast::Expr, TextSize), + (_, target, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, annotation, _): (TextSize, ast::Expr, TextSize), - (_, rhs, _): (TextSize, core::option::Option, TextSize), + (_, annotation, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, rhs, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { - let simple = target.is_name_expr(); + let simple = target.expr.is_name_expr(); ast::Stmt::AnnAssign( ast::StmtAnnAssign { - target: Box::new(set_context(target, ast::ExprContext::Store)), - annotation: Box::new(annotation), - value: rhs.map(Box::new), + target: Box::new(set_context(target.into(), ast::ExprContext::Store)), + annotation: Box::new(annotation.into()), + value: rhs.map(ast::Expr::from).map(Box::new), simple, range: (location..end_location).into() }, @@ -31044,8 +31066,8 @@ fn __action29< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { e } @@ -31056,8 +31078,8 @@ fn __action30< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { e } @@ -31067,8 +31089,8 @@ fn __action30< fn __action31< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31078,8 +31100,8 @@ fn __action31< fn __action32< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31089,8 +31111,8 @@ fn __action32< fn __action33< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31100,8 +31122,8 @@ fn __action33< fn __action34< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31111,8 +31133,8 @@ fn __action34< fn __action35< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31122,8 +31144,8 @@ fn __action35< fn __action36< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31133,8 +31155,8 @@ fn __action36< fn __action37< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31144,8 +31166,8 @@ fn __action37< fn __action38< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31155,8 +31177,8 @@ fn __action38< fn __action39< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -31342,13 +31364,13 @@ fn __action55< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, value, _): (TextSize, core::option::Option, TextSize), + (_, value, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { ast::Stmt::Return( - ast::StmtReturn { value: value.map(Box::new), range: (location..end_location).into() } + ast::StmtReturn { value: value.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) } } @@ -31359,13 +31381,13 @@ fn __action56< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, expression, _): (TextSize, ast::Expr, TextSize), + (_, expression, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { ast::Stmt::Expr( - ast::StmtExpr { value: Box::new(expression), range: (location..end_location).into() } + ast::StmtExpr { value: Box::new(expression.into()), range: (location..end_location).into() } ) } } @@ -31405,14 +31427,14 @@ fn __action59< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, t, _): (TextSize, ast::Expr, TextSize), - (_, c, _): (TextSize, core::option::Option, TextSize), + (_, exc, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, cause, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { ast::Stmt::Raise( - ast::StmtRaise { exc: Some(Box::new(t)), cause: c.map(Box::new), range: (location..end_location).into() } + ast::StmtRaise { exc: Some(Box::new(exc.into())), cause: cause.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) } } @@ -31632,16 +31654,16 @@ fn __action73< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, test, _): (TextSize, ast::Expr, TextSize), - (_, msg, _): (TextSize, core::option::Option, TextSize), + (_, test, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, msg, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { { ast::Stmt::Assert( ast::StmtAssert { - test: Box::new(test), - msg: msg.map(Box::new), + test: Box::new(test.into()), + msg: msg.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) @@ -31659,7 +31681,7 @@ fn __action74< ) -> Result> { { - if mode == Mode::Jupyter { + if mode == Mode::Ipython { Ok(ast::Stmt::IpyEscapeCommand( ast::StmtIpyEscapeCommand { kind: c.0, @@ -31669,7 +31691,7 @@ fn __action74< )) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in `Mode::Ipython`".to_string()), location, })? } @@ -31684,10 +31706,10 @@ fn __action75< (_, location, _): (TextSize, TextSize, TextSize), (_, c, _): (TextSize, (IpyEscapeKind, String), TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { { - if mode == Mode::Jupyter { + if mode == Mode::Ipython { // This should never occur as the lexer won't allow it. if !matches!(c.0, IpyEscapeKind::Magic | IpyEscapeKind::Shell) { return Err(LexicalError { @@ -31695,16 +31717,14 @@ fn __action75< location, })?; } - Ok(ast::Expr::IpyEscapeCommand( - ast::ExprIpyEscapeCommand { - kind: c.0, - value: c.1, - range: (location..end_location).into() - } - )) + Ok(ast::ExprIpyEscapeCommand { + kind: c.0, + value: c.1, + range: (location..end_location).into() + }.into()) } else { Err(LexicalError { - error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in `Mode::Ipython`".to_string()), location, })? } @@ -31717,7 +31737,7 @@ fn __action76< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, suffix, _): (TextSize, alloc::vec::Vec, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> Result> @@ -31755,10 +31775,10 @@ fn __action76< Ok(()) } - if mode != Mode::Jupyter { + if mode != Mode::Ipython { return Err(ParseError::User { error: LexicalError { - error: LexicalErrorType::OtherError("IPython escape commands are only allowed in Jupyter mode".to_string()), + error: LexicalErrorType::OtherError("IPython escape commands are only allowed in `Mode::Ipython`".to_string()), location, }, }); @@ -31778,7 +31798,7 @@ fn __action76< }; let mut value = String::new(); - unparse_expr(&e, &mut value)?; + unparse_expr(&e.into(), &mut value)?; Ok(ast::Stmt::IpyEscapeCommand( ast::StmtIpyEscapeCommand { @@ -31885,7 +31905,7 @@ fn __action85< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, subject, _): (TextSize, ast::Expr, TextSize), + (_, subject, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), @@ -31903,7 +31923,7 @@ fn __action85< .end(); ast::Stmt::Match( ast::StmtMatch { - subject: Box::new(subject), + subject: Box::new(subject.into()), cases, range: (location..end_location).into() } @@ -31918,7 +31938,7 @@ fn __action86< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, subject, _): (TextSize, ast::Expr, TextSize), + (_, subject, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), @@ -31937,7 +31957,7 @@ fn __action86< .end(); ast::Stmt::Match( ast::StmtMatch { - subject: Box::new(subject), + subject: Box::new(subject.into()), cases, range: (location..end_location).into() } @@ -31952,7 +31972,7 @@ fn __action87< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, subjects, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), @@ -31969,11 +31989,12 @@ fn __action87< .last() .unwrap() .end(); + let elts = elts.into_iter().map(ast::Expr::from).collect(); ast::Stmt::Match( ast::StmtMatch { subject: Box::new(ast::Expr::Tuple( ast::ExprTuple { - elts: subjects, + elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, @@ -32016,11 +32037,11 @@ fn __action89< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, guard, _): (TextSize, ast::Expr, TextSize), + (_, guard, _): (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Expr { { - guard + guard.into() } } @@ -32352,11 +32373,11 @@ fn __action111< (_, location, _): (TextSize, TextSize, TextSize), (_, value, _): (TextSize, ast::Constant, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { ast::Expr::Constant( - ast::ExprConstant { value, kind: None, range: (location..end_location).into() } - ) + ast::ExprConstant { value, range: (location..end_location).into() } + ).into() } #[allow(unused_variables)] @@ -32364,8 +32385,8 @@ fn __action111< fn __action112< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -32377,17 +32398,17 @@ fn __action113< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, operand, _): (TextSize, ast::Expr, TextSize), + (_, operand, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { ast::Expr::UnaryOp( ast::ExprUnaryOp { op: ast::UnaryOp::USub, - operand: Box::new(operand), + operand: Box::new(operand.into()), range: (location..end_location).into() } - ) + ).into() } #[allow(unused_variables)] @@ -32396,20 +32417,18 @@ fn __action114< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, left, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, right, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { - left: Box::new(left), - op, - right: Box::new(right), - range: (location..end_location).into() - } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -32466,12 +32485,12 @@ fn __action118< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, value, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Pattern { ast::PatternMatchValue { - value: Box::new(value), + value: Box::new(value.into()), range: (location..end_location).into() }.into() } @@ -32482,12 +32501,12 @@ fn __action119< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, value, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Pattern { ast::PatternMatchValue { - value: Box::new(value), + value: Box::new(value.into()), range: (location..end_location).into() }.into() } @@ -32552,14 +32571,12 @@ fn __action123< (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Expr { - ast::Expr::Attribute( - ast::ExprAttribute { - value: Box::new(name), - attr, - ctx: ast::ExprContext::Load, - range: (location..end_location).into() - }, - ) + ast::ExprAttribute { + value: Box::new(name), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -32574,14 +32591,12 @@ fn __action124< (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Expr { - ast::Expr::Attribute( - ast::ExprAttribute { - value: Box::new(e), - attr, - ctx: ast::ExprContext::Load, - range: (location..end_location).into() - }, - ) + ast::ExprAttribute { + value: Box::new(e), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -32616,10 +32631,10 @@ fn __action126< fn __action127< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Expr { - __0 + e.into() } #[allow(unused_variables)] @@ -32627,10 +32642,10 @@ fn __action127< fn __action128< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Expr { - __0 + e.into() } #[allow(unused_variables)] @@ -32643,13 +32658,10 @@ fn __action129< (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Expr { - ast::Expr::Constant( - ast::ExprConstant { - value: ast::Constant::None, - kind: None, - range: (location..end_location).into() - }, - ) + ast::ExprConstant { + value: ast::Constant::None, + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -32662,13 +32674,10 @@ fn __action130< (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Expr { - ast::Expr::Constant( - ast::ExprConstant { - value: true.into(), - kind: None, - range: (location..end_location).into() - }, - ) + ast::ExprConstant { + value: true.into(), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -32681,13 +32690,10 @@ fn __action131< (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Expr { - ast::Expr::Constant( - ast::ExprConstant { - value: false.into(), - kind: None, - range: (location..end_location).into() - }, - ) + ast::ExprConstant { + value: false.into(), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -32969,17 +32975,17 @@ fn __action145< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, test, _): (TextSize, ast::Expr, TextSize), + (_, test, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), - (_, s2, _): (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), + (_, s2, _): (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), (_, s3, _): (TextSize, core::option::Option<(TextSize, ast::Suite)>, TextSize), ) -> ast::Stmt { { let elif_else_clauses: Vec<_> = s2.into_iter().map(|(start, test, body)| ast::ElifElseClause { range: (start..body.last().unwrap().end()).into(), - test: Some(test), + test: Some(test.into()), body, }).chain(s3.into_iter().map(|(start, body)| ast::ElifElseClause { range: (start..body.last().unwrap().end()).into(), @@ -32992,7 +32998,7 @@ fn __action145< .map_or_else(|| body.last().unwrap().end(), Ranged::end); ast::Stmt::If( - ast::StmtIf { test: Box::new(test), body, elif_else_clauses, range: (location..end_location).into() } + ast::StmtIf { test: Box::new(test.into()), body, elif_else_clauses, range: (location..end_location).into() } ) } } @@ -33004,7 +33010,7 @@ fn __action146< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, test, _): (TextSize, ast::Expr, TextSize), + (_, test, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), (_, s2, _): (TextSize, core::option::Option, TextSize), @@ -33019,7 +33025,7 @@ fn __action146< .end(); ast::Stmt::While( ast::StmtWhile { - test: Box::new(test), + test: Box::new(test.into()), body, orelse, range: (location..end_location).into() @@ -33036,9 +33042,9 @@ fn __action147< (_, location, _): (TextSize, TextSize, TextSize), (_, is_async, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, target, _): (TextSize, ast::Expr, TextSize), + (_, target, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, iter, _): (TextSize, ast::Expr, TextSize), + (_, iter, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), (_, orelse, _): (TextSize, core::option::Option, TextSize), @@ -33051,8 +33057,8 @@ fn __action147< .or_else(|| body.last()) .unwrap() .end(); - let target = Box::new(set_context(target, ast::ExprContext::Store)); - let iter = Box::new(iter); + let target = Box::new(set_context(target.into(), ast::ExprContext::Store)); + let iter = Box::new(iter.into()); ast::Stmt::For(ast::StmtFor { target, iter, body, orelse, is_async: is_async.is_some(), range: (location..end_location).into() }) } } @@ -33168,7 +33174,7 @@ fn __action151< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, typ, _): (TextSize, ast::Expr, TextSize), + (_, typ, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -33177,7 +33183,7 @@ fn __action151< let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: Some(Box::new(typ)), + type_: Some(Box::new(typ.into())), name: None, body, range: (location..end_location).into() @@ -33194,7 +33200,7 @@ fn __action152< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, x, _): (TextSize, (ast::Expr, ast::Identifier), TextSize), + (_, x, _): (TextSize, (ast::ParenthesizedExpr, ast::Identifier), TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -33203,7 +33209,7 @@ fn __action152< let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: Some(Box::new(x.0)), + type_: Some(Box::new(x.0.into())), name: Some(x.1), body, range: (location..end_location).into() @@ -33219,7 +33225,7 @@ fn __action153< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, typ, _): (TextSize, core::option::Option, TextSize), + (_, typ, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -33228,7 +33234,7 @@ fn __action153< let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: typ.map(Box::new), + type_: typ.map(ast::Expr::from).map(Box::new), name: None, body, range: (location..end_location).into() @@ -33244,7 +33250,7 @@ fn __action154< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, x, _): (TextSize, (ast::Expr, ast::Identifier), TextSize), + (_, x, _): (TextSize, (ast::ParenthesizedExpr, ast::Identifier), TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -33253,7 +33259,7 @@ fn __action154< let end_location = body.last().unwrap().end(); ast::ExceptHandler::ExceptHandler( ast::ExceptHandlerExceptHandler { - type_: Some(Box::new(x.0)), + type_: Some(Box::new(x.0.into())), name: Some(x.1), body, range: (location..end_location).into() @@ -33318,10 +33324,28 @@ fn __action157< fn __action158< >( mode: Mode, - (_, __0, _): (TextSize, ast::WithItem, TextSize), + (_, item, _): (TextSize, ast::WithItem, TextSize), ) -> Vec { - vec![__0] + { + // Special-case: if the `WithItem` is a parenthesized named expression, then the item + // should _exclude_ the outer parentheses in its range. For example: + // ```python + // with (a := 0): pass + // ``` + // In this case, the `(` and `)` are part of the `with` statement. + // The same applies to `yield` and `yield from`. + let item = if matches!(item.context_expr, ast::Expr::NamedExpr(_) | ast::Expr::Yield(_) | ast::Expr::YieldFrom(_)) { + ast::WithItem { + range: item.range().add_start(TextSize::new(1)).sub_end(TextSize::new(1)), + context_expr: item.context_expr, + optional_vars: item.optional_vars, + } + } else { + item + }; + vec![item] + } } #[allow(unused_variables)] @@ -33343,13 +33367,15 @@ fn __action159< fn __action160< >( mode: Mode, - (_, location, _): (TextSize, TextSize, TextSize), - (_, all, _): (TextSize, Vec, TextSize), - (_, end_location, _): (TextSize, TextSize, TextSize), + (_, all, _): (TextSize, Vec, TextSize), ) -> Vec { { - all.into_iter().map(|context_expr| ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() }).collect() + all.into_iter().map(|context_expr| ast::WithItem { + range: context_expr.range(), + context_expr: context_expr.into(), + optional_vars: None, + }).collect() } } @@ -33359,15 +33385,19 @@ fn __action161< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, context_expr, _): (TextSize, ast::Expr, TextSize), + (_, context_expr, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, vars, _): (TextSize, ast::Expr, TextSize), + (_, optional_vars, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::WithItem { { - let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store))); - ast::WithItem { context_expr, optional_vars, range: (location..end_location).into() } + let optional_vars = Some(Box::new(set_context(optional_vars.into(), ast::ExprContext::Store))); + ast::WithItem { + context_expr: context_expr.into(), + optional_vars, + range: (location..end_location).into(), + } } } @@ -33382,17 +33412,26 @@ fn __action162< (_, _, _): (TextSize, token::Tok, TextSize), (_, name, _): (TextSize, ast::Identifier, TextSize), (_, type_params, _): (TextSize, core::option::Option, TextSize), - (_, args, _): (TextSize, ast::Parameters, TextSize), - (_, r, _): (TextSize, core::option::Option, TextSize), + (_, parameters, _): (TextSize, ast::Parameters, TextSize), + (_, returns, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, body, _): (TextSize, ast::Suite, TextSize), ) -> ast::Stmt { { - let args = Box::new(args); - let returns = r.map(Box::new); + let parameters = Box::new(parameters); + let returns = returns.map(ast::Expr::from).map(Box::new); let end_location = body.last().unwrap().end(); - ast::StmtFunctionDef { name, parameters:args, body, decorator_list, returns, type_params, is_async: is_async.is_some(), range: (location..end_location).into() }.into() + ast::StmtFunctionDef { + name, + parameters, + body, + decorator_list, + returns, + type_params, + is_async: is_async.is_some(), + range: (location..end_location).into(), + }.into() } } @@ -33406,9 +33445,11 @@ fn __action163< (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Expr { - ast::Expr::Name( - ast::ExprName { id: name.into(), ctx: ast::ExprContext::Store, range: (location..end_location).into() }, - ) + ast::ExprName { + id: name.into(), + ctx: ast::ExprContext::Store, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -33421,7 +33462,7 @@ fn __action164< (_, name, _): (TextSize, ast::Expr, TextSize), (_, type_params, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, value, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -33429,7 +33470,7 @@ fn __action164< ast::Stmt::TypeAlias( ast::StmtTypeAlias { name: Box::new(name), - value: Box::new(value), + value: Box::new(value.into()), type_params, range: (location..end_location).into() }, @@ -33469,13 +33510,13 @@ fn __action166< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, arg, _): (TextSize, ast::Identifier, TextSize), + (_, name, _): (TextSize, ast::Identifier, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::ParameterWithDefault { { - let def = ast::Parameter { name:arg, annotation: None, range: (location..end_location).into() }; - ast::ParameterWithDefault { parameter:def, default: None, range: (location..end_location).into() } + let parameter = ast::Parameter { name, annotation: None, range: (location..end_location).into() }; + ast::ParameterWithDefault { parameter, default: None, range: (location..end_location).into() } } } @@ -33498,15 +33539,15 @@ fn __action168< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, arg, _): (TextSize, ast::Identifier, TextSize), - (_, a, _): (TextSize, core::option::Option, TextSize), + (_, name, _): (TextSize, ast::Identifier, TextSize), + (_, annotation, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::ParameterWithDefault { { - let annotation = a.map(Box::new); - let def = ast::Parameter { name:arg, annotation, range: (location..end_location).into() }; - ast::ParameterWithDefault { parameter:def, default: None, range: (location..end_location).into() } + let annotation = annotation.map(ast::Expr::from).map(Box::new); + let parameter = ast::Parameter { name, annotation, range: (location..end_location).into() }; + ast::ParameterWithDefault { parameter, default: None, range: (location..end_location).into() } } } @@ -33516,14 +33557,14 @@ fn __action169< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, arg, _): (TextSize, ast::Identifier, TextSize), - (_, a, _): (TextSize, core::option::Option, TextSize), + (_, name, _): (TextSize, ast::Identifier, TextSize), + (_, annotation, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Parameter { { - let annotation = a.map(Box::new); - ast::Parameter { name:arg, annotation, range: (location..end_location).into() } + let annotation = annotation.map(ast::Expr::from).map(Box::new); + ast::Parameter { name, annotation, range: (location..end_location).into() } } } @@ -33533,14 +33574,14 @@ fn __action170< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, arg, _): (TextSize, ast::Identifier, TextSize), - (_, a, _): (TextSize, core::option::Option, TextSize), + (_, name, _): (TextSize, ast::Identifier, TextSize), + (_, annotation, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Parameter { { - let annotation = a.map(Box::new); - ast::Parameter { name:arg, annotation, range: (location..end_location).into() } + let annotation = annotation.map(ast::Expr::from).map(Box::new); + ast::Parameter { name, annotation, range: (location..end_location).into() } } } @@ -33602,13 +33643,13 @@ fn __action173< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, name, _): (TextSize, ast::Identifier, TextSize), - (_, bound, _): (TextSize, core::option::Option, TextSize), + (_, bound, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::TypeParam { { ast::TypeParam::TypeVar( - ast::TypeParamTypeVar { name, bound: bound.map(Box::new), range: (location..end_location).into() } + ast::TypeParamTypeVar { name, bound: bound.map(ast::Expr::from).map(Box::new), range: (location..end_location).into() } ) } } @@ -33656,13 +33697,13 @@ fn __action176< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, p, _): (TextSize, ast::Expr, TextSize), + (_, expression, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), ) -> ast::Decorator { { - ast::Decorator { range: (location..end_location).into(), expression: p } + ast::Decorator { range: (location..end_location).into(), expression: expression.into() } } } @@ -33673,13 +33714,14 @@ fn __action177< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, value, _): (TextSize, core::option::Option, TextSize), + (_, value, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Yield( - ast::ExprYield { value: value.map(Box::new), range: (location..end_location).into() } - ) + ast::ExprYield { + value: value.map(ast::Expr::from).map(Box::new), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -33690,13 +33732,14 @@ fn __action178< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::YieldFrom( - ast::ExprYieldFrom { value: Box::new(e), range: (location..end_location).into() } - ) + ast::ExprYieldFrom { + value: Box::new(value.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -33704,8 +33747,8 @@ fn __action178< fn __action179< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -33715,8 +33758,8 @@ fn __action179< fn __action180< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -33729,11 +33772,13 @@ fn __action181< (_, location, _): (TextSize, TextSize, TextSize), (_, id, _): (TextSize, ast::Identifier, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Name( - ast::ExprName { id: id.into(), ctx: ast::ExprContext::Store, range: (location..end_location).into() }, - ) + ast::ExprName { + id: id.into(), + ctx: ast::ExprContext::Store, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -33742,20 +33787,18 @@ fn __action182< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, target, _): (TextSize, ast::Expr, TextSize), + (_, target, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, value, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::NamedExpr( - ast::ExprNamedExpr { - target: Box::new(target), - value: Box::new(value), - range: (location..end_location).into(), - } - ) + ast::ExprNamedExpr { + target: Box::new(target.into()), + value: Box::new(value.into()), + range: (location..end_location).into(), + }.into() } } @@ -33770,20 +33813,18 @@ fn __action183< (_, parameters, _): (TextSize, core::option::Option, TextSize), (_, end_location_args, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, body, _): (TextSize, ast::Expr, TextSize), + (_, body, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { { parameters.as_ref().map(validate_arguments).transpose()?; - Ok(ast::Expr::Lambda( - ast::ExprLambda { - parameters: parameters.map(Box::new), - body: Box::new(body), - range: (location..end_location).into() - } - )) + Ok(ast::ExprLambda { + parameters: parameters.map(Box::new), + body: Box::new(body.into()), + range: (location..end_location).into() + }.into()) } } @@ -34036,14 +34077,10 @@ fn __action205< fn __action206< >( mode: Mode, - (_, location, _): (TextSize, TextSize, TextSize), - (_, s1, _): (TextSize, ast::Expr, TextSize), - (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { - { - s1 - } + __0 } #[allow(unused_variables)] @@ -34052,15 +34089,17 @@ fn __action207< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, s1, _): (TextSize, ast::Expr, TextSize), + (_, s1, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::Tuple( - ast::ExprTuple { elts: vec![s1], ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ) + ast::ExprTuple { + elts: vec![s1.into()], + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } } @@ -34070,15 +34109,18 @@ fn __action208< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, elts, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { + elts, + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } } @@ -34087,8 +34129,8 @@ fn __action208< fn __action209< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34099,20 +34141,20 @@ fn __action210< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, core::option::Option, TextSize), + (_, lower, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, core::option::Option, TextSize), - (_, e3, _): (TextSize, core::option::Option>, TextSize), + (_, upper, _): (TextSize, core::option::Option, TextSize), + (_, step, _): (TextSize, core::option::Option>, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - let lower = e1.map(Box::new); - let upper = e2.map(Box::new); - let step = e3.flatten().map(Box::new); + let lower = lower.map(ast::Expr::from).map(Box::new); + let upper = upper.map(ast::Expr::from).map(Box::new); + let step = step.flatten().map(ast::Expr::from).map(Box::new); ast::Expr::Slice( ast::ExprSlice { lower, upper, step, range: (location..end_location).into() } - ) + ).into() } } @@ -34123,8 +34165,8 @@ fn __action211< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, core::option::Option, TextSize), -) -> Option + (_, e, _): (TextSize, core::option::Option, TextSize), +) -> Option { e } @@ -34134,9 +34176,9 @@ fn __action211< fn __action212< >( mode: Mode, - (_, e, _): (TextSize, Vec, TextSize), + (_, e, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, core::option::Option, TextSize), -) -> Vec +) -> Vec { e } @@ -34146,9 +34188,9 @@ fn __action212< fn __action213< >( mode: Mode, - (_, elements, _): (TextSize, Vec<(Option>, ast::Expr)>, TextSize), + (_, elements, _): (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), (_, _, _): (TextSize, core::option::Option, TextSize), -) -> Vec<(Option>, ast::Expr)> +) -> Vec<(Option>, ast::ParenthesizedExpr)> { elements } @@ -34158,10 +34200,10 @@ fn __action213< fn __action214< >( mode: Mode, - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, e1, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), -) -> (ast::Expr, ast::Expr) + (_, e2, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> (ast::ParenthesizedExpr, ast::ParenthesizedExpr) { (e1, e2) } @@ -34171,8 +34213,8 @@ fn __action214< fn __action215< >( mode: Mode, - (_, e, _): (TextSize, (ast::Expr, ast::Expr), TextSize), -) -> (Option>, ast::Expr) + (_, e, _): (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), +) -> (Option>, ast::ParenthesizedExpr) { (Some(Box::new(e.0)), e.1) } @@ -34183,8 +34225,8 @@ fn __action216< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> (Option>, ast::Expr) + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> (Option>, ast::ParenthesizedExpr) { (None, e) } @@ -34194,9 +34236,9 @@ fn __action216< fn __action217< >( mode: Mode, - (_, e1, _): (TextSize, Vec, TextSize), + (_, e1, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, core::option::Option, TextSize), -) -> Vec +) -> Vec { e1 } @@ -34206,8 +34248,8 @@ fn __action217< fn __action218< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34217,8 +34259,8 @@ fn __action218< fn __action219< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34228,8 +34270,8 @@ fn __action219< fn __action220< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34239,9 +34281,9 @@ fn __action220< fn __action221< >( mode: Mode, - (_, elements, _): (TextSize, Vec, TextSize), + (_, elements, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, core::option::Option, TextSize), -) -> Vec +) -> Vec { elements } @@ -34251,8 +34293,8 @@ fn __action221< fn __action222< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34264,13 +34306,15 @@ fn __action223< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Starred( - ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ) + ast::ExprStarred { + value: Box::new(value.into()), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -34292,18 +34336,19 @@ fn __action225< (_, location, _): (TextSize, TextSize, TextSize), (_, is_async, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, target, _): (TextSize, ast::Expr, TextSize), + (_, target, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, iter, _): (TextSize, ast::Expr, TextSize), - (_, ifs, _): (TextSize, alloc::vec::Vec, TextSize), + (_, iter, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, ifs, _): (TextSize, alloc::vec::Vec, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::Comprehension { { let is_async = is_async.is_some(); + let ifs = ifs.into_iter().map(ast::Expr::from).collect(); ast::Comprehension { - target: set_context(target, ast::ExprContext::Store), - iter, + target: set_context(target.into(), ast::ExprContext::Store), + iter: iter.into(), ifs, is_async, range: (location..end_location).into() @@ -34316,8 +34361,8 @@ fn __action225< fn __action226< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34328,8 +34373,8 @@ fn __action227< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, c, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, c, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { c } @@ -34362,21 +34407,21 @@ fn __action229< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), - (_, c, _): (TextSize, core::option::Option>, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, generators, _): (TextSize, core::option::Option>, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { { - let expr = match c { - Some(c) => ast::Expr::GeneratorExp( + let expr = match generators { + Some(generators) => ast::Expr::GeneratorExp( ast::ExprGeneratorExp { - elt: Box::new(e), - generators: c, + elt: Box::new(elt.into()), + generators, range: (location..end_location).into() } ), - None => e, + None => elt.into(), }; (None, expr) } @@ -34390,11 +34435,11 @@ fn __action230< (_, location, _): (TextSize, TextSize, TextSize), (_, i, _): (TextSize, ast::Identifier, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { - (Some((location, end_location, Some(i))), e) + (Some((location, end_location, Some(i))), e.into()) } #[allow(unused_variables)] @@ -34404,14 +34449,14 @@ fn __action231< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { { - let expr = ast::Expr::Starred( - ast::ExprStarred { value: Box::new(e), ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - ); + let expr = ast::Expr::Starred(ast::ExprStarred { + value: Box::new(value.into()), ctx: ast::ExprContext::Load, range: (location..end_location).into(), + }); (None, expr) } } @@ -34423,11 +34468,11 @@ fn __action232< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { - (Some((location, end_location, None)), e) + (Some((location, end_location, None)), e.into()) } #[allow(unused_variables)] @@ -34523,7 +34568,7 @@ fn __action240< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> alloc::vec::Vec +) -> alloc::vec::Vec { alloc::vec![] } @@ -34533,8 +34578,8 @@ fn __action240< fn __action241< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), +) -> alloc::vec::Vec { v } @@ -34545,16 +34590,14 @@ fn __action242< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, mut values, _): (TextSize, alloc::vec::Vec, TextSize), - (_, last, _): (TextSize, ast::Expr, TextSize), + (_, values, _): (TextSize, alloc::vec::Vec, TextSize), + (_, last, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - values.push(last); - ast::Expr::BoolOp( - ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() } - ) + let values = values.into_iter().chain(std::iter::once(last)).map(ast::Expr::from).collect(); + ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() }.into() } } @@ -34563,8 +34606,8 @@ fn __action242< fn __action243< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34598,18 +34641,20 @@ fn __action246< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, elts, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, trailing_comma, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { if elts.len() == 1 && trailing_comma.is_none() { - elts.into_iter().next().unwrap() + ast::ParenthesizedExpr { + expr: elts.into_iter().next().unwrap().into(), + range: (location..end_location).into(), + } } else { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } } } @@ -34619,8 +34664,8 @@ fn __action246< fn __action247< >( mode: Mode, - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { vec![e] } @@ -34630,10 +34675,10 @@ fn __action247< fn __action248< >( mode: Mode, - (_, mut v, _): (TextSize, Vec, TextSize), + (_, mut v, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { { v.push(e); @@ -34647,18 +34692,20 @@ fn __action249< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, elts, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, trailing_comma, _): (TextSize, core::option::Option, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { if elts.len() == 1 && trailing_comma.is_none() { - elts.into_iter().next().unwrap() + ast::ParenthesizedExpr { + expr: elts.into_iter().next().unwrap().into(), + range: (location..end_location).into(), + } } else { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } } } @@ -34668,8 +34715,8 @@ fn __action249< fn __action250< >( mode: Mode, - (_, e, _): (TextSize, (Option>, ast::Expr), TextSize), -) -> Vec<(Option>, ast::Expr)> + (_, e, _): (TextSize, (Option>, ast::ParenthesizedExpr), TextSize), +) -> Vec<(Option>, ast::ParenthesizedExpr)> { vec![e] } @@ -34679,10 +34726,10 @@ fn __action250< fn __action251< >( mode: Mode, - (_, mut v, _): (TextSize, Vec<(Option>, ast::Expr)>, TextSize), + (_, mut v, _): (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, (Option>, ast::Expr), TextSize), -) -> Vec<(Option>, ast::Expr)> + (_, e, _): (TextSize, (Option>, ast::ParenthesizedExpr), TextSize), +) -> Vec<(Option>, ast::ParenthesizedExpr)> { { v.push(e); @@ -34695,8 +34742,8 @@ fn __action251< fn __action252< >( mode: Mode, - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { vec![e] } @@ -34706,10 +34753,10 @@ fn __action252< fn __action253< >( mode: Mode, - (_, mut v, _): (TextSize, Vec, TextSize), + (_, mut v, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { { v.push(e); @@ -34722,8 +34769,8 @@ fn __action253< fn __action254< >( mode: Mode, - (_, __0, _): (TextSize, Option, TextSize), -) -> core::option::Option> + (_, __0, _): (TextSize, Option, TextSize), +) -> core::option::Option> { Some(__0) } @@ -34735,7 +34782,7 @@ fn __action255< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option> +) -> core::option::Option> { None } @@ -34745,10 +34792,10 @@ fn __action255< fn __action256< >( mode: Mode, - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, e1, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e2, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { vec![e1, e2] } @@ -34758,10 +34805,10 @@ fn __action256< fn __action257< >( mode: Mode, - (_, mut v, _): (TextSize, Vec, TextSize), + (_, mut v, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { { v.push(e); @@ -34956,8 +35003,8 @@ fn __action267< fn __action268< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -34969,7 +35016,7 @@ fn __action269< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -34980,8 +35027,8 @@ fn __action270< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -34991,8 +35038,8 @@ fn __action270< fn __action271< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -35004,7 +35051,7 @@ fn __action272< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -35015,8 +35062,8 @@ fn __action273< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -35169,8 +35216,8 @@ fn __action280< fn __action281< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -35182,7 +35229,7 @@ fn __action282< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -35193,8 +35240,8 @@ fn __action283< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -35250,8 +35297,8 @@ fn __action287< fn __action288< >( mode: Mode, - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { vec![e] } @@ -35261,10 +35308,10 @@ fn __action288< fn __action289< >( mode: Mode, - (_, mut v, _): (TextSize, Vec, TextSize), + (_, mut v, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { { v.push(e); @@ -35300,12 +35347,16 @@ fn __action291< fn __action292< >( mode: Mode, - (_, location, _): (TextSize, TextSize, TextSize), - (_, context_expr, _): (TextSize, ast::Expr, TextSize), - (_, end_location, _): (TextSize, TextSize, TextSize), + (_, context_expr, _): (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::WithItem { - ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() } + { + ast::WithItem { + range: context_expr.range(), + context_expr: context_expr.into(), + optional_vars: None, + } + } } #[allow(unused_variables)] @@ -35359,12 +35410,16 @@ fn __action296< fn __action297< >( mode: Mode, - (_, location, _): (TextSize, TextSize, TextSize), - (_, context_expr, _): (TextSize, ast::Expr, TextSize), - (_, end_location, _): (TextSize, TextSize, TextSize), + (_, context_expr, _): (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::WithItem { - ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() } + { + ast::WithItem { + range: context_expr.range(), + context_expr: context_expr.into(), + optional_vars: None, + } + } } #[allow(unused_variables)] @@ -35418,8 +35473,8 @@ fn __action301< fn __action302< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -35431,7 +35486,7 @@ fn __action303< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -35441,10 +35496,10 @@ fn __action303< fn __action304< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, __1, _): (TextSize, ast::Identifier, TextSize), -) -> (ast::Expr, ast::Identifier) +) -> (ast::ParenthesizedExpr, ast::Identifier) { (__0, __1) } @@ -35634,7 +35689,7 @@ fn __action320< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)> +) -> alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)> { alloc::vec![] } @@ -35644,8 +35699,8 @@ fn __action320< fn __action321< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), -) -> alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)> + (_, v, _): (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), +) -> alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)> { v } @@ -35657,10 +35712,10 @@ fn __action322< mode: Mode, (_, __0, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, __1, _): (TextSize, ast::Expr, TextSize), + (_, __1, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, __2, _): (TextSize, ast::Suite, TextSize), -) -> (TextSize, ast::Expr, ast::Suite) +) -> (TextSize, ast::ParenthesizedExpr, ast::Suite) { (__0, __1, __2) } @@ -35931,10 +35986,10 @@ fn __action342< fn __action343< >( mode: Mode, - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, e1, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e2, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { vec![e1, e2] } @@ -35944,10 +35999,10 @@ fn __action343< fn __action344< >( mode: Mode, - (_, mut v, _): (TextSize, Vec, TextSize), + (_, mut v, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { { v.push(e); @@ -36018,15 +36073,18 @@ fn __action350< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitOr, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -36034,8 +36092,8 @@ fn __action350< fn __action351< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36045,8 +36103,8 @@ fn __action351< fn __action352< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -36058,7 +36116,7 @@ fn __action353< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -36069,8 +36127,8 @@ fn __action354< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36293,8 +36351,8 @@ fn __action371< fn __action372< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -36306,7 +36364,7 @@ fn __action373< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -36317,8 +36375,8 @@ fn __action374< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36328,8 +36386,8 @@ fn __action374< fn __action375< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -36341,7 +36399,7 @@ fn __action376< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -36351,8 +36409,8 @@ fn __action376< fn __action377< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> core::option::Option + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { Some(__0) } @@ -36364,7 +36422,7 @@ fn __action378< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option +) -> core::option::Option { None } @@ -36375,22 +36433,20 @@ fn __action379< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, body, _): (TextSize, ast::Expr, TextSize), + (_, body, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, test, _): (TextSize, ast::Expr, TextSize), + (_, test, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, orelse, _): (TextSize, ast::Expr, TextSize), + (_, orelse, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::IfExp( - ast::ExprIfExp { - test: Box::new(test), - body: Box::new(body), - orelse: Box::new(orelse), - range: (location..end_location).into() - } - ) + ast::ExprIfExp { + test: Box::new(test.into()), + body: Box::new(body.into()), + orelse: Box::new(orelse.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -36398,8 +36454,8 @@ fn __action379< fn __action380< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36409,8 +36465,8 @@ fn __action380< fn __action381< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36422,7 +36478,7 @@ fn __action382< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> alloc::vec::Vec +) -> alloc::vec::Vec { alloc::vec![] } @@ -36432,8 +36488,8 @@ fn __action382< fn __action383< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), +) -> alloc::vec::Vec { v } @@ -36603,8 +36659,8 @@ fn __action397< fn __action398< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { alloc::vec![__0] } @@ -36614,9 +36670,9 @@ fn __action398< fn __action399< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } @@ -36662,15 +36718,18 @@ fn __action403< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitXor, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -36678,8 +36737,8 @@ fn __action403< fn __action404< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36735,8 +36794,8 @@ fn __action408< fn __action409< >( mode: Mode, - (_, __0, _): (TextSize, (TextSize, ast::Expr, ast::Suite), TextSize), -) -> alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)> + (_, __0, _): (TextSize, (TextSize, ast::ParenthesizedExpr, ast::Suite), TextSize), +) -> alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)> { alloc::vec![__0] } @@ -36746,9 +36805,9 @@ fn __action409< fn __action410< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), - (_, e, _): (TextSize, (TextSize, ast::Expr, ast::Suite), TextSize), -) -> alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)> + (_, v, _): (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), + (_, e, _): (TextSize, (TextSize, ast::ParenthesizedExpr, ast::Suite), TextSize), +) -> alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)> { { let mut v = v; v.push(e); v } } @@ -36759,22 +36818,20 @@ fn __action411< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, body, _): (TextSize, ast::Expr, TextSize), + (_, body, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, test, _): (TextSize, ast::Expr, TextSize), + (_, test, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, orelse, _): (TextSize, ast::Expr, TextSize), + (_, orelse, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::IfExp( - ast::ExprIfExp { - test: Box::new(test), - body: Box::new(body), - orelse: Box::new(orelse), - range: (location..end_location).into() - } - ) + ast::ExprIfExp { + test: Box::new(test.into()), + body: Box::new(body.into()), + orelse: Box::new(orelse.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -36782,8 +36839,8 @@ fn __action411< fn __action412< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -36793,8 +36850,8 @@ fn __action412< fn __action413< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37061,8 +37118,8 @@ fn __action431< fn __action432< >( mode: Mode, - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { vec![e] } @@ -37072,10 +37129,10 @@ fn __action432< fn __action433< >( mode: Mode, - (_, mut v, _): (TextSize, Vec, TextSize), + (_, mut v, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> Vec + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Vec { { v.push(e); @@ -37088,8 +37145,8 @@ fn __action433< fn __action434< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { alloc::vec![__0] } @@ -37099,9 +37156,9 @@ fn __action434< fn __action435< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } @@ -37111,9 +37168,9 @@ fn __action435< fn __action436< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { __0 } @@ -37124,16 +37181,14 @@ fn __action437< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, mut values, _): (TextSize, alloc::vec::Vec, TextSize), - (_, last, _): (TextSize, ast::Expr, TextSize), + (_, values, _): (TextSize, alloc::vec::Vec, TextSize), + (_, last, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - values.push(last); - ast::Expr::BoolOp( - ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() } - ) + let values = values.into_iter().chain(std::iter::once(last)).map(ast::Expr::from).collect(); + ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() }.into() } } @@ -37142,8 +37197,8 @@ fn __action437< fn __action438< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37153,8 +37208,8 @@ fn __action438< fn __action439< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { alloc::vec![__0] } @@ -37164,9 +37219,9 @@ fn __action439< fn __action440< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } @@ -37257,8 +37312,8 @@ fn __action447< fn __action448< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { alloc::vec![__0] } @@ -37268,9 +37323,9 @@ fn __action448< fn __action449< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } @@ -37280,9 +37335,9 @@ fn __action449< fn __action450< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { __0 } @@ -37294,13 +37349,15 @@ fn __action451< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, operand, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::UnaryOp( - ast::ExprUnaryOp { operand: Box::new(e), op: ast::UnaryOp::Not, range: (location..end_location).into() } - ) + ast::ExprUnaryOp { + operand: Box::new(operand.into()), + op: ast::UnaryOp::Not, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -37308,8 +37365,8 @@ fn __action451< fn __action452< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37417,12 +37474,12 @@ fn __action461< mode: Mode, (_, mut i, _): (TextSize, ast::ParameterWithDefault, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, default, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::ParameterWithDefault { { - i.default = Some(Box::new(e)); + i.default = Some(Box::new(default.into())); i.range = (i.range.start()..end_location).into(); i } @@ -37554,12 +37611,12 @@ fn __action472< mode: Mode, (_, mut i, _): (TextSize, ast::ParameterWithDefault, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, default, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), ) -> ast::ParameterWithDefault { { - i.default = Some(Box::new(e)); + i.default = Some(Box::new(default.into())); i.range = (i.range.start()..end_location).into(); i } @@ -37617,16 +37674,14 @@ fn __action477< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, mut values, _): (TextSize, alloc::vec::Vec, TextSize), - (_, last, _): (TextSize, ast::Expr, TextSize), + (_, values, _): (TextSize, alloc::vec::Vec, TextSize), + (_, last, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - values.push(last); - ast::Expr::BoolOp( - ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() } - ) + let values = values.into_iter().chain(std::iter::once(last)).map(ast::Expr::from).collect(); + ast::ExprBoolOp { op: ast::BoolOp::Or, values, range: (location..end_location).into() }.into() } } @@ -37635,8 +37690,8 @@ fn __action477< fn __action478< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37647,15 +37702,18 @@ fn __action479< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitAnd, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -37663,8 +37721,8 @@ fn __action479< fn __action480< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37675,15 +37733,18 @@ fn __action481< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -37691,8 +37752,8 @@ fn __action481< fn __action482< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37703,16 +37764,14 @@ fn __action483< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, mut values, _): (TextSize, alloc::vec::Vec, TextSize), - (_, last, _): (TextSize, ast::Expr, TextSize), + (_, values, _): (TextSize, alloc::vec::Vec, TextSize), + (_, last, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - values.push(last); - ast::Expr::BoolOp( - ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() } - ) + let values = values.into_iter().chain(std::iter::once(last)).map(ast::Expr::from).collect(); + ast::ExprBoolOp { op: ast::BoolOp::And, values, range: (location..end_location).into() }.into() } } @@ -37721,8 +37780,8 @@ fn __action483< fn __action484< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37779,16 +37838,14 @@ fn __action489< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, left, _): (TextSize, ast::Expr, TextSize), - (_, comparisons, _): (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, comparisons, _): (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - let (ops, comparators) = comparisons.into_iter().unzip(); - ast::Expr::Compare( - ast::ExprCompare { left: Box::new(left), ops, comparators, range: (location..end_location).into() } - ) + let (ops, comparators) = comparisons.into_iter().map(|(op, comparator)| (op, ast::Expr::from(comparator))).unzip(); + ast::ExprCompare { left: Box::new(left.into()), ops, comparators, range: (location..end_location).into() }.into() } } @@ -37797,8 +37854,8 @@ fn __action489< fn __action490< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37808,8 +37865,8 @@ fn __action490< fn __action491< >( mode: Mode, - (_, __0, _): (TextSize, (ast::CmpOp, ast::Expr), TextSize), -) -> alloc::vec::Vec<(ast::CmpOp, ast::Expr)> + (_, __0, _): (TextSize, (ast::CmpOp, ast::ParenthesizedExpr), TextSize), +) -> alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)> { alloc::vec![__0] } @@ -37819,9 +37876,9 @@ fn __action491< fn __action492< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), - (_, e, _): (TextSize, (ast::CmpOp, ast::Expr), TextSize), -) -> alloc::vec::Vec<(ast::CmpOp, ast::Expr)> + (_, v, _): (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), + (_, e, _): (TextSize, (ast::CmpOp, ast::ParenthesizedExpr), TextSize), +) -> alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)> { { let mut v = v; v.push(e); v } } @@ -37832,8 +37889,8 @@ fn __action493< >( mode: Mode, (_, __0, _): (TextSize, ast::CmpOp, TextSize), - (_, __1, _): (TextSize, ast::Expr, TextSize), -) -> (ast::CmpOp, ast::Expr) + (_, __1, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> (ast::CmpOp, ast::ParenthesizedExpr) { (__0, __1) } @@ -37845,13 +37902,15 @@ fn __action494< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, operand, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::UnaryOp( - ast::ExprUnaryOp { operand: Box::new(e), op: ast::UnaryOp::Not, range: (location..end_location).into() } - ) + ast::ExprUnaryOp { + operand: Box::new(operand.into()), + op: ast::UnaryOp::Not, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -37859,8 +37918,8 @@ fn __action494< fn __action495< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37871,15 +37930,18 @@ fn __action496< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, a, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, b, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -37887,8 +37949,8 @@ fn __action496< fn __action497< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37899,15 +37961,18 @@ fn __action498< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, a, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, b, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -37915,8 +37980,8 @@ fn __action498< fn __action499< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37927,16 +37992,14 @@ fn __action500< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, left, _): (TextSize, ast::Expr, TextSize), - (_, comparisons, _): (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, comparisons, _): (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - let (ops, comparators) = comparisons.into_iter().unzip(); - ast::Expr::Compare( - ast::ExprCompare { left: Box::new(left), ops, comparators, range: (location..end_location).into() } - ) + let (ops, comparators) = comparisons.into_iter().map(|(op, comparator)| (op, ast::Expr::from(comparator))).unzip(); + ast::ExprCompare { left: Box::new(left.into()), ops, comparators, range: (location..end_location).into() }.into() } } @@ -37945,8 +38008,8 @@ fn __action500< fn __action501< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37957,15 +38020,18 @@ fn __action502< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitOr, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitOr, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -37973,8 +38039,8 @@ fn __action502< fn __action503< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -37986,13 +38052,15 @@ fn __action504< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, op, _): (TextSize, ast::UnaryOp, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, operand, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::UnaryOp( - ast::ExprUnaryOp { operand: Box::new(e), op, range: (location..end_location).into() } - ) + ast::ExprUnaryOp { + operand: Box::new(operand.into()), + op, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38000,8 +38068,8 @@ fn __action504< fn __action505< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38012,15 +38080,18 @@ fn __action506< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, b, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::Pow, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38028,8 +38099,8 @@ fn __action506< fn __action507< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38040,15 +38111,18 @@ fn __action508< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitXor, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitXor, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -38056,8 +38130,8 @@ fn __action508< fn __action509< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38068,15 +38142,18 @@ fn __action510< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op: ast::Operator::BitAnd, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::BitAnd, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -38084,8 +38161,8 @@ fn __action510< fn __action511< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38097,14 +38174,12 @@ fn __action512< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, atom, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::Await( - ast::ExprAwait { value: Box::new(atom), range: (location..end_location).into() } - ) + ast::ExprAwait { value: Box::new(value.into()), range: (location..end_location).into() }.into() } } @@ -38113,8 +38188,8 @@ fn __action512< fn __action513< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38124,8 +38199,8 @@ fn __action513< fn __action514< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38136,16 +38211,16 @@ fn __action515< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, f, _): (TextSize, ast::Expr, TextSize), + (_, func, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, arguments, _): (TextSize, ast::Arguments, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - { - ast::Expr::Call( - ast::ExprCall { func: Box::new(f), arguments, range: (location..end_location).into() } - ) - } + ast::ExprCall { + func: Box::new(func.into()), + arguments, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38154,16 +38229,19 @@ fn __action516< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, s, _): (TextSize, ast::Expr, TextSize), + (_, slice, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Subscript( - ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprSubscript { + value: Box::new(value.into()), + slice: Box::new(slice.into()), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38172,15 +38250,18 @@ fn __action517< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, attr, _): (TextSize, ast::Identifier, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Attribute( - ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprAttribute { + value: Box::new(value.into()), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38189,15 +38270,18 @@ fn __action518< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e1, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, e2, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e1), op, right: Box::new(e2), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into() + }.into() } #[allow(unused_variables)] @@ -38205,8 +38289,8 @@ fn __action518< fn __action519< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38217,15 +38301,18 @@ fn __action520< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, a, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, b, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38233,8 +38320,8 @@ fn __action520< fn __action521< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38246,9 +38333,9 @@ fn __action522< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, s, _): (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), -) -> Result> +) -> Result> { - Ok(parse_strings(s)?) + Ok(parse_strings(s)?.into()) } #[allow(unused_variables)] @@ -38259,11 +38346,12 @@ fn __action523< (_, location, _): (TextSize, TextSize, TextSize), (_, value, _): (TextSize, ast::Constant, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant( - ast::ExprConstant { value, kind: None, range: (location..end_location).into() } - ) + ast::ExprConstant { + value, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38274,11 +38362,13 @@ fn __action524< (_, location, _): (TextSize, TextSize, TextSize), (_, id, _): (TextSize, ast::Identifier, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Name( - ast::ExprName { id: id.into(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprName { + id: id.into(), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38288,16 +38378,14 @@ fn __action525< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, core::option::Option>, TextSize), + (_, elts, _): (TextSize, core::option::Option>, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - let elts = e.unwrap_or_default(); - ast::Expr::List( - ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().flatten().map(ast::Expr::from).collect(); + ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } } @@ -38308,16 +38396,14 @@ fn __action526< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elt, _): (TextSize, ast::Expr, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::ListComp( - ast::ExprListComp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) + ast::ExprListComp { elt: Box::new(elt.into()), generators, range: (location..end_location).into() }.into() } } @@ -38328,19 +38414,21 @@ fn __action527< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elts, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, trailing_comma, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { if elts.len() == 1 && trailing_comma.is_none() { - elts.into_iter().next().unwrap() + ast::ParenthesizedExpr { + expr: elts.into_iter().next().unwrap().into(), + range: (location..end_location).into(), + } } else { - ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } } } @@ -38352,28 +38440,29 @@ fn __action528< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, left, _): (TextSize, core::option::Option>, TextSize), - (_, mid, _): (TextSize, ast::Expr, TextSize), - (_, right, _): (TextSize, alloc::vec::Vec, TextSize), + (_, left, _): (TextSize, core::option::Option>, TextSize), + (_, mid, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, right, _): (TextSize, alloc::vec::Vec, TextSize), (_, trailing_comma, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { { if left.is_none() && right.is_empty() && trailing_comma.is_none() { - if mid.is_starred_expr() { + if mid.expr.is_starred_expr() { return Err(LexicalError{ error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()), location: mid.start(), })?; } - Ok(mid) + Ok(ast::ParenthesizedExpr { + expr: mid.into(), + range: (location..end_location).into(), + }) } else { - let elts = left.into_iter().flatten().chain([mid]).chain(right).collect(); - Ok(ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - )) + let elts = left.into_iter().flatten().chain([mid]).chain(right).map(ast::Expr::from).collect(); + Ok(ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into()) } } } @@ -38387,11 +38476,13 @@ fn __action529< (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Tuple( - ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprTuple { + elts: Vec::new(), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38399,12 +38490,17 @@ fn __action529< fn __action530< >( mode: Mode, + (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), -) -> ast::Expr + (_, end_location, _): (TextSize, TextSize, TextSize), +) -> ast::ParenthesizedExpr { - e + ast::ParenthesizedExpr { + expr: e.into(), + range: (location..end_location).into(), + } } #[allow(unused_variables)] @@ -38414,17 +38510,17 @@ fn __action531< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elt, _): (TextSize, ast::Expr, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - { - ast::Expr::GeneratorExp( - ast::ExprGeneratorExp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) - } + ast::ExprGeneratorExp { + elt: Box::new(elt.into()), + generators, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38435,10 +38531,10 @@ fn __action532< (_, _, _): (TextSize, token::Tok, TextSize), (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { { Err(LexicalError{ @@ -38455,20 +38551,18 @@ fn __action533< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, core::option::Option>, ast::Expr)>>, TextSize), + (_, e, _): (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { let (keys, values) = e .unwrap_or_default() .into_iter() - .map(|(k, v)| (k.map(|x| *x), v)) + .map(|(k, v)| (k.map(|x| ast::Expr::from(*x)), ast::Expr::from(v))) .unzip(); - ast::Expr::Dict( - ast::ExprDict { keys, values, range: (location..end_location).into() } - ) + ast::ExprDict { keys, values, range: (location..end_location).into() }.into() } } @@ -38479,21 +38573,19 @@ fn __action534< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e1, _): (TextSize, (ast::Expr, ast::Expr), TextSize), + (_, e1, _): (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::DictComp( - ast::ExprDictComp { - key: Box::new(e1.0), - value: Box::new(e1.1), - generators, - range: (location..end_location).into() - } - ) + ast::ExprDictComp { + key: Box::new(e1.0.into()), + value: Box::new(e1.1.into()), + generators, + range: (location..end_location).into() + }.into() } } @@ -38504,14 +38596,18 @@ fn __action535< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elts, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Set( - ast::ExprSet { elts, range: (location..end_location).into() } - ) + { + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprSet { + elts, + range: (location..end_location).into(), + }.into() + } } #[allow(unused_variables)] @@ -38521,17 +38617,17 @@ fn __action536< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elt, _): (TextSize, ast::Expr, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - { - ast::Expr::SetComp( - ast::ExprSetComp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) - } + ast::ExprSetComp { + elt: Box::new(elt.into()), + generators, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38542,9 +38638,9 @@ fn __action537< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: true.into(), kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: true.into(), range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -38555,9 +38651,9 @@ fn __action538< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: false.into(), kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: false.into(), range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -38568,9 +38664,9 @@ fn __action539< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::None, kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: ast::Constant::None, range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -38581,9 +38677,9 @@ fn __action540< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: ast::Constant::Ellipsis, range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -38591,8 +38687,8 @@ fn __action540< fn __action541< >( mode: Mode, - (_, __0, _): (TextSize, Vec<(Option>, ast::Expr)>, TextSize), -) -> core::option::Option>, ast::Expr)>> + (_, __0, _): (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), +) -> core::option::Option>, ast::ParenthesizedExpr)>> { Some(__0) } @@ -38604,7 +38700,7 @@ fn __action542< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option>, ast::Expr)>> +) -> core::option::Option>, ast::ParenthesizedExpr)>> { None } @@ -38616,7 +38712,7 @@ fn __action543< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> alloc::vec::Vec +) -> alloc::vec::Vec { alloc::vec![] } @@ -38626,8 +38722,8 @@ fn __action543< fn __action544< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), +) -> alloc::vec::Vec { v } @@ -38638,8 +38734,8 @@ fn __action545< >( mode: Mode, (_, _, _): (TextSize, token::Tok, TextSize), - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38649,8 +38745,8 @@ fn __action545< fn __action546< >( mode: Mode, - (_, __0, _): (TextSize, Vec, TextSize), -) -> core::option::Option> + (_, __0, _): (TextSize, Vec, TextSize), +) -> core::option::Option> { Some(__0) } @@ -38662,7 +38758,7 @@ fn __action547< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option> +) -> core::option::Option> { None } @@ -38672,9 +38768,9 @@ fn __action547< fn __action548< >( mode: Mode, - (_, __0, _): (TextSize, Vec, TextSize), + (_, __0, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), -) -> Vec +) -> Vec { __0 } @@ -38684,8 +38780,8 @@ fn __action548< fn __action549< >( mode: Mode, - (_, __0, _): (TextSize, Vec, TextSize), -) -> core::option::Option> + (_, __0, _): (TextSize, Vec, TextSize), +) -> core::option::Option> { Some(__0) } @@ -38697,7 +38793,7 @@ fn __action550< mode: Mode, __lookbehind: &TextSize, __lookahead: &TextSize, -) -> core::option::Option> +) -> core::option::Option> { None } @@ -38708,15 +38804,18 @@ fn __action551< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, a, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, op, _): (TextSize, ast::Operator, TextSize), - (_, b, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(a), op, right: Box::new(b), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38724,8 +38823,8 @@ fn __action551< fn __action552< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38737,13 +38836,15 @@ fn __action553< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, op, _): (TextSize, ast::UnaryOp, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, operand, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::UnaryOp( - ast::ExprUnaryOp { operand: Box::new(e), op, range: (location..end_location).into() } - ) + ast::ExprUnaryOp { + operand: Box::new(operand.into()), + op, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38751,8 +38852,8 @@ fn __action553< fn __action554< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38762,8 +38863,8 @@ fn __action554< fn __action555< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { alloc::vec![__0] } @@ -38773,9 +38874,9 @@ fn __action555< fn __action556< >( mode: Mode, - (_, v, _): (TextSize, alloc::vec::Vec, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + (_, v, _): (TextSize, alloc::vec::Vec, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { { let mut v = v; v.push(e); v } } @@ -38786,15 +38887,18 @@ fn __action557< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, left, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, b, _): (TextSize, ast::Expr, TextSize), + (_, right, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::BinOp( - ast::ExprBinOp { left: Box::new(e), op: ast::Operator::Pow, right: Box::new(b), range: (location..end_location).into() } - ) + ast::ExprBinOp { + left: Box::new(left.into()), + op: ast::Operator::Pow, + right: Box::new(right.into()), + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38802,8 +38906,8 @@ fn __action557< fn __action558< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38815,14 +38919,12 @@ fn __action559< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, atom, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::Await( - ast::ExprAwait { value: Box::new(atom), range: (location..end_location).into() } - ) + ast::ExprAwait { value: Box::new(value.into()), range: (location..end_location).into() }.into() } } @@ -38831,8 +38933,8 @@ fn __action559< fn __action560< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38842,8 +38944,8 @@ fn __action560< fn __action561< >( mode: Mode, - (_, __0, _): (TextSize, ast::Expr, TextSize), -) -> ast::Expr + (_, __0, _): (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { __0 } @@ -38854,16 +38956,16 @@ fn __action562< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, f, _): (TextSize, ast::Expr, TextSize), + (_, func, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, arguments, _): (TextSize, ast::Arguments, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - { - ast::Expr::Call( - ast::ExprCall { func: Box::new(f), arguments, range: (location..end_location).into() } - ) - } + ast::ExprCall { + func: Box::new(func.into()), + arguments, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38872,16 +38974,19 @@ fn __action563< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, s, _): (TextSize, ast::Expr, TextSize), + (_, slice, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Subscript( - ast::ExprSubscript { value: Box::new(e), slice: Box::new(s), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprSubscript { + value: Box::new(value.into()), + slice: Box::new(slice.into()), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38890,15 +38995,18 @@ fn __action564< >( mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, value, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, attr, _): (TextSize, ast::Identifier, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Attribute( - ast::ExprAttribute { value: Box::new(e), attr, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprAttribute { + value: Box::new(value.into()), + attr, + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38908,9 +39016,9 @@ fn __action565< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, s, _): (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), -) -> Result> +) -> Result> { - Ok(parse_strings(s)?) + Ok(parse_strings(s)?.into()) } #[allow(unused_variables)] @@ -38921,11 +39029,12 @@ fn __action566< (_, location, _): (TextSize, TextSize, TextSize), (_, value, _): (TextSize, ast::Constant, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant( - ast::ExprConstant { value, kind: None, range: (location..end_location).into() } - ) + ast::ExprConstant { + value, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38936,11 +39045,13 @@ fn __action567< (_, location, _): (TextSize, TextSize, TextSize), (_, id, _): (TextSize, ast::Identifier, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Name( - ast::ExprName { id: id.into(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprName { + id: id.into(), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -38950,16 +39061,14 @@ fn __action568< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, core::option::Option>, TextSize), + (_, elts, _): (TextSize, core::option::Option>, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - let elts = e.unwrap_or_default(); - ast::Expr::List( - ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + let elts = elts.into_iter().flatten().map(ast::Expr::from).collect(); + ast::ExprList { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into() } } @@ -38970,16 +39079,14 @@ fn __action569< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elt, _): (TextSize, ast::Expr, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::ListComp( - ast::ExprListComp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) + ast::ExprListComp { elt: Box::new(elt.into()), generators, range: (location..end_location).into() }.into() } } @@ -38990,28 +39097,29 @@ fn __action570< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, left, _): (TextSize, core::option::Option>, TextSize), - (_, mid, _): (TextSize, ast::Expr, TextSize), - (_, right, _): (TextSize, alloc::vec::Vec, TextSize), + (_, left, _): (TextSize, core::option::Option>, TextSize), + (_, mid, _): (TextSize, ast::ParenthesizedExpr, TextSize), + (_, right, _): (TextSize, alloc::vec::Vec, TextSize), (_, trailing_comma, _): (TextSize, core::option::Option, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { { if left.is_none() && right.is_empty() && trailing_comma.is_none() { - if mid.is_starred_expr() { + if mid.expr.is_starred_expr() { return Err(LexicalError{ error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()), location: mid.start(), })?; } - Ok(mid) + Ok(ast::ParenthesizedExpr { + expr: mid.into(), + range: (location..end_location).into(), + }) } else { - let elts = left.into_iter().flatten().chain([mid]).chain(right).collect(); - Ok(ast::Expr::Tuple( - ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }, - )) + let elts = left.into_iter().flatten().chain([mid]).chain(right).map(ast::Expr::from).collect(); + Ok(ast::ExprTuple { elts, ctx: ast::ExprContext::Load, range: (location..end_location).into() }.into()) } } } @@ -39025,11 +39133,13 @@ fn __action571< (_, _, _): (TextSize, token::Tok, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Tuple( - ast::ExprTuple { elts: Vec::new(), ctx: ast::ExprContext::Load, range: (location..end_location).into() } - ) + ast::ExprTuple { + elts: Vec::new(), + ctx: ast::ExprContext::Load, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -39037,12 +39147,17 @@ fn __action571< fn __action572< >( mode: Mode, + (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), -) -> ast::Expr + (_, end_location, _): (TextSize, TextSize, TextSize), +) -> ast::ParenthesizedExpr { - e + ast::ParenthesizedExpr { + expr: e.into(), + range: (location..end_location).into(), + } } #[allow(unused_variables)] @@ -39052,17 +39167,17 @@ fn __action573< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elt, _): (TextSize, ast::Expr, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - { - ast::Expr::GeneratorExp( - ast::ExprGeneratorExp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) - } + ast::ExprGeneratorExp { + elt: Box::new(elt.into()), + generators, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -39073,10 +39188,10 @@ fn __action574< (_, _, _): (TextSize, token::Tok, TextSize), (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, ast::Expr, TextSize), + (_, e, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { { Err(LexicalError{ @@ -39093,20 +39208,18 @@ fn __action575< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e, _): (TextSize, core::option::Option>, ast::Expr)>>, TextSize), + (_, e, _): (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { let (keys, values) = e .unwrap_or_default() .into_iter() - .map(|(k, v)| (k.map(|x| *x), v)) + .map(|(k, v)| (k.map(|x| ast::Expr::from(*x)), ast::Expr::from(v))) .unzip(); - ast::Expr::Dict( - ast::ExprDict { keys, values, range: (location..end_location).into() } - ) + ast::ExprDict { keys, values, range: (location..end_location).into() }.into() } } @@ -39117,21 +39230,19 @@ fn __action576< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, e1, _): (TextSize, (ast::Expr, ast::Expr), TextSize), + (_, e1, _): (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { { - ast::Expr::DictComp( - ast::ExprDictComp { - key: Box::new(e1.0), - value: Box::new(e1.1), - generators, - range: (location..end_location).into() - } - ) + ast::ExprDictComp { + key: Box::new(e1.0.into()), + value: Box::new(e1.1.into()), + generators, + range: (location..end_location).into() + }.into() } } @@ -39142,14 +39253,18 @@ fn __action577< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elts, _): (TextSize, Vec, TextSize), + (_, elts, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Set( - ast::ExprSet { elts, range: (location..end_location).into() } - ) + { + let elts = elts.into_iter().map(ast::Expr::from).collect(); + ast::ExprSet { + elts, + range: (location..end_location).into(), + }.into() + } } #[allow(unused_variables)] @@ -39159,17 +39274,17 @@ fn __action578< mode: Mode, (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), - (_, elt, _): (TextSize, ast::Expr, TextSize), + (_, elt, _): (TextSize, ast::ParenthesizedExpr, TextSize), (_, generators, _): (TextSize, Vec, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - { - ast::Expr::SetComp( - ast::ExprSetComp { elt: Box::new(elt), generators, range: (location..end_location).into() } - ) - } + ast::ExprSetComp { + elt: Box::new(elt.into()), + generators, + range: (location..end_location).into(), + }.into() } #[allow(unused_variables)] @@ -39180,9 +39295,9 @@ fn __action579< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: true.into(), kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: true.into(), range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -39193,9 +39308,9 @@ fn __action580< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: false.into(), kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: false.into(), range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -39206,9 +39321,9 @@ fn __action581< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::None, kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: ast::Constant::None, range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -39219,9 +39334,9 @@ fn __action582< (_, location, _): (TextSize, TextSize, TextSize), (_, _, _): (TextSize, token::Tok, TextSize), (_, end_location, _): (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { - ast::Expr::Constant(ast::ExprConstant { value: ast::Constant::Ellipsis, kind: None, range: (location..end_location).into() }) + ast::ExprConstant { value: ast::Constant::Ellipsis, range: (location..end_location).into() }.into() } #[allow(unused_variables)] @@ -39231,11 +39346,11 @@ fn __action583< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Vec, TextSize), + __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __3.0; let __end0 = __3.2; @@ -39262,10 +39377,10 @@ fn __action584< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Vec, TextSize), + __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __3.0; @@ -39293,13 +39408,13 @@ fn __action585< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option>, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, core::option::Option>, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __5.0; let __end0 = __5.2; @@ -39328,12 +39443,12 @@ fn __action586< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option>, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, core::option::Option>, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __4.2; let __end0 = __5.0; @@ -39363,13 +39478,13 @@ fn __action587< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option>, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, core::option::Option>, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __5.0; let __end0 = __5.2; @@ -39398,12 +39513,12 @@ fn __action588< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option>, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, core::option::Option>, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __4.2; let __end0 = __5.0; @@ -39431,9 +39546,9 @@ fn __action588< fn __action589< >( mode: Mode, - __0: (TextSize, Vec<(Option>, ast::Expr)>, TextSize), + __0: (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> Vec<(Option>, ast::Expr)> +) -> Vec<(Option>, ast::ParenthesizedExpr)> { let __start0 = __1.0; let __end0 = __1.2; @@ -39454,8 +39569,8 @@ fn __action589< fn __action590< >( mode: Mode, - __0: (TextSize, Vec<(Option>, ast::Expr)>, TextSize), -) -> Vec<(Option>, ast::Expr)> + __0: (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), +) -> Vec<(Option>, ast::ParenthesizedExpr)> { let __start0 = __0.2; let __end0 = __0.2; @@ -39477,9 +39592,9 @@ fn __action590< fn __action591< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> Vec +) -> Vec { let __start0 = __1.0; let __end0 = __1.2; @@ -39500,8 +39615,8 @@ fn __action591< fn __action592< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> Vec + __0: (TextSize, Vec, TextSize), +) -> Vec { let __start0 = __0.2; let __end0 = __0.2; @@ -39524,10 +39639,10 @@ fn __action593< >( mode: Mode, __0: (TextSize, TextSize, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.0; let __end0 = __2.2; @@ -39551,9 +39666,9 @@ fn __action594< >( mode: Mode, __0: (TextSize, TextSize, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __2.0; @@ -39578,10 +39693,10 @@ fn __action595< >( mode: Mode, __0: (TextSize, TextSize, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.0; let __end0 = __2.2; @@ -39605,9 +39720,9 @@ fn __action596< >( mode: Mode, __0: (TextSize, TextSize, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __2.0; @@ -39693,9 +39808,9 @@ fn __action598< fn __action599< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> Vec +) -> Vec { let __start0 = __1.0; let __end0 = __1.2; @@ -39716,8 +39831,8 @@ fn __action599< fn __action600< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> Vec + __0: (TextSize, Vec, TextSize), +) -> Vec { let __start0 = __0.2; let __end0 = __0.2; @@ -39943,7 +40058,7 @@ fn __action607< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Vec, TextSize), + __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), @@ -39980,7 +40095,7 @@ fn __action608< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Vec, TextSize), + __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), @@ -40777,9 +40892,9 @@ fn __action634< fn __action635< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> Vec +) -> Vec { let __start0 = __1.0; let __end0 = __1.2; @@ -40800,8 +40915,8 @@ fn __action635< fn __action636< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> Vec + __0: (TextSize, Vec, TextSize), +) -> Vec { let __start0 = __0.2; let __end0 = __0.2; @@ -40824,10 +40939,10 @@ fn __action637< >( mode: Mode, __0: (TextSize, TextSize, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.0; let __end0 = __2.2; @@ -40851,9 +40966,9 @@ fn __action638< >( mode: Mode, __0: (TextSize, TextSize, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __2.0; @@ -41282,9 +41397,9 @@ fn __action653< __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, ast::Expr, TextSize), + __5: (TextSize, ast::ParenthesizedExpr, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), __8: (TextSize, core::option::Option, TextSize), @@ -41318,9 +41433,9 @@ fn __action654< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), __7: (TextSize, core::option::Option, TextSize), @@ -41360,7 +41475,7 @@ fn __action655< __4: (TextSize, ast::Identifier, TextSize), __5: (TextSize, core::option::Option, TextSize), __6: (TextSize, ast::Parameters, TextSize), - __7: (TextSize, core::option::Option, TextSize), + __7: (TextSize, core::option::Option, TextSize), __8: (TextSize, token::Tok, TextSize), __9: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -41398,7 +41513,7 @@ fn __action656< __3: (TextSize, ast::Identifier, TextSize), __4: (TextSize, core::option::Option, TextSize), __5: (TextSize, ast::Parameters, TextSize), - __6: (TextSize, core::option::Option, TextSize), + __6: (TextSize, core::option::Option, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -41434,10 +41549,10 @@ fn __action657< __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, ast::Expr, TextSize), - __6: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, ast::ParenthesizedExpr, TextSize), + __6: (TextSize, alloc::vec::Vec, TextSize), __7: (TextSize, TextSize, TextSize), ) -> ast::Comprehension { @@ -41468,10 +41583,10 @@ fn __action658< mode: Mode, __0: (TextSize, TextSize, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), __6: (TextSize, TextSize, TextSize), ) -> ast::Comprehension { @@ -42510,10 +42625,10 @@ fn __action695< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), -) -> (TextSize, ast::Expr, ast::Suite) +) -> (TextSize, ast::ParenthesizedExpr, ast::Suite) { let __start0 = __0.0; let __end0 = __0.0; @@ -42590,11 +42705,11 @@ fn __action697< fn __action698< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42619,11 +42734,11 @@ fn __action698< fn __action699< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42648,11 +42763,11 @@ fn __action699< fn __action700< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42677,10 +42792,10 @@ fn __action700< fn __action701< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42704,10 +42819,10 @@ fn __action701< fn __action702< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42760,11 +42875,11 @@ fn __action703< fn __action704< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42789,11 +42904,11 @@ fn __action704< fn __action705< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42848,8 +42963,8 @@ fn __action707< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, core::option::Option, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, core::option::Option, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -42877,7 +42992,7 @@ fn __action708< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -42901,7 +43016,7 @@ fn __action709< mode: Mode, __0: (TextSize, ast::Constant, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42926,7 +43041,7 @@ fn __action710< mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42950,10 +43065,10 @@ fn __action711< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), + __1: (TextSize, core::option::Option>, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -42979,11 +43094,11 @@ fn __action712< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43010,11 +43125,11 @@ fn __action713< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43041,10 +43156,10 @@ fn __action714< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43070,13 +43185,13 @@ fn __action715< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -43105,12 +43220,12 @@ fn __action716< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -43140,7 +43255,7 @@ fn __action717< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43165,11 +43280,40 @@ fn __action718< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.0; + let __end0 = __0.0; + let __temp0 = __action393( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action530( + mode, + __temp0, + __0, + __1, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action719< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43192,15 +43336,15 @@ fn __action718< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action719< +fn __action720< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.2; let __end0 = __1.0; @@ -43223,14 +43367,14 @@ fn __action719< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action720< +fn __action721< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, ast::Expr)>>, TextSize), + __1: (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43252,15 +43396,15 @@ fn __action720< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action721< +fn __action722< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, (ast::Expr, ast::Expr), TextSize), + __1: (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43283,14 +43427,14 @@ fn __action721< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action722< +fn __action723< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43312,15 +43456,15 @@ fn __action722< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action723< +fn __action724< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43343,12 +43487,12 @@ fn __action723< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action724< +fn __action725< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43368,12 +43512,12 @@ fn __action724< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action725< +fn __action726< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43393,12 +43537,12 @@ fn __action725< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action726< +fn __action727< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43418,12 +43562,12 @@ fn __action726< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action727< +fn __action728< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43443,11 +43587,11 @@ fn __action727< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action728< +fn __action729< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -43466,12 +43610,12 @@ fn __action728< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action729< +fn __action730< >( mode: Mode, __0: (TextSize, ast::Constant, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43491,12 +43635,12 @@ fn __action729< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action730< +fn __action731< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43516,14 +43660,14 @@ fn __action730< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action731< +fn __action732< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), + __1: (TextSize, core::option::Option>, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43545,15 +43689,15 @@ fn __action731< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action732< +fn __action733< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43576,17 +43720,17 @@ fn __action732< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action733< +fn __action734< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -43611,16 +43755,16 @@ fn __action733< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action734< +fn __action735< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -43644,13 +43788,13 @@ fn __action734< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action735< +fn __action736< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43671,15 +43815,44 @@ fn __action735< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action736< +fn __action737< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.0; + let __end0 = __0.0; + let __temp0 = __action393( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action572( + mode, + __temp0, + __0, + __1, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action738< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43702,15 +43875,15 @@ fn __action736< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action737< +fn __action739< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.2; let __end0 = __1.0; @@ -43733,14 +43906,14 @@ fn __action737< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action738< +fn __action740< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, ast::Expr)>>, TextSize), + __1: (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43762,15 +43935,15 @@ fn __action738< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action739< +fn __action741< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, (ast::Expr, ast::Expr), TextSize), + __1: (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43793,14 +43966,14 @@ fn __action739< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action740< +fn __action742< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43822,15 +43995,15 @@ fn __action740< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action741< +fn __action743< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43853,12 +44026,12 @@ fn __action741< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action742< +fn __action744< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43878,12 +44051,12 @@ fn __action742< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action743< +fn __action745< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43903,12 +44076,12 @@ fn __action743< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action744< +fn __action746< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43928,12 +44101,12 @@ fn __action744< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action745< +fn __action747< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43953,13 +44126,13 @@ fn __action745< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action746< +fn __action748< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Arguments, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -43980,15 +44153,15 @@ fn __action746< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action747< +fn __action749< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44011,14 +44184,14 @@ fn __action747< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action748< +fn __action750< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Identifier, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44040,13 +44213,13 @@ fn __action748< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action749< +fn __action751< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Arguments, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44067,15 +44240,15 @@ fn __action749< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action750< +fn __action752< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44098,14 +44271,14 @@ fn __action750< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action751< +fn __action753< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Identifier, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44127,13 +44300,13 @@ fn __action751< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action752< +fn __action754< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44154,13 +44327,13 @@ fn __action752< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action753< +fn __action755< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44181,7 +44354,7 @@ fn __action753< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action754< +fn __action756< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -44206,7 +44379,7 @@ fn __action754< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action755< +fn __action757< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -44241,7 +44414,7 @@ fn __action755< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action756< +fn __action758< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -44268,7 +44441,7 @@ fn __action756< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action757< +fn __action759< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -44295,13 +44468,13 @@ fn __action757< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action758< +fn __action760< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44322,13 +44495,13 @@ fn __action758< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action759< +fn __action761< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44349,12 +44522,12 @@ fn __action759< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action760< +fn __action762< >( mode: Mode, __0: (TextSize, ast::Constant, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44374,13 +44547,13 @@ fn __action760< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action761< +fn __action763< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44401,11 +44574,11 @@ fn __action761< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action762< +fn __action764< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), __3: (TextSize, token::Tok, TextSize), ) -> ast::Decorator @@ -44430,11 +44603,11 @@ fn __action762< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action763< +fn __action765< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -44457,7 +44630,7 @@ fn __action763< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action764< +fn __action766< >( mode: Mode, __0: (TextSize, String, TextSize), @@ -44482,7 +44655,7 @@ fn __action764< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action765< +fn __action767< >( mode: Mode, __0: (TextSize, String, TextSize), @@ -44509,11 +44682,11 @@ fn __action765< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action766< +fn __action768< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Parameter { @@ -44536,11 +44709,11 @@ fn __action766< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action767< +fn __action769< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -44565,11 +44738,11 @@ fn __action767< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action768< +fn __action770< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, (ast::Expr, ast::Identifier), TextSize), + __1: (TextSize, (ast::ParenthesizedExpr, ast::Identifier), TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -44594,12 +44767,12 @@ fn __action768< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action769< +fn __action771< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -44625,12 +44798,12 @@ fn __action769< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action770< +fn __action772< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, (ast::Expr, ast::Identifier), TextSize), + __2: (TextSize, (ast::ParenthesizedExpr, ast::Identifier), TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, ast::Suite, TextSize), ) -> ast::ExceptHandler @@ -44656,14 +44829,14 @@ fn __action770< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action771< +fn __action773< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44685,14 +44858,14 @@ fn __action771< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action772< +fn __action774< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44714,11 +44887,11 @@ fn __action772< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action773< +fn __action775< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -44741,12 +44914,12 @@ fn __action773< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action774< +fn __action776< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -44770,13 +44943,13 @@ fn __action774< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action775< +fn __action777< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, core::option::Option, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, core::option::Option, TextSize), __4: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -44801,13 +44974,13 @@ fn __action775< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action776< +fn __action778< >( mode: Mode, __0: (TextSize, ast::UnaryOp, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44828,13 +45001,13 @@ fn __action776< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action777< +fn __action779< >( mode: Mode, __0: (TextSize, ast::UnaryOp, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -44855,7 +45028,7 @@ fn __action777< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action778< +fn __action780< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -44880,7 +45053,7 @@ fn __action778< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action779< +fn __action781< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -44905,11 +45078,11 @@ fn __action779< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action780< +fn __action782< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -44932,10 +45105,10 @@ fn __action780< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action781< +fn __action783< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -44957,14 +45130,14 @@ fn __action781< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action782< +fn __action784< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), __7: (TextSize, core::option::Option, TextSize), @@ -44994,13 +45167,13 @@ fn __action782< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action783< +fn __action785< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, ast::Suite, TextSize), __6: (TextSize, core::option::Option, TextSize), @@ -45029,7 +45202,7 @@ fn __action783< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action784< +fn __action786< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -45038,7 +45211,7 @@ fn __action784< __3: (TextSize, ast::Identifier, TextSize), __4: (TextSize, core::option::Option, TextSize), __5: (TextSize, ast::Parameters, TextSize), - __6: (TextSize, core::option::Option, TextSize), + __6: (TextSize, core::option::Option, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -45068,7 +45241,7 @@ fn __action784< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action785< +fn __action787< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -45076,7 +45249,7 @@ fn __action785< __2: (TextSize, ast::Identifier, TextSize), __3: (TextSize, core::option::Option, TextSize), __4: (TextSize, ast::Parameters, TextSize), - __5: (TextSize, core::option::Option, TextSize), + __5: (TextSize, core::option::Option, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -45105,10 +45278,10 @@ fn __action785< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action786< +fn __action788< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, core::option::Option>, TextSize), __2: (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) @@ -45132,12 +45305,12 @@ fn __action786< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action787< +fn __action789< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { @@ -45161,11 +45334,11 @@ fn __action787< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action788< +fn __action790< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { @@ -45188,11 +45361,11 @@ fn __action788< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action789< +fn __action791< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { @@ -45215,13 +45388,13 @@ fn __action789< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action790< +fn __action792< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -45242,12 +45415,12 @@ fn __action790< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action791< +fn __action793< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -45267,13 +45440,13 @@ fn __action791< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action792< +fn __action794< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -45294,12 +45467,12 @@ fn __action792< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action793< +fn __action795< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -45319,7 +45492,7 @@ fn __action793< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action794< +fn __action796< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45346,7 +45519,7 @@ fn __action794< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action795< +fn __action797< >( mode: Mode, __0: (TextSize, String, TextSize), @@ -45371,14 +45544,14 @@ fn __action795< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action796< +fn __action798< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), - __4: (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), + __4: (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), __5: (TextSize, core::option::Option<(TextSize, ast::Suite)>, TextSize), ) -> ast::Stmt { @@ -45404,7 +45577,7 @@ fn __action796< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action797< +fn __action799< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -45431,7 +45604,7 @@ fn __action797< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action798< +fn __action800< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -45458,7 +45631,7 @@ fn __action798< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action799< +fn __action801< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -45483,7 +45656,7 @@ fn __action799< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action800< +fn __action802< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45514,7 +45687,7 @@ fn __action800< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action801< +fn __action803< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45543,7 +45716,7 @@ fn __action801< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action802< +fn __action804< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45568,7 +45741,7 @@ fn __action802< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action803< +fn __action805< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45595,7 +45768,7 @@ fn __action803< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action804< +fn __action806< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45626,12 +45799,12 @@ fn __action804< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action805< +fn __action807< >( mode: Mode, __0: (TextSize, (IpyEscapeKind, String), TextSize), __1: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -45651,7 +45824,7 @@ fn __action805< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action806< +fn __action808< >( mode: Mode, __0: (TextSize, (IpyEscapeKind, String), TextSize), @@ -45676,10 +45849,10 @@ fn __action806< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action807< +fn __action809< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, alloc::vec::Vec, TextSize), __2: (TextSize, TextSize, TextSize), ) -> Result> @@ -45703,16 +45876,16 @@ fn __action807< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action808< +fn __action810< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.0; let __end0 = __0.0; @@ -45745,7 +45918,7 @@ fn __action808< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action809< +fn __action811< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45770,7 +45943,7 @@ fn __action809< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action810< +fn __action812< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45795,7 +45968,7 @@ fn __action810< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action811< +fn __action813< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45820,10 +45993,10 @@ fn __action811< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action812< +fn __action814< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, TextSize, TextSize), ) -> ast::Pattern { @@ -45845,10 +46018,10 @@ fn __action812< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action813< +fn __action815< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, TextSize, TextSize), ) -> ast::Pattern { @@ -45870,7 +46043,7 @@ fn __action813< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action814< +fn __action816< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), @@ -45895,7 +46068,7 @@ fn __action814< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action815< +fn __action817< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45920,7 +46093,7 @@ fn __action815< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action816< +fn __action818< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45945,7 +46118,7 @@ fn __action816< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action817< +fn __action819< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -45970,7 +46143,7 @@ fn __action817< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action818< +fn __action820< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), @@ -45993,7 +46166,7 @@ fn __action818< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action819< +fn __action821< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46020,7 +46193,7 @@ fn __action819< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action820< +fn __action822< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46051,7 +46224,7 @@ fn __action820< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action821< +fn __action823< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46080,7 +46253,7 @@ fn __action821< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action822< +fn __action824< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46113,7 +46286,7 @@ fn __action822< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action823< +fn __action825< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46144,7 +46317,7 @@ fn __action823< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action824< +fn __action826< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46181,7 +46354,7 @@ fn __action824< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action825< +fn __action827< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46216,7 +46389,7 @@ fn __action825< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action826< +fn __action828< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46247,7 +46420,7 @@ fn __action826< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action827< +fn __action829< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -46276,7 +46449,7 @@ fn __action827< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action828< +fn __action830< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -46301,7 +46474,7 @@ fn __action828< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action829< +fn __action831< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -46330,7 +46503,7 @@ fn __action829< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action830< +fn __action832< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -46359,11 +46532,11 @@ fn __action830< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action831< +fn __action833< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -46394,11 +46567,11 @@ fn __action831< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action832< +fn __action834< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -46431,11 +46604,11 @@ fn __action832< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action833< +fn __action835< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -46468,11 +46641,11 @@ fn __action833< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action834< +fn __action836< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -46503,14 +46676,14 @@ fn __action834< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action835< +fn __action837< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -46532,12 +46705,12 @@ fn __action835< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action836< +fn __action838< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -46557,7 +46730,7 @@ fn __action836< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action837< +fn __action839< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -46584,13 +46757,13 @@ fn __action837< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action838< +fn __action840< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -46611,13 +46784,13 @@ fn __action838< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action839< +fn __action841< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -46638,7 +46811,7 @@ fn __action839< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action840< +fn __action842< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -46663,13 +46836,13 @@ fn __action840< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action841< +fn __action843< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -46690,13 +46863,13 @@ fn __action841< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action842< +fn __action844< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -46717,7 +46890,7 @@ fn __action842< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action843< +fn __action845< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -46746,7 +46919,7 @@ fn __action843< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action844< +fn __action846< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -46773,7 +46946,7 @@ fn __action844< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action845< +fn __action847< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -46804,7 +46977,7 @@ fn __action845< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action846< +fn __action848< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -46833,7 +47006,7 @@ fn __action846< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action847< +fn __action849< >( mode: Mode, __0: (TextSize, (Option>, Vec, Option>), TextSize), @@ -46860,7 +47033,7 @@ fn __action847< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action848< +fn __action850< >( mode: Mode, __0: (TextSize, (Option>, Vec, Option>), TextSize), @@ -46885,7 +47058,7 @@ fn __action848< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action849< +fn __action851< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -46912,7 +47085,7 @@ fn __action849< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action850< +fn __action852< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -46937,7 +47110,7 @@ fn __action850< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action851< +fn __action853< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -46966,7 +47139,7 @@ fn __action851< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action852< +fn __action854< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -46993,7 +47166,7 @@ fn __action852< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action853< +fn __action855< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -47024,7 +47197,7 @@ fn __action853< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action854< +fn __action856< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -47053,7 +47226,7 @@ fn __action854< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action855< +fn __action857< >( mode: Mode, __0: (TextSize, (Option>, Vec, Option>), TextSize), @@ -47080,7 +47253,7 @@ fn __action855< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action856< +fn __action858< >( mode: Mode, __0: (TextSize, (Option>, Vec, Option>), TextSize), @@ -47105,7 +47278,7 @@ fn __action856< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action857< +fn __action859< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -47132,7 +47305,7 @@ fn __action857< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action858< +fn __action860< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -47157,7 +47330,7 @@ fn __action858< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action859< +fn __action861< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47186,7 +47359,7 @@ fn __action859< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action860< +fn __action862< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47213,7 +47386,7 @@ fn __action860< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action861< +fn __action863< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47244,7 +47417,7 @@ fn __action861< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action862< +fn __action864< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47273,7 +47446,7 @@ fn __action862< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action863< +fn __action865< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47298,7 +47471,7 @@ fn __action863< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action864< +fn __action866< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47321,7 +47494,7 @@ fn __action864< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action865< +fn __action867< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47348,7 +47521,7 @@ fn __action865< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action866< +fn __action868< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47373,7 +47546,7 @@ fn __action866< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action867< +fn __action869< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47402,7 +47575,7 @@ fn __action867< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action868< +fn __action870< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47433,7 +47606,7 @@ fn __action868< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action869< +fn __action871< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47458,7 +47631,7 @@ fn __action869< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action870< +fn __action872< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47485,7 +47658,7 @@ fn __action870< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action871< +fn __action873< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47514,7 +47687,7 @@ fn __action871< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action872< +fn __action874< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47539,7 +47712,7 @@ fn __action872< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action873< +fn __action875< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47574,7 +47747,7 @@ fn __action873< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action874< +fn __action876< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47607,7 +47780,7 @@ fn __action874< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action875< +fn __action877< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47638,7 +47811,7 @@ fn __action875< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action876< +fn __action878< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47667,7 +47840,7 @@ fn __action876< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action877< +fn __action879< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47698,7 +47871,7 @@ fn __action877< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action878< +fn __action880< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47727,7 +47900,7 @@ fn __action878< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action879< +fn __action881< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47754,7 +47927,7 @@ fn __action879< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action880< +fn __action882< >( mode: Mode, __0: (TextSize, ast::Pattern, TextSize), @@ -47781,7 +47954,7 @@ fn __action880< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action881< +fn __action883< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -47808,7 +47981,7 @@ fn __action881< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action882< +fn __action884< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -47833,14 +48006,14 @@ fn __action882< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action883< +fn __action885< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -47862,14 +48035,14 @@ fn __action883< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action884< +fn __action886< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -47891,7 +48064,7 @@ fn __action884< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action885< +fn __action887< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47916,12 +48089,12 @@ fn __action885< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action886< +fn __action888< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, core::option::Option, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, core::option::Option, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -47945,7 +48118,7 @@ fn __action886< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action887< +fn __action889< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -47974,7 +48147,7 @@ fn __action887< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action888< +fn __action890< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48001,7 +48174,7 @@ fn __action888< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action889< +fn __action891< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48032,7 +48205,7 @@ fn __action889< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action890< +fn __action892< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48065,7 +48238,7 @@ fn __action890< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action891< +fn __action893< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48096,7 +48269,7 @@ fn __action891< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action892< +fn __action894< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48125,14 +48298,14 @@ fn __action892< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action893< +fn __action895< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48154,14 +48327,14 @@ fn __action893< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action894< +fn __action896< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48183,15 +48356,15 @@ fn __action894< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action895< +fn __action897< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), __6: (TextSize, TextSize, TextSize), ) -> ast::Comprehension { @@ -48218,14 +48391,14 @@ fn __action895< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action896< +fn __action898< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, TextSize, TextSize), ) -> ast::Comprehension { @@ -48251,12 +48424,12 @@ fn __action896< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action897< +fn __action899< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), -) -> Option + __1: (TextSize, core::option::Option, TextSize), +) -> Option { let __start0 = __0.0; let __end0 = __0.0; @@ -48276,13 +48449,13 @@ fn __action897< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action898< +fn __action900< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48303,7 +48476,7 @@ fn __action898< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action899< +fn __action901< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48330,11 +48503,11 @@ fn __action899< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action900< +fn __action902< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Parameter { @@ -48357,7 +48530,7 @@ fn __action900< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action901< +fn __action903< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -48382,15 +48555,15 @@ fn __action901< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action902< +fn __action904< >( mode: Mode, - __0: (TextSize, core::option::Option, TextSize), + __0: (TextSize, core::option::Option, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option, TextSize), - __3: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, core::option::Option, TextSize), + __3: (TextSize, core::option::Option>, TextSize), __4: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48413,38 +48586,13 @@ fn __action902< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action903< +fn __action905< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> ast::Expr -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action393( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action206( - mode, - __temp0, - __0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action904< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48465,13 +48613,13 @@ fn __action904< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action905< +fn __action906< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48492,12 +48640,12 @@ fn __action905< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action906< +fn __action907< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48517,14 +48665,14 @@ fn __action906< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action907< +fn __action908< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48546,14 +48694,14 @@ fn __action907< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action908< +fn __action909< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48575,16 +48723,16 @@ fn __action908< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action909< +fn __action910< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48608,16 +48756,16 @@ fn __action909< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action910< +fn __action911< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -48641,7 +48789,7 @@ fn __action910< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action911< +fn __action912< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48668,11 +48816,11 @@ fn __action911< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action912< +fn __action913< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Mod @@ -48697,7 +48845,7 @@ fn __action912< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action913< +fn __action914< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48732,7 +48880,7 @@ fn __action913< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action914< +fn __action915< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48767,7 +48915,7 @@ fn __action914< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action915< +fn __action916< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48796,7 +48944,7 @@ fn __action915< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action916< +fn __action917< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -48821,14 +48969,14 @@ fn __action916< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action917< +fn __action918< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Expr, TextSize), __2: (TextSize, core::option::Option, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -48854,11 +49002,11 @@ fn __action917< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action918< +fn __action919< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::TypeParam { @@ -48879,33 +49027,6 @@ fn __action918< ) } -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action919< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Identifier, TextSize), - __2: (TextSize, TextSize, TextSize), -) -> ast::TypeParam -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action393( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action174( - mode, - __temp0, - __0, - __1, - __2, - ) -} - #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action920< @@ -48924,7 +49045,7 @@ fn __action920< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action175( + __action174( mode, __temp0, __0, @@ -48936,6 +49057,33 @@ fn __action920< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action921< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::Identifier, TextSize), + __2: (TextSize, TextSize, TextSize), +) -> ast::TypeParam +{ + let __start0 = __0.0; + let __end0 = __0.0; + let __temp0 = __action393( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action175( + mode, + __temp0, + __0, + __1, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action922< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48966,7 +49114,7 @@ fn __action921< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action922< +fn __action923< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -48995,11 +49143,11 @@ fn __action922< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action923< +fn __action924< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::ParameterWithDefault { @@ -49022,7 +49170,7 @@ fn __action923< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action924< +fn __action925< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -49047,7 +49195,7 @@ fn __action924< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action925< +fn __action926< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -49072,11 +49220,11 @@ fn __action925< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action926< +fn __action927< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), __4: (TextSize, core::option::Option, TextSize), @@ -49101,64 +49249,14 @@ fn __action926< ) } -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action927< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> ast::WithItem -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action393( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action297( - mode, - __temp0, - __0, - __1, - ) -} - #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action928< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> ast::WithItem -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action393( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action292( - mode, - __temp0, - __0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action929< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::WithItem { @@ -49182,32 +49280,7 @@ fn __action929< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action930< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action393( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action160( - mode, - __temp0, - __0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action931< +fn __action929< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49238,7 +49311,7 @@ fn __action931< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action932< +fn __action930< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49267,14 +49340,14 @@ fn __action932< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action933< +fn __action931< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -49296,14 +49369,14 @@ fn __action933< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action934< +fn __action932< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -49325,13 +49398,13 @@ fn __action934< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action935< +fn __action933< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), + __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -49352,14 +49425,14 @@ fn __action935< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action936< +fn __action934< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -49381,7 +49454,7 @@ fn __action936< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action937< +fn __action935< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49393,7 +49466,7 @@ fn __action937< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action859( + let __temp0 = __action861( mode, __1, __2, @@ -49410,7 +49483,7 @@ fn __action937< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action938< +fn __action936< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49421,7 +49494,7 @@ fn __action938< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action860( + let __temp0 = __action862( mode, __1, __2, @@ -49435,6 +49508,66 @@ fn __action938< )) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action937< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), +) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> +{ + let __start0 = __1.0; + let __end0 = __5.2; + let __temp0 = __action863( + mode, + __1, + __2, + __3, + __4, + __5, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action420( + mode, + __0, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action938< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, Option>, TextSize), +) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> +{ + let __start0 = __1.0; + let __end0 = __4.2; + let __temp0 = __action864( + mode, + __1, + __2, + __3, + __4, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action420( + mode, + __0, + __temp0, + )) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action939< @@ -49443,20 +49576,14 @@ fn __action939< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __5.2; - let __temp0 = __action861( + let __end0 = __2.2; + let __temp0 = __action865( mode, __1, __2, - __3, - __4, - __5, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action420( @@ -49473,19 +49600,13 @@ fn __action940< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, Option>, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __4.2; - let __temp0 = __action862( + let __end0 = __1.2; + let __temp0 = __action866( mode, __1, - __2, - __3, - __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action420( @@ -49503,14 +49624,16 @@ fn __action941< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action863( + let __end0 = __3.2; + let __temp0 = __action867( mode, __1, __2, + __3, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action420( @@ -49527,13 +49650,15 @@ fn __action942< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action864( + let __end0 = __2.2; + let __temp0 = __action868( mode, __1, + __2, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action420( @@ -49546,58 +49671,6 @@ fn __action942< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action943< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), -) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> -{ - let __start0 = __1.0; - let __end0 = __3.2; - let __temp0 = __action865( - mode, - __1, - __2, - __3, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action420( - mode, - __0, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action944< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), -) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action866( - mode, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action420( - mode, - __0, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action945< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49610,7 +49683,7 @@ fn __action945< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action859( + let __temp0 = __action861( mode, __0, __1, @@ -49618,7 +49691,7 @@ fn __action945< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __4, @@ -49628,7 +49701,7 @@ fn __action945< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action946< +fn __action944< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49640,14 +49713,14 @@ fn __action946< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action860( + let __temp0 = __action862( mode, __0, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __3, @@ -49657,7 +49730,7 @@ fn __action946< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action947< +fn __action945< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49671,7 +49744,7 @@ fn __action947< { let __start0 = __0.0; let __end0 = __4.2; - let __temp0 = __action861( + let __temp0 = __action863( mode, __0, __1, @@ -49680,7 +49753,7 @@ fn __action947< __4, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __5, @@ -49690,7 +49763,7 @@ fn __action947< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action948< +fn __action946< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49703,7 +49776,7 @@ fn __action948< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action862( + let __temp0 = __action864( mode, __0, __1, @@ -49711,7 +49784,7 @@ fn __action948< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __4, @@ -49721,7 +49794,7 @@ fn __action948< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action949< +fn __action947< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49732,13 +49805,13 @@ fn __action949< { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action863( + let __temp0 = __action865( mode, __0, __1, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __2, @@ -49748,7 +49821,7 @@ fn __action949< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action950< +fn __action948< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49758,12 +49831,12 @@ fn __action950< { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action864( + let __temp0 = __action866( mode, __0, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __1, @@ -49773,7 +49846,7 @@ fn __action950< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action951< +fn __action949< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49785,14 +49858,14 @@ fn __action951< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action865( + let __temp0 = __action867( mode, __0, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __3, @@ -49802,7 +49875,7 @@ fn __action951< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action952< +fn __action950< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49813,13 +49886,13 @@ fn __action952< { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action866( + let __temp0 = __action868( mode, __0, __1, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action847( + Ok(__action849( mode, __temp0, __2, @@ -49829,7 +49902,7 @@ fn __action952< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action953< +fn __action951< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49841,7 +49914,7 @@ fn __action953< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action859( + let __temp0 = __action861( mode, __0, __1, @@ -49849,7 +49922,7 @@ fn __action953< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( + Ok(__action850( mode, __temp0, __4, @@ -49858,7 +49931,7 @@ fn __action953< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action954< +fn __action952< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49869,14 +49942,14 @@ fn __action954< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action860( + let __temp0 = __action862( mode, __0, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( + Ok(__action850( mode, __temp0, __3, @@ -49885,7 +49958,7 @@ fn __action954< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action955< +fn __action953< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49898,7 +49971,7 @@ fn __action955< { let __start0 = __0.0; let __end0 = __4.2; - let __temp0 = __action861( + let __temp0 = __action863( mode, __0, __1, @@ -49907,7 +49980,7 @@ fn __action955< __4, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( + Ok(__action850( mode, __temp0, __5, @@ -49916,7 +49989,7 @@ fn __action955< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action956< +fn __action954< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -49928,7 +50001,7 @@ fn __action956< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action862( + let __temp0 = __action864( mode, __0, __1, @@ -49936,13 +50009,61 @@ fn __action956< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( + Ok(__action850( mode, __temp0, __4, )) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action955< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::Parameter, TextSize), + __2: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __1.2; + let __temp0 = __action865( + mode, + __0, + __1, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action850( + mode, + __temp0, + __2, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action956< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action866( + mode, + __0, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action850( + mode, + __temp0, + __1, + )) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action957< @@ -49950,77 +50071,29 @@ fn __action957< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Parameter, TextSize), - __2: (TextSize, TextSize, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, TextSize, TextSize), ) -> Result> { let __start0 = __0.0; - let __end0 = __1.2; - let __temp0 = __action863( + let __end0 = __2.2; + let __temp0 = __action867( mode, __0, __1, + __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( + Ok(__action850( mode, __temp0, - __2, + __3, )) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action958< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action864( - mode, - __0, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( - mode, - __temp0, - __1, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action959< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Parameter, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action865( - mode, - __0, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( - mode, - __temp0, - __3, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action960< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50030,13 +50103,13 @@ fn __action960< { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action866( + let __temp0 = __action868( mode, __0, __1, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action848( + Ok(__action850( mode, __temp0, __2, @@ -50045,7 +50118,7 @@ fn __action960< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action961< +fn __action959< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50057,7 +50130,7 @@ fn __action961< { let __start0 = __0.0; let __end0 = __4.2; - let __temp0 = __action937( + let __temp0 = __action935( mode, __0, __1, @@ -50074,7 +50147,7 @@ fn __action961< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action962< +fn __action960< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50085,12 +50158,72 @@ fn __action962< { let __start0 = __0.0; let __end0 = __3.2; + let __temp0 = __action936( + mode, + __0, + __1, + __2, + __3, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action418( + mode, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action961< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), +) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> +{ + let __start0 = __0.0; + let __end0 = __5.2; + let __temp0 = __action937( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action418( + mode, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action962< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, Option>, TextSize), +) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> +{ + let __start0 = __0.0; + let __end0 = __4.2; let __temp0 = __action938( mode, __0, __1, __2, __3, + __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action418( @@ -50107,21 +50240,15 @@ fn __action963< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __5.2; + let __end0 = __2.2; let __temp0 = __action939( mode, __0, __1, __2, - __3, - __4, - __5, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action418( @@ -50137,20 +50264,14 @@ fn __action964< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, Option>, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __4.2; + let __end0 = __1.2; let __temp0 = __action940( mode, __0, __1, - __2, - __3, - __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action418( @@ -50167,15 +50288,17 @@ fn __action965< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __2.2; + let __end0 = __3.2; let __temp0 = __action941( mode, __0, __1, __2, + __3, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action418( @@ -50191,14 +50314,16 @@ fn __action966< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __1.2; + let __end0 = __2.2; let __temp0 = __action942( mode, __0, __1, + __2, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action418( @@ -50210,58 +50335,6 @@ fn __action966< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action967< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), -) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action943( - mode, - __0, - __1, - __2, - __3, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action418( - mode, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action968< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), -) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action944( - mode, - __0, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action418( - mode, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action969< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50276,7 +50349,7 @@ fn __action969< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action961( + let __temp0 = __action959( mode, __1, __2, @@ -50285,7 +50358,7 @@ fn __action969< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50296,7 +50369,7 @@ fn __action969< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action970< +fn __action968< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50310,7 +50383,7 @@ fn __action970< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action962( + let __temp0 = __action960( mode, __1, __2, @@ -50318,7 +50391,7 @@ fn __action970< __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50329,7 +50402,7 @@ fn __action970< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action971< +fn __action969< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50345,7 +50418,7 @@ fn __action971< { let __start0 = __1.0; let __end0 = __6.2; - let __temp0 = __action963( + let __temp0 = __action961( mode, __1, __2, @@ -50355,7 +50428,7 @@ fn __action971< __6, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50366,7 +50439,7 @@ fn __action971< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action972< +fn __action970< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50381,7 +50454,7 @@ fn __action972< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action964( + let __temp0 = __action962( mode, __1, __2, @@ -50390,7 +50463,7 @@ fn __action972< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50401,7 +50474,7 @@ fn __action972< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action973< +fn __action971< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50414,14 +50487,14 @@ fn __action973< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action965( + let __temp0 = __action963( mode, __1, __2, __3, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50432,7 +50505,7 @@ fn __action973< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action974< +fn __action972< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50444,13 +50517,13 @@ fn __action974< { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action966( + let __temp0 = __action964( mode, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50461,7 +50534,7 @@ fn __action974< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action975< +fn __action973< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50475,7 +50548,7 @@ fn __action975< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action967( + let __temp0 = __action965( mode, __1, __2, @@ -50483,7 +50556,7 @@ fn __action975< __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50494,7 +50567,7 @@ fn __action975< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action976< +fn __action974< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50507,14 +50580,14 @@ fn __action976< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action968( + let __temp0 = __action966( mode, __1, __2, __3, )?; let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50525,7 +50598,7 @@ fn __action976< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action977< +fn __action975< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50541,7 +50614,7 @@ fn __action977< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action843( + __action845( mode, __0, __temp0, @@ -50552,7 +50625,7 @@ fn __action977< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action978< +fn __action976< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50566,7 +50639,7 @@ fn __action978< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action961( + let __temp0 = __action959( mode, __1, __2, @@ -50575,7 +50648,7 @@ fn __action978< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, @@ -50585,7 +50658,7 @@ fn __action978< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action979< +fn __action977< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50598,7 +50671,7 @@ fn __action979< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action962( + let __temp0 = __action960( mode, __1, __2, @@ -50606,7 +50679,7 @@ fn __action979< __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, @@ -50616,7 +50689,7 @@ fn __action979< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action980< +fn __action978< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50631,7 +50704,7 @@ fn __action980< { let __start0 = __1.0; let __end0 = __6.2; - let __temp0 = __action963( + let __temp0 = __action961( mode, __1, __2, @@ -50641,7 +50714,7 @@ fn __action980< __6, )?; let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, @@ -50651,7 +50724,7 @@ fn __action980< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action981< +fn __action979< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50665,7 +50738,7 @@ fn __action981< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action964( + let __temp0 = __action962( mode, __1, __2, @@ -50674,7 +50747,7 @@ fn __action981< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, @@ -50682,6 +50755,62 @@ fn __action981< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action980< +>( + mode: Mode, + __0: (TextSize, (Vec, Vec), TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::Parameter, TextSize), + __4: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __3.2; + let __temp0 = __action963( + mode, + __1, + __2, + __3, + )?; + let __temp0 = (__start0, __temp0, __end0); + __action846( + mode, + __0, + __temp0, + __4, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action981< +>( + mode: Mode, + __0: (TextSize, (Vec, Vec), TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action964( + mode, + __1, + __2, + )?; + let __temp0 = (__start0, __temp0, __end0); + __action846( + mode, + __0, + __temp0, + __3, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action982< @@ -50691,87 +50820,31 @@ fn __action982< __1: (TextSize, token::Tok, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Parameter, TextSize), - __4: (TextSize, TextSize, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, TextSize, TextSize), ) -> Result> { let __start0 = __1.0; - let __end0 = __3.2; + let __end0 = __4.2; let __temp0 = __action965( mode, __1, __2, __3, + __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, - __4, + __5, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action983< ->( - mode: Mode, - __0: (TextSize, (Vec, Vec), TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action966( - mode, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - __action844( - mode, - __0, - __temp0, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action984< ->( - mode: Mode, - __0: (TextSize, (Vec, Vec), TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Parameter, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __4.2; - let __temp0 = __action967( - mode, - __1, - __2, - __3, - __4, - )?; - let __temp0 = (__start0, __temp0, __end0); - __action844( - mode, - __0, - __temp0, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action985< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50783,14 +50856,14 @@ fn __action985< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action968( + let __temp0 = __action966( mode, __1, __2, __3, )?; let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, @@ -50800,7 +50873,7 @@ fn __action985< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action986< +fn __action984< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -50815,7 +50888,7 @@ fn __action986< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action844( + __action846( mode, __0, __temp0, @@ -50825,7 +50898,7 @@ fn __action986< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action987< +fn __action985< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50848,7 +50921,7 @@ fn __action987< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action988< +fn __action986< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50871,7 +50944,7 @@ fn __action988< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action989< +fn __action987< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50887,7 +50960,7 @@ fn __action989< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action867( + __action869( mode, __0, __temp0, @@ -50898,7 +50971,7 @@ fn __action989< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action990< +fn __action988< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50914,7 +50987,7 @@ fn __action990< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action867( + __action869( mode, __0, __temp0, @@ -50925,7 +50998,7 @@ fn __action990< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action991< +fn __action989< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50942,7 +51015,7 @@ fn __action991< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action868( + __action870( mode, __0, __temp0, @@ -50954,7 +51027,7 @@ fn __action991< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action992< +fn __action990< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50971,7 +51044,7 @@ fn __action992< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action868( + __action870( mode, __0, __temp0, @@ -50983,7 +51056,7 @@ fn __action992< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action993< +fn __action991< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -50997,7 +51070,7 @@ fn __action993< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action869( + __action871( mode, __0, __temp0, @@ -51006,7 +51079,7 @@ fn __action993< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action994< +fn __action992< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51020,7 +51093,7 @@ fn __action994< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action869( + __action871( mode, __0, __temp0, @@ -51029,7 +51102,7 @@ fn __action994< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action995< +fn __action993< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51044,7 +51117,7 @@ fn __action995< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action870( + __action872( mode, __0, __temp0, @@ -51054,7 +51127,7 @@ fn __action995< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action996< +fn __action994< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51069,7 +51142,7 @@ fn __action996< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action870( + __action872( mode, __0, __temp0, @@ -51079,7 +51152,7 @@ fn __action996< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action997< +fn __action995< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51091,7 +51164,7 @@ fn __action997< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action989( + let __temp0 = __action987( mode, __1, __2, @@ -51108,7 +51181,7 @@ fn __action997< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action998< +fn __action996< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51119,11 +51192,71 @@ fn __action998< { let __start0 = __1.0; let __end0 = __3.2; + let __temp0 = __action988( + mode, + __1, + __2, + __3, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action428( + mode, + __0, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action997< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), +) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> +{ + let __start0 = __1.0; + let __end0 = __5.2; + let __temp0 = __action989( + mode, + __1, + __2, + __3, + __4, + __5, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action428( + mode, + __0, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action998< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, Option>, TextSize), +) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> +{ + let __start0 = __1.0; + let __end0 = __4.2; let __temp0 = __action990( mode, __1, __2, __3, + __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action428( @@ -51141,20 +51274,14 @@ fn __action999< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __5.2; + let __end0 = __2.2; let __temp0 = __action991( mode, __1, __2, - __3, - __4, - __5, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action428( @@ -51171,19 +51298,13 @@ fn __action1000< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, Option>, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __4.2; + let __end0 = __1.2; let __temp0 = __action992( mode, __1, - __2, - __3, - __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action428( @@ -51201,14 +51322,16 @@ fn __action1001< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __2.2; + let __end0 = __3.2; let __temp0 = __action993( mode, __1, __2, + __3, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action428( @@ -51225,13 +51348,15 @@ fn __action1002< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), ) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> { let __start0 = __1.0; - let __end0 = __1.2; + let __end0 = __2.2; let __temp0 = __action994( mode, __1, + __2, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action428( @@ -51244,58 +51369,6 @@ fn __action1002< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1003< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), -) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> -{ - let __start0 = __1.0; - let __end0 = __3.2; - let __temp0 = __action995( - mode, - __1, - __2, - __3, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action428( - mode, - __0, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1004< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), -) -> Result<(Option>, Vec, Option>),__lalrpop_util::ParseError> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action996( - mode, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action428( - mode, - __0, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1005< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51308,7 +51381,7 @@ fn __action1005< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action989( + let __temp0 = __action987( mode, __0, __1, @@ -51316,7 +51389,7 @@ fn __action1005< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __4, @@ -51326,7 +51399,7 @@ fn __action1005< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1006< +fn __action1004< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51338,14 +51411,14 @@ fn __action1006< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action990( + let __temp0 = __action988( mode, __0, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __3, @@ -51355,7 +51428,7 @@ fn __action1006< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1007< +fn __action1005< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51369,7 +51442,7 @@ fn __action1007< { let __start0 = __0.0; let __end0 = __4.2; - let __temp0 = __action991( + let __temp0 = __action989( mode, __0, __1, @@ -51378,7 +51451,7 @@ fn __action1007< __4, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __5, @@ -51388,7 +51461,7 @@ fn __action1007< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1008< +fn __action1006< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51401,7 +51474,7 @@ fn __action1008< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action992( + let __temp0 = __action990( mode, __0, __1, @@ -51409,7 +51482,7 @@ fn __action1008< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __4, @@ -51419,7 +51492,7 @@ fn __action1008< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1009< +fn __action1007< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51430,13 +51503,13 @@ fn __action1009< { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action993( + let __temp0 = __action991( mode, __0, __1, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __2, @@ -51446,7 +51519,7 @@ fn __action1009< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1010< +fn __action1008< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51456,12 +51529,12 @@ fn __action1010< { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action994( + let __temp0 = __action992( mode, __0, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __1, @@ -51471,7 +51544,7 @@ fn __action1010< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1011< +fn __action1009< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51483,14 +51556,14 @@ fn __action1011< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action995( + let __temp0 = __action993( mode, __0, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __3, @@ -51500,7 +51573,7 @@ fn __action1011< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1012< +fn __action1010< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51511,13 +51584,13 @@ fn __action1012< { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action996( + let __temp0 = __action994( mode, __0, __1, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action855( + Ok(__action857( mode, __temp0, __2, @@ -51527,7 +51600,7 @@ fn __action1012< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1013< +fn __action1011< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51539,7 +51612,7 @@ fn __action1013< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action989( + let __temp0 = __action987( mode, __0, __1, @@ -51547,7 +51620,7 @@ fn __action1013< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( + Ok(__action858( mode, __temp0, __4, @@ -51556,7 +51629,7 @@ fn __action1013< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1014< +fn __action1012< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51567,14 +51640,14 @@ fn __action1014< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action990( + let __temp0 = __action988( mode, __0, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( + Ok(__action858( mode, __temp0, __3, @@ -51583,7 +51656,7 @@ fn __action1014< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1015< +fn __action1013< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51596,7 +51669,7 @@ fn __action1015< { let __start0 = __0.0; let __end0 = __4.2; - let __temp0 = __action991( + let __temp0 = __action989( mode, __0, __1, @@ -51605,7 +51678,7 @@ fn __action1015< __4, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( + Ok(__action858( mode, __temp0, __5, @@ -51614,7 +51687,7 @@ fn __action1015< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1016< +fn __action1014< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51626,7 +51699,7 @@ fn __action1016< { let __start0 = __0.0; let __end0 = __3.2; - let __temp0 = __action992( + let __temp0 = __action990( mode, __0, __1, @@ -51634,13 +51707,61 @@ fn __action1016< __3, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( + Ok(__action858( mode, __temp0, __4, )) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1015< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::Parameter, TextSize), + __2: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __1.2; + let __temp0 = __action991( + mode, + __0, + __1, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action858( + mode, + __temp0, + __2, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1016< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action992( + mode, + __0, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action858( + mode, + __temp0, + __1, + )) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1017< @@ -51648,77 +51769,29 @@ fn __action1017< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Parameter, TextSize), - __2: (TextSize, TextSize, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, TextSize, TextSize), ) -> Result> { let __start0 = __0.0; - let __end0 = __1.2; + let __end0 = __2.2; let __temp0 = __action993( mode, __0, __1, + __2, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( + Ok(__action858( mode, __temp0, - __2, + __3, )) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1018< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action994( - mode, - __0, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( - mode, - __temp0, - __1, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1019< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Parameter, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action995( - mode, - __0, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( - mode, - __temp0, - __3, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1020< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51728,13 +51801,13 @@ fn __action1020< { let __start0 = __0.0; let __end0 = __1.2; - let __temp0 = __action996( + let __temp0 = __action994( mode, __0, __1, )?; let __temp0 = (__start0, __temp0, __end0); - Ok(__action856( + Ok(__action858( mode, __temp0, __2, @@ -51743,7 +51816,7 @@ fn __action1020< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1021< +fn __action1019< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51755,7 +51828,7 @@ fn __action1021< { let __start0 = __0.0; let __end0 = __4.2; - let __temp0 = __action997( + let __temp0 = __action995( mode, __0, __1, @@ -51772,7 +51845,7 @@ fn __action1021< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1022< +fn __action1020< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -51783,12 +51856,72 @@ fn __action1022< { let __start0 = __0.0; let __end0 = __3.2; + let __temp0 = __action996( + mode, + __0, + __1, + __2, + __3, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action426( + mode, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1021< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), +) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> +{ + let __start0 = __0.0; + let __end0 = __5.2; + let __temp0 = __action997( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + )?; + let __temp0 = (__start0, __temp0, __end0); + Ok(__action426( + mode, + __temp0, + )) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1022< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, Option>, TextSize), +) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> +{ + let __start0 = __0.0; + let __end0 = __4.2; let __temp0 = __action998( mode, __0, __1, __2, __3, + __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action426( @@ -51805,21 +51938,15 @@ fn __action1023< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __5.2; + let __end0 = __2.2; let __temp0 = __action999( mode, __0, __1, __2, - __3, - __4, - __5, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action426( @@ -51835,20 +51962,14 @@ fn __action1024< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, Option>, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __4.2; + let __end0 = __1.2; let __temp0 = __action1000( mode, __0, __1, - __2, - __3, - __4, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action426( @@ -51865,15 +51986,17 @@ fn __action1025< __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Parameter, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __2.2; + let __end0 = __3.2; let __temp0 = __action1001( mode, __0, __1, __2, + __3, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action426( @@ -51889,14 +52012,16 @@ fn __action1026< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), ) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> { let __start0 = __0.0; - let __end0 = __1.2; + let __end0 = __2.2; let __temp0 = __action1002( mode, __0, __1, + __2, )?; let __temp0 = (__start0, __temp0, __end0); Ok(__action426( @@ -51908,58 +52033,6 @@ fn __action1026< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1027< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Parameter, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), -) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action1003( - mode, - __0, - __1, - __2, - __3, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action426( - mode, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1028< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), -) -> Result>, Vec, Option>)>,__lalrpop_util::ParseError> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action1004( - mode, - __0, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - Ok(__action426( - mode, - __temp0, - )) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1029< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -51974,7 +52047,7 @@ fn __action1029< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action1021( + let __temp0 = __action1019( mode, __1, __2, @@ -51983,7 +52056,7 @@ fn __action1029< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -51994,7 +52067,7 @@ fn __action1029< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1030< +fn __action1028< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52008,7 +52081,7 @@ fn __action1030< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action1022( + let __temp0 = __action1020( mode, __1, __2, @@ -52016,7 +52089,7 @@ fn __action1030< __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52027,7 +52100,7 @@ fn __action1030< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1031< +fn __action1029< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52043,7 +52116,7 @@ fn __action1031< { let __start0 = __1.0; let __end0 = __6.2; - let __temp0 = __action1023( + let __temp0 = __action1021( mode, __1, __2, @@ -52053,7 +52126,7 @@ fn __action1031< __6, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52064,7 +52137,7 @@ fn __action1031< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1032< +fn __action1030< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52079,7 +52152,7 @@ fn __action1032< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action1024( + let __temp0 = __action1022( mode, __1, __2, @@ -52088,7 +52161,7 @@ fn __action1032< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52099,7 +52172,7 @@ fn __action1032< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1033< +fn __action1031< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52112,14 +52185,14 @@ fn __action1033< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action1025( + let __temp0 = __action1023( mode, __1, __2, __3, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52130,7 +52203,7 @@ fn __action1033< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1034< +fn __action1032< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52142,13 +52215,13 @@ fn __action1034< { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1026( + let __temp0 = __action1024( mode, __1, __2, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52159,7 +52232,7 @@ fn __action1034< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1035< +fn __action1033< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52173,7 +52246,7 @@ fn __action1035< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action1027( + let __temp0 = __action1025( mode, __1, __2, @@ -52181,7 +52254,7 @@ fn __action1035< __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52192,7 +52265,7 @@ fn __action1035< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1036< +fn __action1034< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52205,14 +52278,14 @@ fn __action1036< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action1028( + let __temp0 = __action1026( mode, __1, __2, __3, )?; let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52223,7 +52296,7 @@ fn __action1036< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1037< +fn __action1035< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52239,7 +52312,7 @@ fn __action1037< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action851( + __action853( mode, __0, __temp0, @@ -52250,7 +52323,7 @@ fn __action1037< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1038< +fn __action1036< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52264,7 +52337,7 @@ fn __action1038< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action1021( + let __temp0 = __action1019( mode, __1, __2, @@ -52273,7 +52346,7 @@ fn __action1038< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, @@ -52283,7 +52356,7 @@ fn __action1038< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1039< +fn __action1037< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52296,7 +52369,7 @@ fn __action1039< { let __start0 = __1.0; let __end0 = __4.2; - let __temp0 = __action1022( + let __temp0 = __action1020( mode, __1, __2, @@ -52304,7 +52377,7 @@ fn __action1039< __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, @@ -52314,7 +52387,7 @@ fn __action1039< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1040< +fn __action1038< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52329,7 +52402,7 @@ fn __action1040< { let __start0 = __1.0; let __end0 = __6.2; - let __temp0 = __action1023( + let __temp0 = __action1021( mode, __1, __2, @@ -52339,7 +52412,7 @@ fn __action1040< __6, )?; let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, @@ -52349,7 +52422,7 @@ fn __action1040< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1041< +fn __action1039< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52363,7 +52436,7 @@ fn __action1041< { let __start0 = __1.0; let __end0 = __5.2; - let __temp0 = __action1024( + let __temp0 = __action1022( mode, __1, __2, @@ -52372,7 +52445,7 @@ fn __action1041< __5, )?; let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, @@ -52380,6 +52453,62 @@ fn __action1041< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1040< +>( + mode: Mode, + __0: (TextSize, (Vec, Vec), TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::Parameter, TextSize), + __4: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __3.2; + let __temp0 = __action1023( + mode, + __1, + __2, + __3, + )?; + let __temp0 = (__start0, __temp0, __end0); + __action854( + mode, + __0, + __temp0, + __4, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1041< +>( + mode: Mode, + __0: (TextSize, (Vec, Vec), TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1024( + mode, + __1, + __2, + )?; + let __temp0 = (__start0, __temp0, __end0); + __action854( + mode, + __0, + __temp0, + __3, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1042< @@ -52389,87 +52518,31 @@ fn __action1042< __1: (TextSize, token::Tok, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Parameter, TextSize), - __4: (TextSize, TextSize, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, TextSize, TextSize), ) -> Result> { let __start0 = __1.0; - let __end0 = __3.2; + let __end0 = __4.2; let __temp0 = __action1025( mode, __1, __2, __3, + __4, )?; let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, - __4, + __5, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1043< ->( - mode: Mode, - __0: (TextSize, (Vec, Vec), TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1026( - mode, - __1, - __2, - )?; - let __temp0 = (__start0, __temp0, __end0); - __action852( - mode, - __0, - __temp0, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1044< ->( - mode: Mode, - __0: (TextSize, (Vec, Vec), TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Parameter, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __4.2; - let __temp0 = __action1027( - mode, - __1, - __2, - __3, - __4, - )?; - let __temp0 = (__start0, __temp0, __end0); - __action852( - mode, - __0, - __temp0, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1045< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52481,14 +52554,14 @@ fn __action1045< { let __start0 = __1.0; let __end0 = __3.2; - let __temp0 = __action1028( + let __temp0 = __action1026( mode, __1, __2, __3, )?; let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, @@ -52498,7 +52571,7 @@ fn __action1045< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1046< +fn __action1044< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -52513,7 +52586,7 @@ fn __action1046< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action852( + __action854( mode, __0, __temp0, @@ -52523,12 +52596,12 @@ fn __action1046< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1047< +fn __action1045< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> core::option::Option + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { let __start0 = __0.0; let __end0 = __1.2; @@ -52546,19 +52619,19 @@ fn __action1047< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1048< +fn __action1046< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, TextSize, TextSize), ) -> ast::Stmt { let __start0 = __2.0; let __end0 = __3.2; - let __temp0 = __action1047( + let __temp0 = __action1045( mode, __2, __3, @@ -52575,11 +52648,11 @@ fn __action1048< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1049< +fn __action1047< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -52602,12 +52675,12 @@ fn __action1049< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1050< +fn __action1048< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { let __start0 = __0.0; let __end0 = __1.2; @@ -52625,13 +52698,13 @@ fn __action1050< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1051< +fn __action1049< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec { let __start0 = __1.0; let __end0 = __2.2; @@ -52650,16 +52723,16 @@ fn __action1051< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1052< +fn __action1050< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __2.2; let __end0 = __3.0; @@ -52681,19 +52754,82 @@ fn __action1052< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1051< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __3.0; + let __end0 = __3.2; + let __temp0 = __action544( + mode, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action715( + mode, + __0, + __1, + __2, + __temp0, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1052< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __2.2; + let __end0 = __3.0; + let __temp0 = __action543( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action716( + mode, + __0, + __1, + __2, + __temp0, + __3, + __4, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1053< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, TextSize, TextSize), -) -> Result> + __5: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __3.0; let __end0 = __3.2; @@ -52702,7 +52838,7 @@ fn __action1053< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action715( + __action716( mode, __0, __1, @@ -52710,7 +52846,6 @@ fn __action1053< __temp0, __4, __5, - __6, ) } @@ -52720,11 +52855,12 @@ fn __action1054< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, TextSize, TextSize), -) -> Result> + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __2.2; let __end0 = __3.0; @@ -52734,7 +52870,7 @@ fn __action1054< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action716( + __action734( mode, __0, __1, @@ -52742,6 +52878,7 @@ fn __action1054< __temp0, __3, __4, + __5, ) } @@ -52751,77 +52888,13 @@ fn __action1055< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __3.0; - let __end0 = __3.2; - let __temp0 = __action544( - mode, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action716( - mode, - __0, - __1, - __2, - __temp0, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1056< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __2.2; - let __end0 = __3.0; - let __temp0 = __action543( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action733( - mode, - __0, - __1, - __2, - __temp0, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1057< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __3.0; let __end0 = __3.2; @@ -52830,7 +52903,7 @@ fn __action1057< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action733( + __action734( mode, __0, __1, @@ -52844,15 +52917,15 @@ fn __action1057< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1058< +fn __action1056< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __2.2; let __end0 = __3.0; @@ -52862,7 +52935,7 @@ fn __action1058< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action734( + __action735( mode, __0, __1, @@ -52875,16 +52948,16 @@ fn __action1058< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1059< +fn __action1057< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __3.0; let __end0 = __3.2; @@ -52893,7 +52966,7 @@ fn __action1059< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action734( + __action735( mode, __0, __1, @@ -52906,7 +52979,7 @@ fn __action1059< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1060< +fn __action1058< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -52929,7 +53002,7 @@ fn __action1060< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1061< +fn __action1059< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -52954,7 +53027,7 @@ fn __action1061< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1062< +fn __action1060< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -52985,7 +53058,7 @@ fn __action1062< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1063< +fn __action1061< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53016,7 +53089,7 @@ fn __action1063< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1064< +fn __action1062< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53045,7 +53118,7 @@ fn __action1064< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1065< +fn __action1063< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53074,12 +53147,12 @@ fn __action1065< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1066< +fn __action1064< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> core::option::Option + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { let __start0 = __0.0; let __end0 = __1.2; @@ -53097,7 +53170,7 @@ fn __action1066< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1067< +fn __action1065< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -53107,20 +53180,20 @@ fn __action1067< __4: (TextSize, core::option::Option, TextSize), __5: (TextSize, ast::Parameters, TextSize), __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, ast::Expr, TextSize), + __7: (TextSize, ast::ParenthesizedExpr, TextSize), __8: (TextSize, token::Tok, TextSize), __9: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt { let __start0 = __6.0; let __end0 = __7.2; - let __temp0 = __action1066( + let __temp0 = __action1064( mode, __6, __7, ); let __temp0 = (__start0, __temp0, __end0); - __action784( + __action786( mode, __0, __1, @@ -53136,7 +53209,7 @@ fn __action1067< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1068< +fn __action1066< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -53157,7 +53230,7 @@ fn __action1068< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action784( + __action786( mode, __0, __1, @@ -53173,7 +53246,7 @@ fn __action1068< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1069< +fn __action1067< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -53182,20 +53255,20 @@ fn __action1069< __3: (TextSize, core::option::Option, TextSize), __4: (TextSize, ast::Parameters, TextSize), __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Expr, TextSize), + __6: (TextSize, ast::ParenthesizedExpr, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt { let __start0 = __5.0; let __end0 = __6.2; - let __temp0 = __action1066( + let __temp0 = __action1064( mode, __5, __6, ); let __temp0 = (__start0, __temp0, __end0); - __action785( + __action787( mode, __0, __1, @@ -53210,7 +53283,7 @@ fn __action1069< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1070< +fn __action1068< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -53230,7 +53303,7 @@ fn __action1070< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action785( + __action787( mode, __0, __1, @@ -53245,7 +53318,7 @@ fn __action1070< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1071< +fn __action1069< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53268,7 +53341,7 @@ fn __action1071< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1072< +fn __action1070< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(token::Tok, ast::Identifier)>, TextSize), @@ -53293,12 +53366,12 @@ fn __action1072< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1073< +fn __action1071< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> core::option::Option + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { let __start0 = __0.0; let __end0 = __1.2; @@ -53316,24 +53389,76 @@ fn __action1073< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1074< +fn __action1072< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Parameter { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1073( + let __temp0 = __action1071( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action766( + __action768( + mode, + __0, + __temp0, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1073< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, TextSize, TextSize), +) -> ast::Parameter +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action272( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action768( + mode, + __0, + __temp0, + __1, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1074< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> ast::TypeParam +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1071( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action919( mode, __0, __temp0, @@ -53348,7 +53473,7 @@ fn __action1075< mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::Parameter +) -> ast::TypeParam { let __start0 = __0.2; let __end0 = __1.0; @@ -53358,7 +53483,7 @@ fn __action1075< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action766( + __action919( mode, __0, __temp0, @@ -53373,19 +53498,19 @@ fn __action1076< mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), -) -> ast::TypeParam +) -> ast::ParameterWithDefault { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1073( + let __temp0 = __action1071( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action918( + __action924( mode, __0, __temp0, @@ -53400,7 +53525,7 @@ fn __action1077< mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, TextSize, TextSize), -) -> ast::TypeParam +) -> ast::ParameterWithDefault { let __start0 = __0.2; let __end0 = __1.0; @@ -53410,7 +53535,7 @@ fn __action1077< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action918( + __action924( mode, __0, __temp0, @@ -53421,63 +53546,11 @@ fn __action1077< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1078< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> ast::ParameterWithDefault -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1073( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action923( - mode, - __0, - __temp0, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1079< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> ast::ParameterWithDefault -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action272( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action923( - mode, - __0, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1080< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> core::option::Option + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { let __start0 = __0.0; let __end0 = __1.2; @@ -53495,24 +53568,24 @@ fn __action1080< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1081< +fn __action1079< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Parameter { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1080( + let __temp0 = __action1078( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action900( + __action902( mode, __0, __temp0, @@ -53522,7 +53595,7 @@ fn __action1081< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1082< +fn __action1080< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -53537,7 +53610,7 @@ fn __action1082< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action900( + __action902( mode, __0, __temp0, @@ -53547,7 +53620,7 @@ fn __action1082< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1083< +fn __action1081< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53568,7 +53641,7 @@ fn __action1083< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1084< +fn __action1082< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -53591,7 +53664,7 @@ fn __action1084< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1085< +fn __action1083< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53612,7 +53685,7 @@ fn __action1085< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1086< +fn __action1084< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -53635,11 +53708,11 @@ fn __action1086< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1087< +fn __action1085< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Mod { @@ -53651,7 +53724,7 @@ fn __action1087< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action912( + __action913( mode, __0, __1, @@ -53662,11 +53735,11 @@ fn __action1087< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1088< +fn __action1086< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, TextSize, TextSize), ) -> ast::Mod @@ -53678,7 +53751,7 @@ fn __action1088< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action912( + __action913( mode, __0, __1, @@ -53689,7 +53762,7 @@ fn __action1088< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1089< +fn __action1087< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53710,6 +53783,58 @@ fn __action1089< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1088< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Identifier, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> ast::Alias +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1087( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action799( + mode, + __0, + __temp0, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1089< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, TextSize, TextSize), +) -> ast::Alias +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action401( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action799( + mode, + __0, + __temp0, + __1, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1090< @@ -53723,13 +53848,13 @@ fn __action1090< { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1089( + let __temp0 = __action1087( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action797( + __action800( mode, __0, __temp0, @@ -53754,7 +53879,7 @@ fn __action1091< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action797( + __action800( mode, __0, __temp0, @@ -53765,58 +53890,6 @@ fn __action1091< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1092< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> ast::Alias -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1089( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action798( - mode, - __0, - __temp0, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1093< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, TextSize, TextSize), -) -> ast::Alias -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action401( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action798( - mode, - __0, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1094< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -53841,14 +53914,14 @@ fn __action1094< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1095< +fn __action1093< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), __7: (TextSize, token::Tok, TextSize), @@ -53858,14 +53931,14 @@ fn __action1095< { let __start0 = __7.0; let __end0 = __9.2; - let __temp0 = __action1094( + let __temp0 = __action1092( mode, __7, __8, __9, ); let __temp0 = (__start0, __temp0, __end0); - __action782( + __action784( mode, __0, __1, @@ -53880,14 +53953,14 @@ fn __action1095< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1096< +fn __action1094< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -53900,7 +53973,7 @@ fn __action1096< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action782( + __action784( mode, __0, __1, @@ -53915,13 +53988,13 @@ fn __action1096< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1097< +fn __action1095< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, ast::Suite, TextSize), __6: (TextSize, token::Tok, TextSize), @@ -53931,14 +54004,14 @@ fn __action1097< { let __start0 = __6.0; let __end0 = __8.2; - let __temp0 = __action1094( + let __temp0 = __action1092( mode, __6, __7, __8, ); let __temp0 = (__start0, __temp0, __end0); - __action783( + __action785( mode, __0, __1, @@ -53952,13 +54025,13 @@ fn __action1097< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1098< +fn __action1096< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -53971,7 +54044,7 @@ fn __action1098< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action783( + __action785( mode, __0, __1, @@ -53983,6 +54056,76 @@ fn __action1098< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1097< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Suite, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Suite, TextSize), + __7: (TextSize, core::option::Option, TextSize), + __8: (TextSize, TextSize, TextSize), +) -> ast::Stmt +{ + let __start0 = __4.0; + let __end0 = __6.2; + let __temp0 = __action1092( + mode, + __4, + __5, + __6, + ); + let __temp0 = (__start0, __temp0, __end0); + __action914( + mode, + __0, + __1, + __2, + __3, + __temp0, + __7, + __8, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1098< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Suite, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, core::option::Option, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> ast::Stmt +{ + let __start0 = __3.2; + let __end0 = __4.0; + let __temp0 = __action315( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action914( + mode, + __0, + __1, + __2, + __3, + __temp0, + __4, + __5, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1099< @@ -54001,14 +54144,14 @@ fn __action1099< { let __start0 = __4.0; let __end0 = __6.2; - let __temp0 = __action1094( + let __temp0 = __action1092( mode, __4, __5, __6, ); let __temp0 = (__start0, __temp0, __end0); - __action913( + __action915( mode, __0, __1, @@ -54041,7 +54184,7 @@ fn __action1100< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action913( + __action915( mode, __0, __1, @@ -54059,77 +54202,7 @@ fn __action1101< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Suite, TextSize), - __7: (TextSize, core::option::Option, TextSize), - __8: (TextSize, TextSize, TextSize), -) -> ast::Stmt -{ - let __start0 = __4.0; - let __end0 = __6.2; - let __temp0 = __action1094( - mode, - __4, - __5, - __6, - ); - let __temp0 = (__start0, __temp0, __end0); - __action914( - mode, - __0, - __1, - __2, - __3, - __temp0, - __7, - __8, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1102< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, core::option::Option, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> ast::Stmt -{ - let __start0 = __3.2; - let __end0 = __4.0; - let __temp0 = __action315( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action914( - mode, - __0, - __1, - __2, - __3, - __temp0, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1103< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -54139,14 +54212,14 @@ fn __action1103< { let __start0 = __4.0; let __end0 = __6.2; - let __temp0 = __action1094( + let __temp0 = __action1092( mode, __4, __5, __6, ); let __temp0 = (__start0, __temp0, __end0); - __action926( + __action927( mode, __0, __1, @@ -54158,11 +54231,11 @@ fn __action1103< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1104< +fn __action1102< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -54175,7 +54248,7 @@ fn __action1104< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action926( + __action927( mode, __0, __1, @@ -54187,7 +54260,7 @@ fn __action1104< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1105< +fn __action1103< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54212,7 +54285,7 @@ fn __action1105< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1106< +fn __action1104< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54232,7 +54305,7 @@ fn __action1106< __5, ); let __temp0 = (__start0, __temp0, __end0); - __action915( + __action916( mode, __0, __1, @@ -54241,6 +54314,84 @@ fn __action1106< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1105< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Suite, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Suite, TextSize), + __7: (TextSize, token::Tok, TextSize), + __8: (TextSize, token::Tok, TextSize), + __9: (TextSize, ast::Suite, TextSize), + __10: (TextSize, TextSize, TextSize), +) -> ast::Stmt +{ + let __start0 = __7.0; + let __end0 = __9.2; + let __temp0 = __action1103( + mode, + __7, + __8, + __9, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1097( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + __temp0, + __10, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1106< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Suite, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Suite, TextSize), + __7: (TextSize, TextSize, TextSize), +) -> ast::Stmt +{ + let __start0 = __6.2; + let __end0 = __7.0; + let __temp0 = __action308( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1097( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + __temp0, + __7, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1107< @@ -54253,32 +54404,26 @@ fn __action1107< __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), - __7: (TextSize, token::Tok, TextSize), - __8: (TextSize, token::Tok, TextSize), - __9: (TextSize, ast::Suite, TextSize), - __10: (TextSize, TextSize, TextSize), + __7: (TextSize, TextSize, TextSize), ) -> ast::Stmt { - let __start0 = __7.0; - let __end0 = __9.2; - let __temp0 = __action1105( + let __start0 = __4.0; + let __end0 = __6.2; + let __temp0 = __action1103( mode, - __7, - __8, - __9, + __4, + __5, + __6, ); let __temp0 = (__start0, __temp0, __end0); - __action1099( + __action1098( mode, __0, __1, __2, __3, - __4, - __5, - __6, __temp0, - __10, + __7, ) } @@ -54291,103 +54436,31 @@ fn __action1108< __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Suite, TextSize), __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Suite, TextSize), - __7: (TextSize, TextSize, TextSize), + __4: (TextSize, TextSize, TextSize), ) -> ast::Stmt { - let __start0 = __6.2; - let __end0 = __7.0; + let __start0 = __3.2; + let __end0 = __4.0; let __temp0 = __action308( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1099( + __action1098( mode, __0, __1, __2, __3, - __4, - __5, - __6, __temp0, - __7, + __4, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1109< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Suite, TextSize), - __7: (TextSize, TextSize, TextSize), -) -> ast::Stmt -{ - let __start0 = __4.0; - let __end0 = __6.2; - let __temp0 = __action1105( - mode, - __4, - __5, - __6, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1100( - mode, - __0, - __1, - __2, - __3, - __temp0, - __7, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1110< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, TextSize, TextSize), -) -> ast::Stmt -{ - let __start0 = __3.2; - let __end0 = __4.0; - let __temp0 = __action308( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1100( - mode, - __0, - __1, - __2, - __3, - __temp0, - __4, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1111< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54405,14 +54478,14 @@ fn __action1111< { let __start0 = __7.0; let __end0 = __9.2; - let __temp0 = __action1105( + let __temp0 = __action1103( mode, __7, __8, __9, ); let __temp0 = (__start0, __temp0, __end0); - __action1101( + __action1099( mode, __0, __1, @@ -54428,7 +54501,7 @@ fn __action1111< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1112< +fn __action1110< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54449,7 +54522,7 @@ fn __action1112< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1101( + __action1099( mode, __0, __1, @@ -54465,7 +54538,7 @@ fn __action1112< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1113< +fn __action1111< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54480,14 +54553,14 @@ fn __action1113< { let __start0 = __4.0; let __end0 = __6.2; - let __temp0 = __action1105( + let __temp0 = __action1103( mode, __4, __5, __6, ); let __temp0 = (__start0, __temp0, __end0); - __action1102( + __action1100( mode, __0, __1, @@ -54500,7 +54573,7 @@ fn __action1113< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1114< +fn __action1112< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54518,7 +54591,7 @@ fn __action1114< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1102( + __action1100( mode, __0, __1, @@ -54531,12 +54604,12 @@ fn __action1114< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1115< +fn __action1113< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> core::option::Option + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { let __start0 = __0.0; let __end0 = __1.2; @@ -54554,25 +54627,25 @@ fn __action1115< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1116< +fn __action1114< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, TextSize, TextSize), ) -> ast::Stmt { let __start0 = __2.0; let __end0 = __3.2; - let __temp0 = __action1115( + let __temp0 = __action1113( mode, __2, __3, ); let __temp0 = (__start0, __temp0, __end0); - __action886( + __action888( mode, __0, __1, @@ -54583,11 +54656,11 @@ fn __action1116< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1117< +fn __action1115< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, TextSize, TextSize), ) -> ast::Stmt { @@ -54599,7 +54672,7 @@ fn __action1117< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action886( + __action888( mode, __0, __1, @@ -54610,14 +54683,14 @@ fn __action1117< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1118< +fn __action1116< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), -) -> alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)> +) -> alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)> { let __start0 = __0.0; let __end0 = __3.2; @@ -54637,15 +54710,15 @@ fn __action1118< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1119< +fn __action1117< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), + __0: (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, ast::Suite, TextSize), -) -> alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)> +) -> alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)> { let __start0 = __1.0; let __end0 = __4.2; @@ -54666,11 +54739,11 @@ fn __action1119< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1120< +fn __action1118< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), __4: (TextSize, core::option::Option<(TextSize, ast::Suite)>, TextSize), @@ -54684,7 +54757,7 @@ fn __action1120< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action796( + __action798( mode, __0, __1, @@ -54697,14 +54770,14 @@ fn __action1120< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1121< +fn __action1119< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), - __4: (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), + __4: (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), __5: (TextSize, core::option::Option<(TextSize, ast::Suite)>, TextSize), ) -> ast::Stmt { @@ -54715,7 +54788,7 @@ fn __action1121< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action796( + __action798( mode, __0, __1, @@ -54728,7 +54801,7 @@ fn __action1121< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1122< +fn __action1120< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -54753,11 +54826,11 @@ fn __action1122< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1123< +fn __action1121< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -54767,14 +54840,14 @@ fn __action1123< { let __start0 = __4.0; let __end0 = __6.2; - let __temp0 = __action1122( + let __temp0 = __action1120( mode, __4, __5, __6, ); let __temp0 = (__start0, __temp0, __end0); - __action1120( + __action1118( mode, __0, __1, @@ -54786,11 +54859,11 @@ fn __action1123< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1124< +fn __action1122< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -54803,7 +54876,7 @@ fn __action1124< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1120( + __action1118( mode, __0, __1, @@ -54815,14 +54888,14 @@ fn __action1124< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1125< +fn __action1123< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), - __4: (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), + __4: (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), @@ -54830,14 +54903,14 @@ fn __action1125< { let __start0 = __5.0; let __end0 = __7.2; - let __temp0 = __action1122( + let __temp0 = __action1120( mode, __5, __6, __7, ); let __temp0 = (__start0, __temp0, __end0); - __action1121( + __action1119( mode, __0, __1, @@ -54850,14 +54923,14 @@ fn __action1125< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1126< +fn __action1124< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Suite, TextSize), - __4: (TextSize, alloc::vec::Vec<(TextSize, ast::Expr, ast::Suite)>, TextSize), + __4: (TextSize, alloc::vec::Vec<(TextSize, ast::ParenthesizedExpr, ast::Suite)>, TextSize), ) -> ast::Stmt { let __start0 = __4.2; @@ -54868,7 +54941,7 @@ fn __action1126< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1121( + __action1119( mode, __0, __1, @@ -54881,12 +54954,12 @@ fn __action1126< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1127< +fn __action1125< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> alloc::vec::Vec +) -> alloc::vec::Vec { let __start0 = __0.0; let __end0 = __1.2; @@ -54904,13 +54977,13 @@ fn __action1127< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1128< +fn __action1126< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> alloc::vec::Vec +) -> alloc::vec::Vec { let __start0 = __1.0; let __end0 = __2.2; @@ -54929,7 +55002,7 @@ fn __action1128< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1129< +fn __action1127< >( mode: Mode, __0: (TextSize, (Option<(TextSize, TextSize, Option)>, ast::Expr), TextSize), @@ -54952,7 +55025,7 @@ fn __action1129< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1130< +fn __action1128< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize), @@ -54977,7 +55050,7 @@ fn __action1130< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1131< +fn __action1129< >( mode: Mode, __0: (TextSize, core::option::Option<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize), @@ -55000,7 +55073,7 @@ fn __action1131< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1132< +fn __action1130< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize), @@ -55023,12 +55096,12 @@ fn __action1132< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1133< +fn __action1131< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> alloc::vec::Vec +) -> alloc::vec::Vec { let __start0 = __0.0; let __end0 = __1.2; @@ -55046,13 +55119,13 @@ fn __action1133< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1134< +fn __action1132< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> alloc::vec::Vec +) -> alloc::vec::Vec { let __start0 = __1.0; let __end0 = __2.2; @@ -55071,12 +55144,12 @@ fn __action1134< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1135< +fn __action1133< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> core::option::Option> +) -> core::option::Option> { let __start0 = __0.0; let __end0 = __1.2; @@ -55094,27 +55167,27 @@ fn __action1135< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1136< +fn __action1134< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1135( + let __temp0 = __action1133( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1052( + __action1050( mode, __0, __temp0, @@ -55127,15 +55200,15 @@ fn __action1136< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1137< +fn __action1135< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __0.2; let __end0 = __1.0; @@ -55145,7 +55218,7 @@ fn __action1137< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1052( + __action1050( mode, __0, __temp0, @@ -55158,28 +55231,28 @@ fn __action1137< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1138< +fn __action1136< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1135( + let __temp0 = __action1133( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1053( + __action1051( mode, __0, __temp0, @@ -55191,18 +55264,143 @@ fn __action1138< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1137< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action547( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1051( + mode, + __0, + __temp0, + __1, + __2, + __3, + __4, + __5, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1138< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1133( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1052( + mode, + __0, + __temp0, + __3, + __4, + __5, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1139< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action547( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1052( + mode, + __0, + __temp0, + __1, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1140< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1133( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1053( + mode, + __0, + __temp0, + __3, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1141< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> + __4: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __0.2; let __end0 = __1.0; @@ -55220,67 +55418,6 @@ fn __action1139< __2, __3, __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1140< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1135( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1054( - mode, - __0, - __temp0, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1141< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action547( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1054( - mode, - __0, - __temp0, - __1, - __2, - __3, ) } @@ -55290,23 +55427,23 @@ fn __action1142< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1135( + let __temp0 = __action1133( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1055( + __action1054( mode, __0, __temp0, @@ -55323,11 +55460,78 @@ fn __action1143< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, TextSize, TextSize), -) -> Result> +) -> Result> +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action547( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1054( + mode, + __0, + __temp0, + __1, + __2, + __3, + __4, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1144< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, token::Tok, TextSize), + __7: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1133( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1055( + mode, + __0, + __temp0, + __3, + __4, + __5, + __6, + __7, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1145< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __0.2; let __end0 = __1.0; @@ -55345,70 +55549,7 @@ fn __action1143< __2, __3, __4, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1144< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1135( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1056( - mode, - __0, - __temp0, - __3, - __4, __5, - __6, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1145< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action547( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1056( - mode, - __0, - __temp0, - __1, - __2, - __3, - __4, ) } @@ -55418,32 +55559,28 @@ fn __action1146< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, TextSize, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1135( + let __temp0 = __action1133( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1057( + __action1056( mode, __0, __temp0, __3, __4, __5, - __6, - __7, ) } @@ -55453,12 +55590,73 @@ fn __action1147< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action547( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1056( + mode, + __0, + __temp0, + __1, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1148< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, TextSize, TextSize), +) -> Result> +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1133( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1057( + mode, + __0, + __temp0, + __3, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1149< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> + __4: (TextSize, TextSize, TextSize), +) -> Result> { let __start0 = __0.2; let __end0 = __1.0; @@ -55476,137 +55674,12 @@ fn __action1147< __2, __3, __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1148< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1135( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1058( - mode, - __0, - __temp0, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1149< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action547( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1058( - mode, - __0, - __temp0, - __1, - __2, - __3, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1150< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1135( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1059( - mode, - __0, - __temp0, - __3, - __4, - __5, - __6, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1151< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, TextSize, TextSize), -) -> Result> -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action547( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1059( - mode, - __0, - __temp0, - __1, - __2, - __3, - __4, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1152< >( mode: Mode, __0: (TextSize, ast::Pattern, TextSize), @@ -55629,7 +55702,7 @@ fn __action1152< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1153< +fn __action1151< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -55654,7 +55727,7 @@ fn __action1153< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1154< +fn __action1152< >( mode: Mode, __0: (TextSize, core::option::Option, TextSize), @@ -55677,7 +55750,7 @@ fn __action1154< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1155< +fn __action1153< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -55700,7 +55773,7 @@ fn __action1155< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1156< +fn __action1154< >( mode: Mode, __0: (TextSize, ast::Stmt, TextSize), @@ -55723,7 +55796,7 @@ fn __action1156< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1157< +fn __action1155< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -55748,7 +55821,7 @@ fn __action1157< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1158< +fn __action1156< >( mode: Mode, __0: (TextSize, ast::Suite, TextSize), @@ -55775,6 +55848,62 @@ fn __action1158< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1157< +>( + mode: Mode, + __0: (TextSize, ast::Suite, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, ast::Stmt, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), +) -> ast::Suite +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action387( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action645( + mode, + __0, + __temp0, + __2, + __3, + __4, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1158< +>( + mode: Mode, + __0: (TextSize, ast::Suite, TextSize), + __1: (TextSize, ast::Stmt, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::Suite +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action386( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action646( + mode, + __0, + __temp0, + __1, + __2, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1159< @@ -55784,7 +55913,6 @@ fn __action1159< __1: (TextSize, alloc::vec::Vec, TextSize), __2: (TextSize, ast::Stmt, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), ) -> ast::Suite { let __start0 = __1.0; @@ -55794,13 +55922,12 @@ fn __action1159< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action645( + __action646( mode, __0, __temp0, __2, __3, - __4, ) } @@ -55809,23 +55936,23 @@ fn __action1159< fn __action1160< >( mode: Mode, - __0: (TextSize, ast::Suite, TextSize), - __1: (TextSize, ast::Stmt, TextSize), + __0: (TextSize, ast::Stmt, TextSize), + __1: (TextSize, token::Tok, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> ast::Suite +) -> Vec { - let __start0 = __0.2; - let __end0 = __1.0; + let __start0 = __0.0; + let __end0 = __0.0; let __temp0 = __action386( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action646( + __action647( mode, - __0, __temp0, + __0, __1, __2, ) @@ -55836,23 +55963,23 @@ fn __action1160< fn __action1161< >( mode: Mode, - __0: (TextSize, ast::Suite, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), - __2: (TextSize, ast::Stmt, TextSize), + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::Stmt, TextSize), + __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> ast::Suite +) -> Vec { - let __start0 = __1.0; - let __end0 = __1.2; + let __start0 = __0.0; + let __end0 = __0.2; let __temp0 = __action387( mode, - __1, + __0, ); let __temp0 = (__start0, __temp0, __end0); - __action646( + __action647( mode, - __0, __temp0, + __1, __2, __3, ) @@ -55865,7 +55992,6 @@ fn __action1162< mode: Mode, __0: (TextSize, ast::Stmt, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), ) -> Vec { let __start0 = __0.0; @@ -55876,12 +56002,11 @@ fn __action1162< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action647( + __action648( mode, __temp0, __0, __1, - __2, ) } @@ -55893,7 +56018,6 @@ fn __action1163< __0: (TextSize, alloc::vec::Vec, TextSize), __1: (TextSize, ast::Stmt, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), ) -> Vec { let __start0 = __0.0; @@ -55903,68 +56027,17 @@ fn __action1163< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action647( + __action648( mode, __temp0, __1, __2, - __3, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1164< ->( - mode: Mode, - __0: (TextSize, ast::Stmt, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action386( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action648( - mode, - __temp0, - __0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1165< ->( - mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Stmt, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action387( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action648( - mode, - __temp0, - __1, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1166< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -55993,7 +56066,7 @@ fn __action1166< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1167< +fn __action1165< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -56022,7 +56095,7 @@ fn __action1167< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1168< +fn __action1166< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -56049,7 +56122,7 @@ fn __action1168< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1169< +fn __action1167< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -56076,7 +56149,7 @@ fn __action1169< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1170< +fn __action1168< >( mode: Mode, __0: (TextSize, ast::Stmt, TextSize), @@ -56103,7 +56176,7 @@ fn __action1170< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1171< +fn __action1169< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -56130,7 +56203,7 @@ fn __action1171< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1172< +fn __action1170< >( mode: Mode, __0: (TextSize, ast::Stmt, TextSize), @@ -56155,7 +56228,7 @@ fn __action1172< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1173< +fn __action1171< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -56180,11 +56253,11 @@ fn __action1173< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1174< +fn __action1172< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, ast::Identifier, TextSize), __4: (TextSize, token::Tok, TextSize), @@ -56200,7 +56273,7 @@ fn __action1174< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action768( + __action770( mode, __0, __temp0, @@ -56211,12 +56284,12 @@ fn __action1174< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1175< +fn __action1173< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), __4: (TextSize, ast::Identifier, TextSize), __5: (TextSize, token::Tok, TextSize), @@ -56232,7 +56305,7 @@ fn __action1175< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action770( + __action772( mode, __0, __1, @@ -56242,9 +56315,347 @@ fn __action1175< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1174< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action160( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action301( + mode, + __temp0, + __1, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1175< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action160( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action641( + mode, + __0, + __temp0, + __2, + __3, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1176< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action160( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action642( + mode, + __0, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1177< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> core::option::Option> +{ + let __start0 = __0.0; + let __end0 = __1.2; + let __temp0 = __action1174( + mode, + __0, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action299( + mode, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1178< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::WithItem, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1177( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1060( + mode, + __0, + __temp0, + __3, + __4, + __5, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1179< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::WithItem, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action300( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1060( + mode, + __0, + __temp0, + __1, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1180< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::WithItem, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1177( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1061( + mode, + __0, + __temp0, + __3, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1181< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::WithItem, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action300( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1061( + mode, + __0, + __temp0, + __1, + __2, + __3, + __4, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1182< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::WithItem, TextSize), + __4: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1177( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1062( + mode, + __0, + __temp0, + __3, + __4, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1183< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::WithItem, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action300( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1062( + mode, + __0, + __temp0, + __1, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1184< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::WithItem, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __1.0; + let __end0 = __2.2; + let __temp0 = __action1177( + mode, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1063( + mode, + __0, + __temp0, + __3, + __4, + __5, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1185< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::WithItem, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Vec +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action300( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1063( + mode, + __0, + __temp0, + __1, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1186< >( mode: Mode, __0: (TextSize, (String, StringKind, bool), TextSize), @@ -56267,13 +56678,13 @@ fn __action1176< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1177< +fn __action1187< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56294,13 +56705,13 @@ fn __action1177< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1178< +fn __action1188< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56321,13 +56732,13 @@ fn __action1178< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1179< +fn __action1189< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56348,12 +56759,12 @@ fn __action1179< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1180< +fn __action1190< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -56373,12 +56784,12 @@ fn __action1180< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1181< +fn __action1191< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -56398,7 +56809,7 @@ fn __action1181< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1182< +fn __action1192< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -56425,13 +56836,13 @@ fn __action1182< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1183< +fn __action1193< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56452,13 +56863,13 @@ fn __action1183< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1184< +fn __action1194< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56479,7 +56890,7 @@ fn __action1184< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1185< +fn __action1195< >( mode: Mode, __0: (TextSize, ast::Pattern, TextSize), @@ -56506,13 +56917,13 @@ fn __action1185< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1186< +fn __action1196< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __3.2; @@ -56523,7 +56934,7 @@ fn __action1186< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1048( + __action1046( mode, __0, __1, @@ -56535,11 +56946,11 @@ fn __action1186< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1187< +fn __action1197< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __1.2; @@ -56550,7 +56961,7 @@ fn __action1187< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1049( + __action1047( mode, __0, __1, @@ -56560,11 +56971,11 @@ fn __action1187< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1188< +fn __action1198< >( mode: Mode, __0: (TextSize, ast::Constant, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.2; let __end0 = __0.2; @@ -56583,11 +56994,11 @@ fn __action1188< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1189< +fn __action1199< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.2; let __end0 = __0.2; @@ -56606,13 +57017,13 @@ fn __action1189< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1190< +fn __action1200< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), + __1: (TextSize, core::option::Option>, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56633,14 +57044,14 @@ fn __action1190< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1191< +fn __action1201< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __3.2; let __end0 = __3.2; @@ -56662,14 +57073,14 @@ fn __action1191< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1192< +fn __action1202< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __3.2; let __end0 = __3.2; @@ -56691,13 +57102,13 @@ fn __action1192< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1193< +fn __action1203< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -56718,16 +57129,16 @@ fn __action1193< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1194< +fn __action1204< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), -) -> Result> +) -> Result> { let __start0 = __5.2; let __end0 = __5.2; @@ -56737,6 +57148,69 @@ fn __action1194< &__end0, ); let __temp0 = (__start0, __temp0, __end0); + __action1134( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1205< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1135( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1206< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __6.2; + let __end0 = __6.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); __action1136( mode, __0, @@ -56745,23 +57219,25 @@ fn __action1194< __3, __4, __5, + __6, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1195< +fn __action1207< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> Result> + __4: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __3.2; - let __end0 = __3.2; + let __start0 = __4.2; + let __end0 = __4.2; let __temp0 = __action392( mode, &__start0, @@ -56774,26 +57250,25 @@ fn __action1195< __1, __2, __3, + __4, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1196< +fn __action1208< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, token::Tok, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __6.2; - let __end0 = __6.2; + let __start0 = __4.2; + let __end0 = __4.2; let __temp0 = __action392( mode, &__start0, @@ -56807,26 +57282,22 @@ fn __action1196< __2, __3, __4, - __5, - __6, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1197< +fn __action1209< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> Result> + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __4.2; - let __end0 = __4.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -56838,26 +57309,25 @@ fn __action1197< __0, __1, __2, - __3, - __4, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1198< +fn __action1210< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __4.2; - let __end0 = __4.2; + let __start0 = __5.2; + let __end0 = __5.2; let __temp0 = __action392( mode, &__start0, @@ -56871,22 +57341,24 @@ fn __action1198< __2, __3, __4, + __5, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1199< +fn __action1211< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> Result> + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -56898,22 +57370,439 @@ fn __action1199< __0, __1, __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1200< +fn __action1212< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action717( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1213< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action718( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1214< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action719( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1215< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action720( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1216< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action721( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1217< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), + __2: (TextSize, Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action722( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1218< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action723( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1219< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action724( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1220< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action725( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1221< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action726( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1222< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action727( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1223< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action728( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1224< +>( + mode: Mode, + __0: (TextSize, ast::Constant, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action730( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1225< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action731( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1226< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option>, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action732( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1227< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action733( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1228< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, token::Tok, TextSize), __5: (TextSize, token::Tok, TextSize), -) -> Result> +) -> Result> { let __start0 = __5.2; let __end0 = __5.2; @@ -56937,14 +57826,14 @@ fn __action1200< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1201< +fn __action1229< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> Result> +) -> Result> { let __start0 = __3.2; let __end0 = __3.2; @@ -56966,408 +57855,20 @@ fn __action1201< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1202< +fn __action1230< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action717( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1203< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action718( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1204< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action719( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1205< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, ast::Expr)>>, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action720( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1206< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, (ast::Expr, ast::Expr), TextSize), - __2: (TextSize, Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action721( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1207< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action722( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1208< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action723( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1209< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action724( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1210< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action725( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1211< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action726( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1212< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action727( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1213< ->( - mode: Mode, - __0: (TextSize, ast::Constant, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action729( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1214< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action730( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1215< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action731( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1216< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action732( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1217< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), __5: (TextSize, token::Tok, TextSize), -) -> Result> + __6: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __5.2; - let __end0 = __5.2; + let __start0 = __6.2; + let __end0 = __6.2; let __temp0 = __action392( mode, &__start0, @@ -57382,23 +57883,25 @@ fn __action1217< __3, __4, __5, + __6, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1218< +fn __action1231< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> Result> + __4: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __3.2; - let __end0 = __3.2; + let __start0 = __4.2; + let __end0 = __4.2; let __temp0 = __action392( mode, &__start0, @@ -57411,26 +57914,25 @@ fn __action1218< __1, __2, __3, + __4, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1219< +fn __action1232< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, token::Tok, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __6.2; - let __end0 = __6.2; + let __start0 = __4.2; + let __end0 = __4.2; let __temp0 = __action392( mode, &__start0, @@ -57444,26 +57946,22 @@ fn __action1219< __2, __3, __4, - __5, - __6, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1220< +fn __action1233< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> Result> + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __4.2; - let __end0 = __4.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -57475,26 +57973,25 @@ fn __action1220< __0, __1, __2, - __3, - __4, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1221< +fn __action1234< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), + __5: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __4.2; - let __end0 = __4.2; + let __start0 = __5.2; + let __end0 = __5.2; let __temp0 = __action392( mode, &__start0, @@ -57508,22 +58005,24 @@ fn __action1221< __2, __3, __4, + __5, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1222< +fn __action1235< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> Result> + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> Result> { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -57531,67 +58030,6 @@ fn __action1222< ); let __temp0 = (__start0, __temp0, __end0); __action1149( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1223< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __5.2; - let __end0 = __5.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1150( - mode, - __0, - __1, - __2, - __3, - __4, - __5, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1224< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1151( mode, __0, __1, @@ -57603,12 +58041,12 @@ fn __action1224< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1225< +fn __action1236< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -57618,56 +58056,26 @@ fn __action1225< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action735( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1226< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action736( mode, __0, __1, - __2, - __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1227< +fn __action1237< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> Result> + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __3.2; - let __end0 = __3.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -57679,23 +58087,23 @@ fn __action1227< __0, __1, __2, - __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1228< +fn __action1238< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option>, ast::Expr)>>, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -57707,20 +58115,21 @@ fn __action1228< __0, __1, __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1229< +fn __action1239< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, (ast::Expr, ast::Expr), TextSize), - __2: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> Result> { let __start0 = __3.2; let __end0 = __3.2; @@ -57742,13 +58151,13 @@ fn __action1229< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1230< +fn __action1240< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, core::option::Option>, ast::ParenthesizedExpr)>>, TextSize), __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -57769,14 +58178,14 @@ fn __action1230< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1231< +fn __action1241< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, (ast::ParenthesizedExpr, ast::ParenthesizedExpr), TextSize), __2: (TextSize, Vec, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __3.2; let __end0 = __3.2; @@ -57798,14 +58207,16 @@ fn __action1231< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1232< +fn __action1242< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -57815,20 +58226,25 @@ fn __action1232< __action742( mode, __0, + __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1233< +fn __action1243< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, Vec, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -57838,17 +58254,20 @@ fn __action1233< __action743( mode, __0, + __1, + __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1234< +fn __action1244< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.2; let __end0 = __0.2; @@ -57867,11 +58286,11 @@ fn __action1234< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1235< +fn __action1245< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.2; let __end0 = __0.2; @@ -57890,15 +58309,14 @@ fn __action1235< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1236< +fn __action1246< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::Arguments, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action392( mode, &__start0, @@ -57906,6 +58324,53 @@ fn __action1236< ); let __temp0 = (__start0, __temp0, __end0); __action746( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1247< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action747( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1248< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, ast::Arguments, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action748( mode, __0, __1, @@ -57915,14 +58380,14 @@ fn __action1236< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1237< +fn __action1249< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __3.2; let __end0 = __3.2; @@ -57932,7 +58397,7 @@ fn __action1237< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action747( + __action749( mode, __0, __1, @@ -57944,13 +58409,13 @@ fn __action1237< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1238< +fn __action1250< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -57960,81 +58425,26 @@ fn __action1238< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action748( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1239< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::Arguments, TextSize), -) -> ast::Expr -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action749( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1240< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action750( mode, __0, __1, __2, - __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1241< +fn __action1251< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, ast::Arguments, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __1.2; + let __end0 = __1.2; let __temp0 = __action392( mode, &__start0, @@ -58045,22 +58455,23 @@ fn __action1241< mode, __0, __1, - __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1242< +fn __action1252< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -58071,21 +58482,24 @@ fn __action1242< mode, __0, __1, + __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1243< +fn __action1253< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Identifier, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -58096,13 +58510,64 @@ fn __action1243< mode, __0, __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1244< +fn __action1254< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action754( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1255< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action755( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1256< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -58116,71 +58581,21 @@ fn __action1244< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action754( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1245< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::PatternArguments, TextSize), -) -> ast::Pattern -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action756( mode, __0, - __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1246< +fn __action1257< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), __1: (TextSize, ast::PatternArguments, TextSize), ) -> ast::Pattern -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action757( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1247< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), -) -> ast::Expr { let __start0 = __1.2; let __end0 = __1.2; @@ -58200,12 +58615,12 @@ fn __action1247< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1248< +fn __action1258< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), -) -> ast::Expr + __1: (TextSize, ast::PatternArguments, TextSize), +) -> ast::Pattern { let __start0 = __1.2; let __end0 = __1.2; @@ -58225,14 +58640,15 @@ fn __action1248< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1249< +fn __action1259< >( mode: Mode, - __0: (TextSize, ast::Constant, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __1.2; let __temp0 = __action392( mode, &__start0, @@ -58242,18 +58658,19 @@ fn __action1249< __action760( mode, __0, + __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1250< +fn __action1260< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -58273,16 +58690,14 @@ fn __action1250< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1251< +fn __action1261< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Decorator + __0: (TextSize, ast::Constant, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __1.2; - let __end0 = __2.0; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action392( mode, &__start0, @@ -58292,20 +58707,18 @@ fn __action1251< __action762( mode, __0, - __1, __temp0, - __2, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1252< +fn __action1262< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), -) -> ast::Stmt + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -58325,14 +58738,16 @@ fn __action1252< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1253< +fn __action1263< >( mode: Mode, - __0: (TextSize, String, TextSize), -) -> ast::Identifier + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::Decorator { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __2.0; let __temp0 = __action392( mode, &__start0, @@ -58342,18 +58757,20 @@ fn __action1253< __action764( mode, __0, + __1, __temp0, + __2, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1254< +fn __action1264< >( mode: Mode, - __0: (TextSize, String, TextSize), - __1: (TextSize, alloc::vec::Vec<(token::Tok, ast::Identifier)>, TextSize), -) -> ast::Identifier + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), +) -> ast::Stmt { let __start0 = __1.2; let __end0 = __1.2; @@ -58373,12 +58790,60 @@ fn __action1254< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1255< +fn __action1265< +>( + mode: Mode, + __0: (TextSize, String, TextSize), +) -> ast::Identifier +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action766( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1266< +>( + mode: Mode, + __0: (TextSize, String, TextSize), + __1: (TextSize, alloc::vec::Vec<(token::Tok, ast::Identifier)>, TextSize), +) -> ast::Identifier +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action767( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1267< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Parameter { let __start0 = __2.2; @@ -58389,7 +58854,7 @@ fn __action1255< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1074( + __action1072( mode, __0, __1, @@ -58400,7 +58865,7 @@ fn __action1255< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1256< +fn __action1268< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -58414,7 +58879,7 @@ fn __action1256< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1075( + __action1073( mode, __0, __temp0, @@ -58423,13 +58888,13 @@ fn __action1256< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1257< +fn __action1269< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -58439,76 +58904,24 @@ fn __action1257< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action771( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1258< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action772( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1259< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), -) -> ast::Stmt -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action773( mode, __0, __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1260< +fn __action1270< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Stmt + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -58529,13 +58942,65 @@ fn __action1260< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1261< +fn __action1271< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), +) -> ast::Stmt +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action775( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1272< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, ast::Operator, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::Stmt +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action776( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1273< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, core::option::Option, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, core::option::Option, TextSize), ) -> ast::Stmt { let __start0 = __3.2; @@ -58546,7 +59011,7 @@ fn __action1261< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action775( + __action777( mode, __0, __1, @@ -58558,12 +59023,12 @@ fn __action1261< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1262< +fn __action1274< >( mode: Mode, __0: (TextSize, ast::UnaryOp, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -58573,65 +59038,42 @@ fn __action1262< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action776( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1263< ->( - mode: Mode, - __0: (TextSize, ast::UnaryOp, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action777( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1264< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Stmt -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action778( mode, __0, + __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1265< +fn __action1275< +>( + mode: Mode, + __0: (TextSize, ast::UnaryOp, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action779( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1276< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -58645,44 +59087,19 @@ fn __action1265< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action779( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1266< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), -) -> ast::Stmt -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action780( mode, __0, - __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1267< +fn __action1277< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, token::Tok, TextSize), ) -> ast::Stmt { let __start0 = __0.2; @@ -58702,12 +59119,12 @@ fn __action1267< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1268< +fn __action1278< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, core::option::Option>, TextSize), -) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option, TextSize), +) -> ast::Stmt { let __start0 = __1.2; let __end0 = __1.2; @@ -58717,7 +59134,7 @@ fn __action1268< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action786( + __action782( mode, __0, __1, @@ -58727,38 +59144,34 @@ fn __action1268< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1269< +fn __action1279< >( mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) + __0: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::Stmt { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action392( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action787( + __action783( mode, __0, - __1, - __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1270< +fn __action1280< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, core::option::Option>, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { let __start0 = __1.2; @@ -58779,15 +59192,16 @@ fn __action1270< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1271< +fn __action1281< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -58798,18 +59212,19 @@ fn __action1271< mode, __0, __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1272< +fn __action1282< >( mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { let __start0 = __1.2; let __end0 = __1.2; @@ -58829,14 +59244,15 @@ fn __action1272< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1273< +fn __action1283< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __1.2; let __temp0 = __action392( mode, &__start0, @@ -58846,18 +59262,19 @@ fn __action1273< __action791( mode, __0, + __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1274< +fn __action1284< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, Vec, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -58877,11 +59294,11 @@ fn __action1274< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1275< +fn __action1285< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> ast::Expr + __0: (TextSize, Vec, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.2; let __end0 = __0.2; @@ -58900,12 +59317,12 @@ fn __action1275< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1276< +fn __action1286< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), -) -> ast::Stmt + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -58925,11 +59342,11 @@ fn __action1276< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1277< +fn __action1287< >( mode: Mode, - __0: (TextSize, String, TextSize), -) -> ast::Identifier + __0: (TextSize, Vec, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.2; let __end0 = __0.2; @@ -58948,7 +59365,105 @@ fn __action1277< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1278< +fn __action1288< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), +) -> ast::Stmt +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action796( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1289< +>( + mode: Mode, + __0: (TextSize, String, TextSize), +) -> ast::Identifier +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action797( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1290< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Identifier, TextSize), +) -> ast::Alias +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1088( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1291< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), +) -> ast::Alias +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1089( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1292< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -58975,7 +59490,7 @@ fn __action1278< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1279< +fn __action1293< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -58998,57 +59513,7 @@ fn __action1279< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1280< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), -) -> ast::Alias -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1092( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1281< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), -) -> ast::Alias -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1093( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1282< +fn __action1294< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -59062,7 +59527,7 @@ fn __action1282< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action799( + __action801( mode, __0, __temp0, @@ -59071,7 +59536,7 @@ fn __action1282< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1283< +fn __action1295< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59088,7 +59553,7 @@ fn __action1283< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action800( + __action802( mode, __0, __1, @@ -59100,7 +59565,7 @@ fn __action1283< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1284< +fn __action1296< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59116,7 +59581,7 @@ fn __action1284< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action801( + __action803( mode, __0, __1, @@ -59127,7 +59592,7 @@ fn __action1284< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1285< +fn __action1297< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59141,7 +59606,7 @@ fn __action1285< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action802( + __action804( mode, __0, __temp0, @@ -59150,7 +59615,7 @@ fn __action1285< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1286< +fn __action1298< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59165,7 +59630,7 @@ fn __action1286< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action803( + __action805( mode, __0, __1, @@ -59175,7 +59640,7 @@ fn __action1286< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1287< +fn __action1299< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59192,7 +59657,7 @@ fn __action1287< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action804( + __action806( mode, __0, __1, @@ -59204,11 +59669,11 @@ fn __action1287< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1288< +fn __action1300< >( mode: Mode, __0: (TextSize, (IpyEscapeKind, String), TextSize), -) -> Result> +) -> Result> { let __start0 = __0.2; let __end0 = __0.2; @@ -59218,7 +59683,7 @@ fn __action1288< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action805( + __action807( mode, __0, __temp0, @@ -59227,7 +59692,7 @@ fn __action1288< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1289< +fn __action1301< >( mode: Mode, __0: (TextSize, (IpyEscapeKind, String), TextSize), @@ -59241,7 +59706,7 @@ fn __action1289< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action806( + __action808( mode, __0, __temp0, @@ -59250,10 +59715,10 @@ fn __action1289< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1290< +fn __action1302< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, alloc::vec::Vec, TextSize), ) -> Result> { @@ -59265,7 +59730,7 @@ fn __action1290< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action807( + __action809( mode, __0, __1, @@ -59275,14 +59740,14 @@ fn __action1290< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1291< +fn __action1303< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, core::option::Option, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Result> { let __start0 = __1.2; let __end0 = __2.0; @@ -59300,7 +59765,7 @@ fn __action1291< &__end1, ); let __temp1 = (__start1, __temp1, __end1); - __action808( + __action810( mode, __0, __1, @@ -59313,53 +59778,7 @@ fn __action1291< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1292< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Pattern -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action809( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1293< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Pattern -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action810( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1294< +fn __action1304< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59382,10 +59801,10 @@ fn __action1294< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1295< +fn __action1305< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, token::Tok, TextSize), ) -> ast::Pattern { let __start0 = __0.2; @@ -59405,10 +59824,10 @@ fn __action1295< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1296< +fn __action1306< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, token::Tok, TextSize), ) -> ast::Pattern { let __start0 = __0.2; @@ -59428,11 +59847,11 @@ fn __action1296< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1297< +fn __action1307< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), -) -> Result> + __0: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::Pattern { let __start0 = __0.2; let __end0 = __0.2; @@ -59451,11 +59870,11 @@ fn __action1297< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1298< +fn __action1308< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::Pattern { let __start0 = __0.2; let __end0 = __0.2; @@ -59474,11 +59893,11 @@ fn __action1298< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1299< +fn __action1309< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), +) -> Result> { let __start0 = __0.2; let __end0 = __0.2; @@ -59497,7 +59916,7 @@ fn __action1299< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1300< +fn __action1310< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59520,7 +59939,53 @@ fn __action1300< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1301< +fn __action1311< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::Expr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action818( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1312< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::Expr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action819( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1313< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59535,7 +60000,7 @@ fn __action1301< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action819( + __action821( mode, __0, __1, @@ -59545,7 +60010,7 @@ fn __action1301< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1302< +fn __action1314< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59562,7 +60027,7 @@ fn __action1302< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action820( + __action822( mode, __0, __1, @@ -59574,7 +60039,7 @@ fn __action1302< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1303< +fn __action1315< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59590,7 +60055,7 @@ fn __action1303< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action821( + __action823( mode, __0, __1, @@ -59601,7 +60066,7 @@ fn __action1303< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1304< +fn __action1316< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59619,7 +60084,7 @@ fn __action1304< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action822( + __action824( mode, __0, __1, @@ -59632,7 +60097,7 @@ fn __action1304< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1305< +fn __action1317< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59649,7 +60114,7 @@ fn __action1305< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action823( + __action825( mode, __0, __1, @@ -59661,7 +60126,7 @@ fn __action1305< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1306< +fn __action1318< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59681,7 +60146,7 @@ fn __action1306< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action824( + __action826( mode, __0, __1, @@ -59696,7 +60161,7 @@ fn __action1306< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1307< +fn __action1319< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -59715,7 +60180,7 @@ fn __action1307< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action825( + __action827( mode, __0, __1, @@ -59729,63 +60194,13 @@ fn __action1307< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1308< +fn __action1320< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), __2: (TextSize, ast::Pattern, TextSize), ) -> ast::PatternKeyword -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action827( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1309< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action828( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1310< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr { let __start0 = __2.2; let __end0 = __2.2; @@ -59806,7 +60221,30 @@ fn __action1310< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1311< +fn __action1321< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), +) -> ast::Expr +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action830( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1322< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -59822,7 +60260,7 @@ fn __action1311< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action830( + __action831( mode, __0, __1, @@ -59833,12 +60271,12 @@ fn __action1311< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1312< +fn __action1323< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::Identifier, TextSize), ) -> ast::Expr { let __start0 = __2.2; @@ -59849,7 +60287,7 @@ fn __action1312< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action835( + __action832( mode, __0, __1, @@ -59860,38 +60298,16 @@ fn __action1312< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1313< +fn __action1324< >( mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action836( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1314< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), -) -> ast::Stmt -{ - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -59902,21 +60318,21 @@ fn __action1314< mode, __0, __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1315< +fn __action1325< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::Identifier, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action392( mode, &__start0, @@ -59926,19 +60342,18 @@ fn __action1315< __action838( mode, __0, - __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1316< +fn __action1326< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __1: (TextSize, Vec, TextSize), +) -> ast::Stmt { let __start0 = __1.2; let __end0 = __1.2; @@ -59958,14 +60373,15 @@ fn __action1316< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1317< +fn __action1327< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> ast::Pattern + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __1.2; let __temp0 = __action392( mode, &__start0, @@ -59975,18 +60391,19 @@ fn __action1317< __action840( mode, __0, + __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1318< +fn __action1328< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -60006,15 +60423,14 @@ fn __action1318< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1319< +fn __action1329< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, Vec, TextSize), +) -> ast::Pattern { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action392( mode, &__start0, @@ -60022,6 +60438,30 @@ fn __action1319< ); let __temp0 = (__start0, __temp0, __end0); __action842( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1330< +>( + mode: Mode, + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action843( mode, __0, __1, @@ -60031,12 +60471,37 @@ fn __action1319< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1320< +fn __action1331< +>( + mode: Mode, + __0: (TextSize, alloc::vec::Vec, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action844( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1332< >( mode: Mode, __0: (TextSize, ast::ParameterWithDefault, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::ParameterWithDefault { let __start0 = __2.2; @@ -60058,12 +60523,12 @@ fn __action1320< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1321< +fn __action1333< >( mode: Mode, __0: (TextSize, ast::ParameterWithDefault, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::ParameterWithDefault { let __start0 = __2.2; @@ -60085,7 +60550,7 @@ fn __action1321< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1322< +fn __action1334< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60105,7 +60570,7 @@ fn __action1322< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action969( + __action967( mode, __0, __1, @@ -60120,7 +60585,7 @@ fn __action1322< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1323< +fn __action1335< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60139,7 +60604,7 @@ fn __action1323< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action970( + __action968( mode, __0, __1, @@ -60153,7 +60618,7 @@ fn __action1323< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1324< +fn __action1336< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60174,7 +60639,7 @@ fn __action1324< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action971( + __action969( mode, __0, __1, @@ -60190,7 +60655,7 @@ fn __action1324< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1325< +fn __action1337< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60210,7 +60675,7 @@ fn __action1325< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action972( + __action970( mode, __0, __1, @@ -60225,7 +60690,7 @@ fn __action1325< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1326< +fn __action1338< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60243,7 +60708,7 @@ fn __action1326< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action973( + __action971( mode, __0, __1, @@ -60256,7 +60721,7 @@ fn __action1326< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1327< +fn __action1339< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60273,7 +60738,7 @@ fn __action1327< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action974( + __action972( mode, __0, __1, @@ -60285,7 +60750,7 @@ fn __action1327< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1328< +fn __action1340< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60304,7 +60769,7 @@ fn __action1328< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action975( + __action973( mode, __0, __1, @@ -60318,7 +60783,7 @@ fn __action1328< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1329< +fn __action1341< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60336,7 +60801,7 @@ fn __action1329< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action976( + __action974( mode, __0, __1, @@ -60349,7 +60814,7 @@ fn __action1329< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1330< +fn __action1342< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60364,7 +60829,7 @@ fn __action1330< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action977( + __action975( mode, __0, __1, @@ -60374,7 +60839,7 @@ fn __action1330< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1331< +fn __action1343< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60393,7 +60858,7 @@ fn __action1331< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action978( + __action976( mode, __0, __1, @@ -60407,7 +60872,7 @@ fn __action1331< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1332< +fn __action1344< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60425,7 +60890,7 @@ fn __action1332< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action979( + __action977( mode, __0, __1, @@ -60438,7 +60903,7 @@ fn __action1332< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1333< +fn __action1345< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60458,7 +60923,7 @@ fn __action1333< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action980( + __action978( mode, __0, __1, @@ -60473,7 +60938,7 @@ fn __action1333< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1334< +fn __action1346< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60492,7 +60957,7 @@ fn __action1334< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action981( + __action979( mode, __0, __1, @@ -60506,7 +60971,7 @@ fn __action1334< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1335< +fn __action1347< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60523,7 +60988,7 @@ fn __action1335< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action982( + __action980( mode, __0, __1, @@ -60535,7 +61000,7 @@ fn __action1335< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1336< +fn __action1348< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60551,7 +61016,7 @@ fn __action1336< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action983( + __action981( mode, __0, __1, @@ -60562,7 +61027,7 @@ fn __action1336< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1337< +fn __action1349< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60580,7 +61045,7 @@ fn __action1337< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action984( + __action982( mode, __0, __1, @@ -60593,7 +61058,7 @@ fn __action1337< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1338< +fn __action1350< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60610,7 +61075,7 @@ fn __action1338< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action985( + __action983( mode, __0, __1, @@ -60622,7 +61087,7 @@ fn __action1338< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1339< +fn __action1351< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60636,7 +61101,7 @@ fn __action1339< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action986( + __action984( mode, __0, __temp0, @@ -60645,7 +61110,7 @@ fn __action1339< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1340< +fn __action1352< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60662,7 +61127,7 @@ fn __action1340< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action845( + __action847( mode, __0, __1, @@ -60674,7 +61139,7 @@ fn __action1340< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1341< +fn __action1353< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -60690,7 +61155,7 @@ fn __action1341< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action846( + __action848( mode, __0, __1, @@ -60701,7 +61166,7 @@ fn __action1341< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1342< +fn __action1354< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60719,7 +61184,7 @@ fn __action1342< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action945( + __action943( mode, __0, __1, @@ -60732,7 +61197,7 @@ fn __action1342< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1343< +fn __action1355< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60749,7 +61214,7 @@ fn __action1343< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action946( + __action944( mode, __0, __1, @@ -60761,7 +61226,7 @@ fn __action1343< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1344< +fn __action1356< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60780,7 +61245,7 @@ fn __action1344< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action947( + __action945( mode, __0, __1, @@ -60794,7 +61259,7 @@ fn __action1344< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1345< +fn __action1357< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60812,7 +61277,7 @@ fn __action1345< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action948( + __action946( mode, __0, __1, @@ -60825,7 +61290,7 @@ fn __action1345< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1346< +fn __action1358< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60841,7 +61306,7 @@ fn __action1346< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action949( + __action947( mode, __0, __1, @@ -60852,7 +61317,7 @@ fn __action1346< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1347< +fn __action1359< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60867,7 +61332,7 @@ fn __action1347< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action950( + __action948( mode, __0, __1, @@ -60877,7 +61342,7 @@ fn __action1347< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1348< +fn __action1360< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -60885,6 +61350,62 @@ fn __action1348< __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, token::Tok, TextSize), ) -> Result> +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action949( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1361< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action950( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1362< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::Parameter, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, Option>, TextSize), +) -> Result> { let __start0 = __3.2; let __end0 = __3.2; @@ -60906,12 +61427,12 @@ fn __action1348< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1349< +fn __action1363< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, Option>, TextSize), ) -> Result> { let __start0 = __2.2; @@ -60933,63 +61454,7 @@ fn __action1349< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1350< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Parameter, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action953( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1351< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action954( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1352< +fn __action1364< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61007,7 +61472,7 @@ fn __action1352< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action955( + __action953( mode, __0, __1, @@ -61020,7 +61485,7 @@ fn __action1352< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1353< +fn __action1365< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61037,7 +61502,7 @@ fn __action1353< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action956( + __action954( mode, __0, __1, @@ -61049,7 +61514,7 @@ fn __action1353< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1354< +fn __action1366< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61064,7 +61529,7 @@ fn __action1354< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action957( + __action955( mode, __0, __1, @@ -61074,7 +61539,7 @@ fn __action1354< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1355< +fn __action1367< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61088,7 +61553,7 @@ fn __action1355< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action958( + __action956( mode, __0, __temp0, @@ -61097,7 +61562,7 @@ fn __action1355< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1356< +fn __action1368< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61113,7 +61578,7 @@ fn __action1356< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action959( + __action957( mode, __0, __1, @@ -61124,7 +61589,7 @@ fn __action1356< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1357< +fn __action1369< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61139,7 +61604,7 @@ fn __action1357< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action960( + __action958( mode, __0, __1, @@ -61149,7 +61614,7 @@ fn __action1357< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1358< +fn __action1370< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -61164,7 +61629,7 @@ fn __action1358< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action849( + __action851( mode, __0, __1, @@ -61174,7 +61639,7 @@ fn __action1358< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1359< +fn __action1371< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -61188,7 +61653,7 @@ fn __action1359< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action850( + __action852( mode, __0, __temp0, @@ -61197,7 +61662,7 @@ fn __action1359< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1360< +fn __action1372< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61217,7 +61682,7 @@ fn __action1360< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1029( + __action1027( mode, __0, __1, @@ -61232,7 +61697,7 @@ fn __action1360< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1361< +fn __action1373< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61251,7 +61716,7 @@ fn __action1361< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1030( + __action1028( mode, __0, __1, @@ -61265,7 +61730,7 @@ fn __action1361< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1362< +fn __action1374< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61286,7 +61751,7 @@ fn __action1362< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1031( + __action1029( mode, __0, __1, @@ -61302,7 +61767,7 @@ fn __action1362< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1363< +fn __action1375< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61322,7 +61787,7 @@ fn __action1363< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1032( + __action1030( mode, __0, __1, @@ -61337,7 +61802,7 @@ fn __action1363< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1364< +fn __action1376< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61355,7 +61820,7 @@ fn __action1364< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1033( + __action1031( mode, __0, __1, @@ -61368,7 +61833,7 @@ fn __action1364< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1365< +fn __action1377< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61385,7 +61850,7 @@ fn __action1365< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1034( + __action1032( mode, __0, __1, @@ -61397,7 +61862,7 @@ fn __action1365< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1366< +fn __action1378< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61416,7 +61881,7 @@ fn __action1366< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1035( + __action1033( mode, __0, __1, @@ -61430,7 +61895,7 @@ fn __action1366< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1367< +fn __action1379< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61448,7 +61913,7 @@ fn __action1367< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1036( + __action1034( mode, __0, __1, @@ -61461,7 +61926,7 @@ fn __action1367< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1368< +fn __action1380< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61476,7 +61941,7 @@ fn __action1368< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1037( + __action1035( mode, __0, __1, @@ -61486,7 +61951,7 @@ fn __action1368< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1369< +fn __action1381< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61505,7 +61970,7 @@ fn __action1369< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1038( + __action1036( mode, __0, __1, @@ -61519,7 +61984,7 @@ fn __action1369< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1370< +fn __action1382< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61537,7 +62002,7 @@ fn __action1370< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1039( + __action1037( mode, __0, __1, @@ -61550,7 +62015,7 @@ fn __action1370< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1371< +fn __action1383< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61570,7 +62035,7 @@ fn __action1371< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1040( + __action1038( mode, __0, __1, @@ -61585,7 +62050,7 @@ fn __action1371< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1372< +fn __action1384< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61604,7 +62069,7 @@ fn __action1372< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1041( + __action1039( mode, __0, __1, @@ -61618,7 +62083,7 @@ fn __action1372< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1373< +fn __action1385< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61635,7 +62100,7 @@ fn __action1373< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1042( + __action1040( mode, __0, __1, @@ -61647,7 +62112,7 @@ fn __action1373< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1374< +fn __action1386< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61663,7 +62128,7 @@ fn __action1374< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1043( + __action1041( mode, __0, __1, @@ -61674,7 +62139,7 @@ fn __action1374< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1375< +fn __action1387< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61692,7 +62157,7 @@ fn __action1375< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1044( + __action1042( mode, __0, __1, @@ -61705,7 +62170,7 @@ fn __action1375< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1376< +fn __action1388< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61722,7 +62187,7 @@ fn __action1376< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1045( + __action1043( mode, __0, __1, @@ -61734,7 +62199,7 @@ fn __action1376< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1377< +fn __action1389< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61748,7 +62213,7 @@ fn __action1377< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1046( + __action1044( mode, __0, __temp0, @@ -61757,7 +62222,7 @@ fn __action1377< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1378< +fn __action1390< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61774,7 +62239,7 @@ fn __action1378< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action853( + __action855( mode, __0, __1, @@ -61786,7 +62251,7 @@ fn __action1378< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1379< +fn __action1391< >( mode: Mode, __0: (TextSize, (Vec, Vec), TextSize), @@ -61802,7 +62267,7 @@ fn __action1379< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action854( + __action856( mode, __0, __1, @@ -61813,7 +62278,7 @@ fn __action1379< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1380< +fn __action1392< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61831,7 +62296,7 @@ fn __action1380< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1005( + __action1003( mode, __0, __1, @@ -61844,7 +62309,7 @@ fn __action1380< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1381< +fn __action1393< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61861,7 +62326,7 @@ fn __action1381< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1006( + __action1004( mode, __0, __1, @@ -61873,7 +62338,7 @@ fn __action1381< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1382< +fn __action1394< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61892,7 +62357,7 @@ fn __action1382< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1007( + __action1005( mode, __0, __1, @@ -61906,7 +62371,7 @@ fn __action1382< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1383< +fn __action1395< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61924,7 +62389,7 @@ fn __action1383< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1008( + __action1006( mode, __0, __1, @@ -61937,7 +62402,7 @@ fn __action1383< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1384< +fn __action1396< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61953,7 +62418,7 @@ fn __action1384< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1009( + __action1007( mode, __0, __1, @@ -61964,7 +62429,7 @@ fn __action1384< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1385< +fn __action1397< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61979,7 +62444,7 @@ fn __action1385< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1010( + __action1008( mode, __0, __1, @@ -61989,7 +62454,7 @@ fn __action1385< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1386< +fn __action1398< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -61997,6 +62462,62 @@ fn __action1386< __2: (TextSize, alloc::vec::Vec, TextSize), __3: (TextSize, token::Tok, TextSize), ) -> Result> +{ + let __start0 = __3.2; + let __end0 = __3.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1009( + mode, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1399< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1010( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1400< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::Parameter, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, Option>, TextSize), +) -> Result> { let __start0 = __3.2; let __end0 = __3.2; @@ -62018,12 +62539,12 @@ fn __action1386< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1387< +fn __action1401< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, Option>, TextSize), ) -> Result> { let __start0 = __2.2; @@ -62045,63 +62566,7 @@ fn __action1387< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1388< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Parameter, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1013( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1389< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1014( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1390< +fn __action1402< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62119,7 +62584,7 @@ fn __action1390< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1015( + __action1013( mode, __0, __1, @@ -62132,7 +62597,7 @@ fn __action1390< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1391< +fn __action1403< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62149,7 +62614,7 @@ fn __action1391< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1016( + __action1014( mode, __0, __1, @@ -62161,7 +62626,7 @@ fn __action1391< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1392< +fn __action1404< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62176,7 +62641,7 @@ fn __action1392< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1017( + __action1015( mode, __0, __1, @@ -62186,7 +62651,7 @@ fn __action1392< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1393< +fn __action1405< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62200,7 +62665,7 @@ fn __action1393< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1018( + __action1016( mode, __0, __temp0, @@ -62209,7 +62674,7 @@ fn __action1393< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1394< +fn __action1406< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62225,7 +62690,7 @@ fn __action1394< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1019( + __action1017( mode, __0, __1, @@ -62236,7 +62701,7 @@ fn __action1394< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1395< +fn __action1407< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62251,7 +62716,7 @@ fn __action1395< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1020( + __action1018( mode, __0, __1, @@ -62261,7 +62726,7 @@ fn __action1395< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1396< +fn __action1408< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -62276,7 +62741,7 @@ fn __action1396< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action857( + __action859( mode, __0, __1, @@ -62286,7 +62751,7 @@ fn __action1396< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1397< +fn __action1409< >( mode: Mode, __0: (TextSize, Option>, TextSize), @@ -62300,7 +62765,7 @@ fn __action1397< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action858( + __action860( mode, __0, __temp0, @@ -62309,7 +62774,7 @@ fn __action1397< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1398< +fn __action1410< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62325,7 +62790,7 @@ fn __action1398< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action871( + __action873( mode, __0, __1, @@ -62336,7 +62801,7 @@ fn __action1398< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1399< +fn __action1411< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62350,7 +62815,7 @@ fn __action1399< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action872( + __action874( mode, __0, __temp0, @@ -62359,7 +62824,7 @@ fn __action1399< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1400< +fn __action1412< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62378,7 +62843,7 @@ fn __action1400< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action873( + __action875( mode, __0, __1, @@ -62392,7 +62857,7 @@ fn __action1400< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1401< +fn __action1413< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62410,7 +62875,7 @@ fn __action1401< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action874( + __action876( mode, __0, __1, @@ -62423,7 +62888,7 @@ fn __action1401< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1402< +fn __action1414< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62431,62 +62896,6 @@ fn __action1402< __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), ) -> ast::PatternArguments -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action875( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1403< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::PatternArguments -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action876( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1404< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::PatternArguments { let __start0 = __3.2; let __end0 = __3.2; @@ -62508,11 +62917,11 @@ fn __action1404< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1405< +fn __action1415< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), + __1: (TextSize, Vec, TextSize), __2: (TextSize, token::Tok, TextSize), ) -> ast::PatternArguments { @@ -62535,15 +62944,17 @@ fn __action1405< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1406< +fn __action1416< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), ) -> ast::PatternArguments { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -62554,21 +62965,24 @@ fn __action1406< mode, __0, __1, + __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1407< +fn __action1417< >( mode: Mode, - __0: (TextSize, ast::Pattern, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Pattern + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::PatternArguments { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -62579,18 +62993,19 @@ fn __action1407< mode, __0, __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1408< +fn __action1418< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> ast::Pattern +) -> ast::PatternArguments { let __start0 = __1.2; let __end0 = __1.2; @@ -62610,7 +63025,57 @@ fn __action1408< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1409< +fn __action1419< +>( + mode: Mode, + __0: (TextSize, ast::Pattern, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::Pattern +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action882( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1420< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::Pattern +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action883( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1421< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -62624,59 +63089,32 @@ fn __action1409< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action882( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1410< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action883( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1411< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); __action884( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1422< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action885( mode, __0, __1, @@ -62687,7 +63125,34 @@ fn __action1411< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1412< +fn __action1423< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action886( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1424< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62701,7 +63166,7 @@ fn __action1412< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action885( + __action887( mode, __0, __temp0, @@ -62710,13 +63175,13 @@ fn __action1412< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1413< +fn __action1425< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __3.2; @@ -62727,7 +63192,7 @@ fn __action1413< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1116( + __action1114( mode, __0, __1, @@ -62739,11 +63204,11 @@ fn __action1413< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1414< +fn __action1426< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __1.2; @@ -62754,7 +63219,7 @@ fn __action1414< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1117( + __action1115( mode, __0, __1, @@ -62764,7 +63229,7 @@ fn __action1414< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1415< +fn __action1427< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62780,7 +63245,7 @@ fn __action1415< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action887( + __action889( mode, __0, __1, @@ -62791,7 +63256,7 @@ fn __action1415< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1416< +fn __action1428< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62806,7 +63271,7 @@ fn __action1416< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action888( + __action890( mode, __0, __1, @@ -62816,7 +63281,7 @@ fn __action1416< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1417< +fn __action1429< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -62824,66 +63289,6 @@ fn __action1417< __2: (TextSize, token::Tok, TextSize), __3: (TextSize, token::Tok, TextSize), ) -> ast::Pattern -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action889( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1418< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), - __2: (TextSize, ast::Pattern, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> ast::Pattern -{ - let __start0 = __4.2; - let __end0 = __4.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action890( - mode, - __0, - __1, - __2, - __3, - __4, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1419< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), - __2: (TextSize, ast::Pattern, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> ast::Pattern { let __start0 = __3.2; let __end0 = __3.2; @@ -62905,16 +63310,18 @@ fn __action1419< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1420< +fn __action1430< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, ast::Pattern, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), ) -> ast::Pattern { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __4.2; + let __end0 = __4.2; let __temp0 = __action392( mode, &__start0, @@ -62926,22 +63333,25 @@ fn __action1420< __0, __1, __2, + __3, + __4, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1421< +fn __action1431< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), + __2: (TextSize, ast::Pattern, TextSize), + __3: (TextSize, token::Tok, TextSize), +) -> ast::Pattern { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -62953,19 +63363,20 @@ fn __action1421< __0, __1, __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1422< +fn __action1432< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::Pattern { let __start0 = __2.2; let __end0 = __2.2; @@ -62986,15 +63397,69 @@ fn __action1422< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1423< +fn __action1433< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, ast::Operator, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action895( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1434< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, ast::Operator, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action896( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1435< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Comprehension { let __start0 = __5.2; @@ -63005,7 +63470,7 @@ fn __action1423< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action895( + __action897( mode, __0, __1, @@ -63019,14 +63484,14 @@ fn __action1423< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1424< +fn __action1436< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Comprehension { let __start0 = __4.2; @@ -63037,7 +63502,7 @@ fn __action1424< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action896( + __action898( mode, __0, __1, @@ -63050,12 +63515,12 @@ fn __action1424< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1425< +fn __action1437< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -63065,7 +63530,7 @@ fn __action1425< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action898( + __action900( mode, __0, __1, @@ -63075,7 +63540,7 @@ fn __action1425< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1426< +fn __action1438< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63090,7 +63555,7 @@ fn __action1426< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action899( + __action901( mode, __0, __1, @@ -63100,12 +63565,12 @@ fn __action1426< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1427< +fn __action1439< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Parameter { let __start0 = __2.2; @@ -63116,7 +63581,7 @@ fn __action1427< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1081( + __action1079( mode, __0, __1, @@ -63127,7 +63592,7 @@ fn __action1427< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1428< +fn __action1440< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -63141,7 +63606,7 @@ fn __action1428< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1082( + __action1080( mode, __0, __temp0, @@ -63150,63 +63615,11 @@ fn __action1428< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1429< +fn __action1441< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), ) -> ast::Parameter -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action901( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1430< ->( - mode: Mode, - __0: (TextSize, core::option::Option, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option, TextSize), - __3: (TextSize, core::option::Option>, TextSize), -) -> ast::Expr -{ - let __start0 = __3.2; - let __end0 = __3.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action902( - mode, - __0, - __1, - __2, - __3, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1431< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> ast::Expr { let __start0 = __0.2; let __end0 = __0.2; @@ -63225,15 +63638,17 @@ fn __action1431< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1432< +fn __action1442< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, core::option::Option, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr + __2: (TextSize, core::option::Option, TextSize), + __3: (TextSize, core::option::Option>, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __1.2; - let __end0 = __1.2; + let __start0 = __3.2; + let __end0 = __3.2; let __temp0 = __action392( mode, &__start0, @@ -63244,18 +63659,20 @@ fn __action1432< mode, __0, __1, + __2, + __3, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1433< +fn __action1443< >( mode: Mode, - __0: (TextSize, Vec, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __1.2; let __end0 = __1.2; @@ -63275,14 +63692,15 @@ fn __action1433< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1434< +fn __action1444< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> ast::Expr + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __1.2; + let __end0 = __1.2; let __temp0 = __action392( mode, &__start0, @@ -63292,22 +63710,21 @@ fn __action1434< __action906( mode, __0, + __1, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1435< +fn __action1445< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, Vec, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __2.2; - let __end0 = __2.2; + let __start0 = __0.2; + let __end0 = __0.2; let __temp0 = __action392( mode, &__start0, @@ -63317,21 +63734,19 @@ fn __action1435< __action907( mode, __0, - __1, - __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1436< +fn __action1446< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -63352,18 +63767,16 @@ fn __action1436< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1437< +fn __action1447< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, ast::Operator, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __4.2; - let __end0 = __4.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, @@ -63375,23 +63788,21 @@ fn __action1437< __0, __1, __2, - __3, - __4, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1438< +fn __action1448< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __4: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __4.2; let __end0 = __4.2; @@ -63414,7 +63825,38 @@ fn __action1438< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1439< +fn __action1449< +>( + mode: Mode, + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __4.2; + let __end0 = __4.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action911( + mode, + __0, + __1, + __2, + __3, + __4, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1450< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63429,7 +63871,7 @@ fn __action1439< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action911( + __action912( mode, __0, __1, @@ -63439,11 +63881,11 @@ fn __action1439< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1440< +fn __action1451< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Mod { let __start0 = __1.2; @@ -63454,7 +63896,7 @@ fn __action1440< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1087( + __action1085( mode, __0, __1, @@ -63464,11 +63906,11 @@ fn __action1440< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1441< +fn __action1452< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Mod { @@ -63480,7 +63922,7 @@ fn __action1441< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1088( + __action1086( mode, __0, __1, @@ -63491,7 +63933,7 @@ fn __action1441< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1442< +fn __action1453< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63514,6 +63956,79 @@ fn __action1442< &__end0, ); let __temp0 = (__start0, __temp0, __end0); + __action1105( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + __7, + __8, + __9, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1454< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Suite, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Suite, TextSize), +) -> ast::Stmt +{ + let __start0 = __6.2; + let __end0 = __6.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1106( + mode, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1455< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Suite, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Suite, TextSize), +) -> ast::Stmt +{ + let __start0 = __6.2; + let __end0 = __6.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); __action1107( mode, __0, @@ -63523,86 +64038,13 @@ fn __action1442< __4, __5, __6, - __7, - __8, - __9, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1443< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Suite, TextSize), -) -> ast::Stmt -{ - let __start0 = __6.2; - let __end0 = __6.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1108( - mode, - __0, - __1, - __2, - __3, - __4, - __5, - __6, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1444< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Suite, TextSize), -) -> ast::Stmt -{ - let __start0 = __6.2; - let __end0 = __6.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1109( - mode, - __0, - __1, - __2, - __3, - __4, - __5, - __6, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1445< +fn __action1456< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63619,7 +64061,7 @@ fn __action1445< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1110( + __action1108( mode, __0, __1, @@ -63631,7 +64073,7 @@ fn __action1445< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1446< +fn __action1457< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63654,7 +64096,7 @@ fn __action1446< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1111( + __action1109( mode, __0, __1, @@ -63672,7 +64114,7 @@ fn __action1446< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1447< +fn __action1458< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63692,7 +64134,7 @@ fn __action1447< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1112( + __action1110( mode, __0, __1, @@ -63707,7 +64149,7 @@ fn __action1447< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1448< +fn __action1459< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63727,7 +64169,7 @@ fn __action1448< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1113( + __action1111( mode, __0, __1, @@ -63742,7 +64184,7 @@ fn __action1448< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1449< +fn __action1460< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63759,7 +64201,7 @@ fn __action1449< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1114( + __action1112( mode, __0, __1, @@ -63771,7 +64213,7 @@ fn __action1449< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1450< +fn __action1461< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -63785,7 +64227,7 @@ fn __action1450< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action916( + __action917( mode, __0, __temp0, @@ -63794,14 +64236,14 @@ fn __action1450< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1451< +fn __action1462< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Expr, TextSize), __2: (TextSize, core::option::Option, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __4.2; @@ -63812,7 +64254,7 @@ fn __action1451< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action917( + __action918( mode, __0, __1, @@ -63825,12 +64267,12 @@ fn __action1451< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1452< +fn __action1463< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::TypeParam { let __start0 = __2.2; @@ -63841,7 +64283,7 @@ fn __action1452< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1076( + __action1074( mode, __0, __1, @@ -63852,7 +64294,7 @@ fn __action1452< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1453< +fn __action1464< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -63866,7 +64308,7 @@ fn __action1453< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1077( + __action1075( mode, __0, __temp0, @@ -63875,32 +64317,7 @@ fn __action1453< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1454< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Identifier, TextSize), -) -> ast::TypeParam -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action919( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1455< +fn __action1465< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63925,7 +64342,32 @@ fn __action1455< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1456< +fn __action1466< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::Identifier, TextSize), +) -> ast::TypeParam +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action921( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1467< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63942,7 +64384,7 @@ fn __action1456< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action921( + __action922( mode, __0, __1, @@ -63954,7 +64396,7 @@ fn __action1456< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1457< +fn __action1468< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -63970,7 +64412,7 @@ fn __action1457< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action922( + __action923( mode, __0, __1, @@ -63981,12 +64423,12 @@ fn __action1457< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1458< +fn __action1469< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::ParameterWithDefault { let __start0 = __2.2; @@ -63997,7 +64439,7 @@ fn __action1458< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1078( + __action1076( mode, __0, __1, @@ -64008,7 +64450,7 @@ fn __action1458< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1459< +fn __action1470< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -64022,7 +64464,7 @@ fn __action1459< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1079( + __action1077( mode, __0, __temp0, @@ -64031,34 +64473,11 @@ fn __action1459< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1460< +fn __action1471< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), ) -> ast::ParameterWithDefault -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action924( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1461< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> ast::Pattern { let __start0 = __0.2; let __end0 = __0.2; @@ -64077,11 +64496,11 @@ fn __action1461< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1462< +fn __action1472< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), -) -> ast::WithItem +) -> ast::Pattern { let __start0 = __0.2; let __end0 = __0.2; @@ -64091,7 +64510,7 @@ fn __action1462< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action927( + __action926( mode, __0, __temp0, @@ -64100,35 +64519,12 @@ fn __action1462< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1463< +fn __action1473< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> ast::WithItem -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action928( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1464< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::WithItem { let __start0 = __2.2; @@ -64139,7 +64535,7 @@ fn __action1464< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action929( + __action928( mode, __0, __1, @@ -64150,36 +64546,40 @@ fn __action1464< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1465< +fn __action1474< >( mode: Mode, - __0: (TextSize, Vec, TextSize), -) -> Vec + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { - let __start0 = __0.2; - let __end0 = __0.2; + let __start0 = __2.2; + let __end0 = __2.2; let __temp0 = __action392( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action930( + __action931( mode, __0, + __1, + __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1466< +fn __action1475< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -64189,24 +64589,49 @@ fn __action1466< &__end0, ); let __temp0 = (__start0, __temp0, __end0); + __action932( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1476< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, core::option::Option, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.2; + let __end0 = __1.2; + let __temp0 = __action392( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); __action933( mode, __0, __1, - __2, __temp0, ) } #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1467< +fn __action1477< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __2.2; let __end0 = __2.2; @@ -64225,399 +64650,9 @@ fn __action1467< ) } -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1468< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, core::option::Option, TextSize), -) -> ast::Expr -{ - let __start0 = __1.2; - let __end0 = __1.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action935( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1469< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action392( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action936( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1470< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action1465( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action301( - mode, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1471< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action1465( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action641( - mode, - __0, - __temp0, - __2, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1472< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action1465( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action642( - mode, - __0, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1473< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> core::option::Option> -{ - let __start0 = __0.0; - let __end0 = __1.2; - let __temp0 = __action1470( - mode, - __0, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action299( - mode, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1474< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::WithItem, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1473( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1062( - mode, - __0, - __temp0, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1475< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::WithItem, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action300( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1062( - mode, - __0, - __temp0, - __1, - __2, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1476< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::WithItem, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1473( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1063( - mode, - __0, - __temp0, - __3, - __4, - __5, - __6, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1477< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::WithItem, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action300( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1063( - mode, - __0, - __temp0, - __1, - __2, - __3, - __4, - ) -} - #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1478< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::WithItem, TextSize), - __4: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1473( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1064( - mode, - __0, - __temp0, - __3, - __4, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1479< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::WithItem, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action300( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1064( - mode, - __0, - __temp0, - __1, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1480< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::WithItem, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), - __5: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action1473( - mode, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1065( - mode, - __0, - __temp0, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1481< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::WithItem, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), - __3: (TextSize, token::Tok, TextSize), -) -> Vec -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action300( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1065( - mode, - __0, - __temp0, - __1, - __2, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1482< >( mode: Mode, __0: (TextSize, (String, StringKind, bool), TextSize), @@ -64625,7 +64660,7 @@ fn __action1482< { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action1176( + let __temp0 = __action1186( mode, __0, ); @@ -64638,7 +64673,7 @@ fn __action1482< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1483< +fn __action1479< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(TextSize, (String, StringKind, bool), TextSize)>, TextSize), @@ -64647,7 +64682,7 @@ fn __action1483< { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action1176( + let __temp0 = __action1186( mode, __1, ); @@ -64661,12 +64696,12 @@ fn __action1483< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1484< +fn __action1480< >( mode: Mode, __0: (TextSize, ast::CmpOp, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec<(ast::CmpOp, ast::Expr)> + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)> { let __start0 = __0.0; let __end0 = __1.2; @@ -64684,13 +64719,13 @@ fn __action1484< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1485< +fn __action1481< >( mode: Mode, - __0: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::Expr)>, TextSize), + __0: (TextSize, alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)>, TextSize), __1: (TextSize, ast::CmpOp, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> alloc::vec::Vec<(ast::CmpOp, ast::Expr)> + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> alloc::vec::Vec<(ast::CmpOp, ast::ParenthesizedExpr)> { let __start0 = __1.0; let __end0 = __2.2; @@ -64709,7 +64744,7 @@ fn __action1485< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1486< +fn __action1482< >( mode: Mode, __0: (TextSize, ast::Expr, TextSize), @@ -64730,7 +64765,7 @@ fn __action1486< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1487< +fn __action1483< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64742,12 +64777,12 @@ fn __action1487< { let __start0 = __2.0; let __end0 = __2.2; - let __temp0 = __action1486( + let __temp0 = __action1482( mode, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action826( + __action828( mode, __0, __1, @@ -64759,7 +64794,7 @@ fn __action1487< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1488< +fn __action1484< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64776,7 +64811,7 @@ fn __action1488< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action826( + __action828( mode, __0, __1, @@ -64788,7 +64823,7 @@ fn __action1488< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1489< +fn __action1485< >( mode: Mode, __0: (TextSize, ast::Parameters, TextSize), @@ -64809,7 +64844,7 @@ fn __action1489< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1490< +fn __action1486< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64819,12 +64854,12 @@ fn __action1490< { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action1489( + let __temp0 = __action1485( mode, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1398( + __action1410( mode, __0, __temp0, @@ -64834,7 +64869,7 @@ fn __action1490< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1491< +fn __action1487< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -64849,7 +64884,7 @@ fn __action1491< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1398( + __action1410( mode, __0, __temp0, @@ -64859,7 +64894,7 @@ fn __action1491< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1492< +fn __action1488< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -64878,7 +64913,7 @@ fn __action1492< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action755( + __action757( mode, __0, __1, @@ -64892,7 +64927,7 @@ fn __action1492< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1493< +fn __action1489< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -64911,7 +64946,7 @@ fn __action1493< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action755( + __action757( mode, __0, __1, @@ -64925,10 +64960,10 @@ fn __action1493< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1494< +fn __action1490< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __0.2; @@ -64939,7 +64974,7 @@ fn __action1494< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1259( + __action1271( mode, __0, __temp0, @@ -64948,11 +64983,11 @@ fn __action1494< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1495< +fn __action1491< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Stmt { let __start0 = __1.0; @@ -64962,7 +64997,7 @@ fn __action1495< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1259( + __action1271( mode, __0, __temp0, @@ -64971,13 +65006,13 @@ fn __action1495< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1496< +fn __action1492< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __3.0; @@ -64987,7 +65022,7 @@ fn __action1496< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1261( + __action1273( mode, __0, __1, @@ -64998,12 +65033,12 @@ fn __action1496< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1497< +fn __action1493< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __2.2; @@ -65014,7 +65049,7 @@ fn __action1497< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1261( + __action1273( mode, __0, __1, @@ -65025,7 +65060,7 @@ fn __action1497< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1498< +fn __action1494< >( mode: Mode, __0: (TextSize, (Option<(TextSize, TextSize, Option)>, ast::Expr), TextSize), @@ -65038,7 +65073,7 @@ fn __action1498< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1131( + __action1129( mode, __temp0, ) @@ -65046,7 +65081,7 @@ fn __action1498< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1499< +fn __action1495< >( mode: Mode, __lookbehind: &TextSize, @@ -65061,7 +65096,7 @@ fn __action1499< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1131( + __action1129( mode, __temp0, ) @@ -65069,7 +65104,7 @@ fn __action1499< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1500< +fn __action1496< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize), @@ -65083,7 +65118,7 @@ fn __action1500< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1132( + __action1130( mode, __0, __temp0, @@ -65092,7 +65127,7 @@ fn __action1500< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1501< +fn __action1497< >( mode: Mode, __0: (TextSize, alloc::vec::Vec<(Option<(TextSize, TextSize, Option)>, ast::Expr)>, TextSize), @@ -65106,7 +65141,7 @@ fn __action1501< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1132( + __action1130( mode, __0, __temp0, @@ -65115,7 +65150,7 @@ fn __action1501< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1502< +fn __action1498< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65125,12 +65160,12 @@ fn __action1502< { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action1498( + let __temp0 = __action1494( mode, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1182( + __action1192( mode, __0, __temp0, @@ -65140,7 +65175,7 @@ fn __action1502< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1503< +fn __action1499< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65149,13 +65184,13 @@ fn __action1503< { let __start0 = __0.2; let __end0 = __1.0; - let __temp0 = __action1499( + let __temp0 = __action1495( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1182( + __action1192( mode, __0, __temp0, @@ -65165,7 +65200,7 @@ fn __action1503< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1504< +fn __action1500< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65176,13 +65211,13 @@ fn __action1504< { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1500( + let __temp0 = __action1496( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1182( + __action1192( mode, __0, __temp0, @@ -65192,7 +65227,7 @@ fn __action1504< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1505< +fn __action1501< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65202,12 +65237,12 @@ fn __action1505< { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action1501( + let __temp0 = __action1497( mode, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1182( + __action1192( mode, __0, __temp0, @@ -65217,7 +65252,7 @@ fn __action1505< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1506< +fn __action1502< >( mode: Mode, __0: (TextSize, ast::Pattern, TextSize), @@ -65230,7 +65265,7 @@ fn __action1506< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1154( + __action1152( mode, __temp0, ) @@ -65238,7 +65273,7 @@ fn __action1506< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1507< +fn __action1503< >( mode: Mode, __lookbehind: &TextSize, @@ -65253,7 +65288,7 @@ fn __action1507< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1154( + __action1152( mode, __temp0, ) @@ -65261,7 +65296,7 @@ fn __action1507< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1508< +fn __action1504< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65275,7 +65310,7 @@ fn __action1508< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1155( + __action1153( mode, __0, __temp0, @@ -65284,7 +65319,7 @@ fn __action1508< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1509< +fn __action1505< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65298,7 +65333,7 @@ fn __action1509< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1155( + __action1153( mode, __0, __temp0, @@ -65307,7 +65342,7 @@ fn __action1509< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1510< +fn __action1506< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65317,12 +65352,12 @@ fn __action1510< { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action1506( + let __temp0 = __action1502( mode, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1420( + __action1432( mode, __0, __temp0, @@ -65332,7 +65367,7 @@ fn __action1510< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1511< +fn __action1507< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65341,13 +65376,13 @@ fn __action1511< { let __start0 = __0.2; let __end0 = __1.0; - let __temp0 = __action1507( + let __temp0 = __action1503( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1420( + __action1432( mode, __0, __temp0, @@ -65357,7 +65392,7 @@ fn __action1511< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1512< +fn __action1508< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65368,13 +65403,13 @@ fn __action1512< { let __start0 = __1.0; let __end0 = __2.2; - let __temp0 = __action1508( + let __temp0 = __action1504( mode, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1420( + __action1432( mode, __0, __temp0, @@ -65384,7 +65419,7 @@ fn __action1512< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1513< +fn __action1509< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65394,12 +65429,12 @@ fn __action1513< { let __start0 = __1.0; let __end0 = __1.2; - let __temp0 = __action1509( + let __temp0 = __action1505( mode, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1420( + __action1432( mode, __0, __temp0, @@ -65409,10 +65444,10 @@ fn __action1513< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1514< +fn __action1510< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, Vec, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { @@ -65423,7 +65458,7 @@ fn __action1514< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1268( + __action1280( mode, __0, __temp0, @@ -65432,10 +65467,10 @@ fn __action1514< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1515< +fn __action1511< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> (Option<(TextSize, TextSize, Option)>, ast::Expr) { let __start0 = __0.2; @@ -65446,7 +65481,7 @@ fn __action1515< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1268( + __action1280( mode, __0, __temp0, @@ -65455,14 +65490,14 @@ fn __action1515< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1516< +fn __action1512< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Comprehension { let __start0 = __4.2; @@ -65473,7 +65508,7 @@ fn __action1516< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1423( + __action1435( mode, __0, __1, @@ -65486,15 +65521,15 @@ fn __action1516< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1517< +fn __action1513< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Comprehension { let __start0 = __5.0; @@ -65504,7 +65539,7 @@ fn __action1517< __5, ); let __temp0 = (__start0, __temp0, __end0); - __action1423( + __action1435( mode, __0, __1, @@ -65517,13 +65552,13 @@ fn __action1517< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1518< +fn __action1514< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Comprehension { let __start0 = __3.2; @@ -65534,7 +65569,7 @@ fn __action1518< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1424( + __action1436( mode, __0, __1, @@ -65546,14 +65581,14 @@ fn __action1518< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1519< +fn __action1515< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), - __4: (TextSize, alloc::vec::Vec, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), + __4: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Comprehension { let __start0 = __4.0; @@ -65563,7 +65598,7 @@ fn __action1519< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action1424( + __action1436( mode, __0, __1, @@ -65575,7 +65610,7 @@ fn __action1519< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1520< +fn __action1516< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65594,7 +65629,7 @@ fn __action1520< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1492( + __action1488( mode, __temp0, __0, @@ -65608,7 +65643,7 @@ fn __action1520< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1521< +fn __action1517< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65627,7 +65662,7 @@ fn __action1521< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1492( + __action1488( mode, __temp0, __1, @@ -65641,7 +65676,7 @@ fn __action1521< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1522< +fn __action1518< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65659,7 +65694,7 @@ fn __action1522< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1493( + __action1489( mode, __temp0, __0, @@ -65672,7 +65707,7 @@ fn __action1522< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1523< +fn __action1519< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65690,7 +65725,7 @@ fn __action1523< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1493( + __action1489( mode, __temp0, __1, @@ -65703,7 +65738,7 @@ fn __action1523< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1524< +fn __action1520< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65712,7 +65747,7 @@ fn __action1524< __3: (TextSize, core::option::Option, TextSize), __4: (TextSize, ast::Parameters, TextSize), __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Expr, TextSize), + __6: (TextSize, ast::ParenthesizedExpr, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -65725,7 +65760,7 @@ fn __action1524< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1067( + __action1065( mode, __temp0, __0, @@ -65742,7 +65777,7 @@ fn __action1524< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1525< +fn __action1521< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65752,7 +65787,7 @@ fn __action1525< __4: (TextSize, core::option::Option, TextSize), __5: (TextSize, ast::Parameters, TextSize), __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, ast::Expr, TextSize), + __7: (TextSize, ast::ParenthesizedExpr, TextSize), __8: (TextSize, token::Tok, TextSize), __9: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -65764,7 +65799,7 @@ fn __action1525< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1067( + __action1065( mode, __temp0, __1, @@ -65781,7 +65816,7 @@ fn __action1525< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1526< +fn __action1522< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65801,7 +65836,7 @@ fn __action1526< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1068( + __action1066( mode, __temp0, __0, @@ -65816,7 +65851,7 @@ fn __action1526< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1527< +fn __action1523< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65836,7 +65871,7 @@ fn __action1527< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1068( + __action1066( mode, __temp0, __1, @@ -65851,7 +65886,7 @@ fn __action1527< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1528< +fn __action1524< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65859,7 +65894,7 @@ fn __action1528< __2: (TextSize, core::option::Option, TextSize), __3: (TextSize, ast::Parameters, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, ast::Expr, TextSize), + __5: (TextSize, ast::ParenthesizedExpr, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -65872,7 +65907,7 @@ fn __action1528< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1069( + __action1067( mode, __temp0, __0, @@ -65888,7 +65923,7 @@ fn __action1528< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1529< +fn __action1525< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65897,7 +65932,7 @@ fn __action1529< __3: (TextSize, core::option::Option, TextSize), __4: (TextSize, ast::Parameters, TextSize), __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Expr, TextSize), + __6: (TextSize, ast::ParenthesizedExpr, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -65909,7 +65944,7 @@ fn __action1529< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1069( + __action1067( mode, __temp0, __1, @@ -65925,7 +65960,7 @@ fn __action1529< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1530< +fn __action1526< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -65944,7 +65979,7 @@ fn __action1530< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1070( + __action1068( mode, __temp0, __0, @@ -65958,7 +65993,7 @@ fn __action1530< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1531< +fn __action1527< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -65977,7 +66012,7 @@ fn __action1531< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1070( + __action1068( mode, __temp0, __1, @@ -65989,109 +66024,109 @@ fn __action1531< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1528< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action541( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1216( + mode, + __0, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1529< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action542( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1216( + mode, + __0, + __temp0, + __1, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1530< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec<(Option>, ast::ParenthesizedExpr)>, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action541( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1240( + mode, + __0, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1531< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action542( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1240( + mode, + __0, + __temp0, + __1, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1532< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec<(Option>, ast::Expr)>, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action541( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1205( - mode, - __0, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1533< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action542( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1205( - mode, - __0, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1534< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec<(Option>, ast::Expr)>, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action541( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1228( - mode, - __0, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1535< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action542( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1228( - mode, - __0, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1536< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -66114,7 +66149,7 @@ fn __action1536< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1537< +fn __action1533< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -66135,6 +66170,106 @@ fn __action1537< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1534< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Identifier, TextSize), +) -> Vec +{ + let __start0 = __0.0; + let __end0 = __2.2; + let __temp0 = __action1290( + mode, + __0, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action369( + mode, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1535< +>( + mode: Mode, + __0: (TextSize, ast::Identifier, TextSize), +) -> Vec +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action1291( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action369( + mode, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1536< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Identifier, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, ast::Identifier, TextSize), +) -> Vec +{ + let __start0 = __2.0; + let __end0 = __4.2; + let __temp0 = __action1290( + mode, + __2, + __3, + __4, + ); + let __temp0 = (__start0, __temp0, __end0); + __action370( + mode, + __0, + __1, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1537< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::Identifier, TextSize), +) -> Vec +{ + let __start0 = __2.0; + let __end0 = __2.2; + let __temp0 = __action1291( + mode, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action370( + mode, + __0, + __1, + __temp0, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1538< @@ -66147,14 +66282,14 @@ fn __action1538< { let __start0 = __0.0; let __end0 = __2.2; - let __temp0 = __action1278( + let __temp0 = __action1292( mode, __0, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action369( + __action362( mode, __temp0, ) @@ -66170,12 +66305,12 @@ fn __action1539< { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action1279( + let __temp0 = __action1293( mode, __0, ); let __temp0 = (__start0, __temp0, __end0); - __action369( + __action362( mode, __temp0, ) @@ -66195,14 +66330,14 @@ fn __action1540< { let __start0 = __2.0; let __end0 = __4.2; - let __temp0 = __action1278( + let __temp0 = __action1292( mode, __2, __3, __4, ); let __temp0 = (__start0, __temp0, __end0); - __action370( + __action363( mode, __0, __1, @@ -66222,12 +66357,12 @@ fn __action1541< { let __start0 = __2.0; let __end0 = __2.2; - let __temp0 = __action1279( + let __temp0 = __action1293( mode, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action370( + __action363( mode, __0, __1, @@ -66238,106 +66373,6 @@ fn __action1541< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1542< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action1280( - mode, - __0, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action362( - mode, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1543< ->( - mode: Mode, - __0: (TextSize, ast::Identifier, TextSize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action1281( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action362( - mode, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1544< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Identifier, TextSize), -) -> Vec -{ - let __start0 = __2.0; - let __end0 = __4.2; - let __temp0 = __action1280( - mode, - __2, - __3, - __4, - ); - let __temp0 = (__start0, __temp0, __end0); - __action363( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1545< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Identifier, TextSize), -) -> Vec -{ - let __start0 = __2.0; - let __end0 = __2.2; - let __temp0 = __action1281( - mode, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action363( - mode, - __0, - __1, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1546< >( mode: Mode, __0: (TextSize, ast::Identifier, TextSize), @@ -66360,7 +66395,7 @@ fn __action1546< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1547< +fn __action1543< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -66381,109 +66416,109 @@ fn __action1547< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1544< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action549( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1200( + mode, + __0, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1545< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action550( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1200( + mode, + __0, + __temp0, + __1, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1546< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, Vec, TextSize), + __2: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action549( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1226( + mode, + __0, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1547< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action550( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1226( + mode, + __0, + __temp0, + __1, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1548< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action549( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1190( - mode, - __0, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1549< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action550( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1190( - mode, - __0, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1550< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Vec, TextSize), - __2: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action549( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1215( - mode, - __0, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1551< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action550( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1215( - mode, - __0, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1552< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66502,7 +66537,7 @@ fn __action1552< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1322( + __action1334( mode, __temp0, __1, @@ -66516,7 +66551,7 @@ fn __action1552< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1553< +fn __action1549< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66539,7 +66574,7 @@ fn __action1553< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1322( + __action1334( mode, __temp0, __3, @@ -66553,7 +66588,7 @@ fn __action1553< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1554< +fn __action1550< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66578,7 +66613,7 @@ fn __action1554< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1322( + __action1334( mode, __temp0, __4, @@ -66592,7 +66627,7 @@ fn __action1554< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1555< +fn __action1551< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66610,7 +66645,7 @@ fn __action1555< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1323( + __action1335( mode, __temp0, __1, @@ -66623,7 +66658,7 @@ fn __action1555< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1556< +fn __action1552< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66645,7 +66680,7 @@ fn __action1556< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1323( + __action1335( mode, __temp0, __3, @@ -66658,7 +66693,7 @@ fn __action1556< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1557< +fn __action1553< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66682,7 +66717,7 @@ fn __action1557< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1323( + __action1335( mode, __temp0, __4, @@ -66695,7 +66730,7 @@ fn __action1557< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1558< +fn __action1554< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66715,7 +66750,7 @@ fn __action1558< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1324( + __action1336( mode, __temp0, __1, @@ -66730,7 +66765,7 @@ fn __action1558< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1559< +fn __action1555< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66754,7 +66789,7 @@ fn __action1559< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1324( + __action1336( mode, __temp0, __3, @@ -66767,159 +66802,159 @@ fn __action1559< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1556< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Parameter, TextSize), + __7: (TextSize, alloc::vec::Vec, TextSize), + __8: (TextSize, token::Tok, TextSize), + __9: (TextSize, Option>, TextSize), + __10: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action674( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1336( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + __10, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1557< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), + __6: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action422( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1337( + mode, + __temp0, + __1, + __2, + __3, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1558< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), + __6: (TextSize, token::Tok, TextSize), + __7: (TextSize, Option>, TextSize), + __8: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __2.2; + let __temp0 = __action673( + mode, + __0, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1337( + mode, + __temp0, + __3, + __4, + __5, + __6, + __7, + __8, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1559< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, alloc::vec::Vec, TextSize), + __7: (TextSize, token::Tok, TextSize), + __8: (TextSize, Option>, TextSize), + __9: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action674( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1337( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1560< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Parameter, TextSize), - __7: (TextSize, alloc::vec::Vec, TextSize), - __8: (TextSize, token::Tok, TextSize), - __9: (TextSize, Option>, TextSize), - __10: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action674( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1324( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - __10, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1561< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), - __6: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action422( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1325( - mode, - __temp0, - __1, - __2, - __3, - __4, - __5, - __6, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1562< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), - __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, Option>, TextSize), - __8: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action673( - mode, - __0, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1325( - mode, - __temp0, - __3, - __4, - __5, - __6, - __7, - __8, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1563< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, alloc::vec::Vec, TextSize), - __7: (TextSize, token::Tok, TextSize), - __8: (TextSize, Option>, TextSize), - __9: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action674( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1325( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1564< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66936,7 +66971,7 @@ fn __action1564< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1326( + __action1338( mode, __temp0, __1, @@ -66948,7 +66983,7 @@ fn __action1564< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1565< +fn __action1561< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -66969,7 +67004,7 @@ fn __action1565< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1326( + __action1338( mode, __temp0, __3, @@ -66981,7 +67016,7 @@ fn __action1565< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1566< +fn __action1562< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67004,7 +67039,7 @@ fn __action1566< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1326( + __action1338( mode, __temp0, __4, @@ -67016,7 +67051,7 @@ fn __action1566< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1567< +fn __action1563< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67032,7 +67067,7 @@ fn __action1567< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1327( + __action1339( mode, __temp0, __1, @@ -67043,7 +67078,7 @@ fn __action1567< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1568< +fn __action1564< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67063,7 +67098,7 @@ fn __action1568< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1327( + __action1339( mode, __temp0, __3, @@ -67074,7 +67109,7 @@ fn __action1568< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1569< +fn __action1565< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67096,7 +67131,7 @@ fn __action1569< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1327( + __action1339( mode, __temp0, __4, @@ -67107,7 +67142,7 @@ fn __action1569< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1570< +fn __action1566< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67125,7 +67160,7 @@ fn __action1570< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1328( + __action1340( mode, __temp0, __1, @@ -67138,7 +67173,7 @@ fn __action1570< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1571< +fn __action1567< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67160,7 +67195,7 @@ fn __action1571< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1328( + __action1340( mode, __temp0, __3, @@ -67173,7 +67208,7 @@ fn __action1571< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1572< +fn __action1568< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67197,7 +67232,7 @@ fn __action1572< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1328( + __action1340( mode, __temp0, __4, @@ -67210,7 +67245,7 @@ fn __action1572< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1573< +fn __action1569< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67227,7 +67262,7 @@ fn __action1573< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1329( + __action1341( mode, __temp0, __1, @@ -67239,7 +67274,7 @@ fn __action1573< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1574< +fn __action1570< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67260,7 +67295,7 @@ fn __action1574< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1329( + __action1341( mode, __temp0, __3, @@ -67272,7 +67307,7 @@ fn __action1574< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1575< +fn __action1571< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67295,7 +67330,7 @@ fn __action1575< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1329( + __action1341( mode, __temp0, __4, @@ -67307,7 +67342,7 @@ fn __action1575< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1576< +fn __action1572< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67321,7 +67356,7 @@ fn __action1576< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1330( + __action1342( mode, __temp0, __1, @@ -67330,7 +67365,7 @@ fn __action1576< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1577< +fn __action1573< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67348,7 +67383,7 @@ fn __action1577< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1330( + __action1342( mode, __temp0, __3, @@ -67357,7 +67392,7 @@ fn __action1577< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1578< +fn __action1574< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67377,7 +67412,7 @@ fn __action1578< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1330( + __action1342( mode, __temp0, __4, @@ -67386,7 +67421,7 @@ fn __action1578< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1579< +fn __action1575< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67404,7 +67439,7 @@ fn __action1579< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1331( + __action1343( mode, __temp0, __1, @@ -67417,7 +67452,7 @@ fn __action1579< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1580< +fn __action1576< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67439,7 +67474,7 @@ fn __action1580< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1331( + __action1343( mode, __temp0, __3, @@ -67452,7 +67487,7 @@ fn __action1580< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1581< +fn __action1577< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67476,7 +67511,7 @@ fn __action1581< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1331( + __action1343( mode, __temp0, __4, @@ -67489,7 +67524,7 @@ fn __action1581< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1582< +fn __action1578< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67506,7 +67541,7 @@ fn __action1582< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1332( + __action1344( mode, __temp0, __1, @@ -67518,7 +67553,7 @@ fn __action1582< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1583< +fn __action1579< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67539,7 +67574,7 @@ fn __action1583< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1332( + __action1344( mode, __temp0, __3, @@ -67551,7 +67586,7 @@ fn __action1583< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1584< +fn __action1580< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67574,7 +67609,7 @@ fn __action1584< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1332( + __action1344( mode, __temp0, __4, @@ -67586,7 +67621,7 @@ fn __action1584< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1585< +fn __action1581< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67605,7 +67640,7 @@ fn __action1585< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1333( + __action1345( mode, __temp0, __1, @@ -67619,7 +67654,7 @@ fn __action1585< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1586< +fn __action1582< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67642,7 +67677,7 @@ fn __action1586< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1333( + __action1345( mode, __temp0, __3, @@ -67654,151 +67689,151 @@ fn __action1586< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1583< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Parameter, TextSize), + __7: (TextSize, alloc::vec::Vec, TextSize), + __8: (TextSize, token::Tok, TextSize), + __9: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action674( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1345( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1584< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action422( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1346( + mode, + __temp0, + __1, + __2, + __3, + __4, + __5, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1585< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), + __6: (TextSize, token::Tok, TextSize), + __7: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __2.2; + let __temp0 = __action673( + mode, + __0, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1346( + mode, + __temp0, + __3, + __4, + __5, + __6, + __7, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1586< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, alloc::vec::Vec, TextSize), + __7: (TextSize, token::Tok, TextSize), + __8: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action674( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1346( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1587< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Parameter, TextSize), - __7: (TextSize, alloc::vec::Vec, TextSize), - __8: (TextSize, token::Tok, TextSize), - __9: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action674( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1333( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1588< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action422( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1334( - mode, - __temp0, - __1, - __2, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1589< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), - __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action673( - mode, - __0, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1334( - mode, - __temp0, - __3, - __4, - __5, - __6, - __7, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1590< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, alloc::vec::Vec, TextSize), - __7: (TextSize, token::Tok, TextSize), - __8: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action674( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1334( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1591< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67814,7 +67849,7 @@ fn __action1591< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1335( + __action1347( mode, __temp0, __1, @@ -67825,7 +67860,7 @@ fn __action1591< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1592< +fn __action1588< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67845,7 +67880,7 @@ fn __action1592< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1335( + __action1347( mode, __temp0, __3, @@ -67856,7 +67891,7 @@ fn __action1592< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1593< +fn __action1589< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67878,7 +67913,7 @@ fn __action1593< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1335( + __action1347( mode, __temp0, __4, @@ -67889,7 +67924,7 @@ fn __action1593< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1594< +fn __action1590< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67904,7 +67939,7 @@ fn __action1594< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1336( + __action1348( mode, __temp0, __1, @@ -67914,7 +67949,7 @@ fn __action1594< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1595< +fn __action1591< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67933,7 +67968,7 @@ fn __action1595< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1336( + __action1348( mode, __temp0, __3, @@ -67943,7 +67978,7 @@ fn __action1595< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1596< +fn __action1592< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67964,7 +67999,7 @@ fn __action1596< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1336( + __action1348( mode, __temp0, __4, @@ -67974,7 +68009,7 @@ fn __action1596< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1597< +fn __action1593< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -67991,7 +68026,7 @@ fn __action1597< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1337( + __action1349( mode, __temp0, __1, @@ -68003,7 +68038,7 @@ fn __action1597< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1598< +fn __action1594< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68024,7 +68059,7 @@ fn __action1598< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1337( + __action1349( mode, __temp0, __3, @@ -68036,7 +68071,7 @@ fn __action1598< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1599< +fn __action1595< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68059,7 +68094,7 @@ fn __action1599< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1337( + __action1349( mode, __temp0, __4, @@ -68071,7 +68106,7 @@ fn __action1599< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1600< +fn __action1596< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68087,7 +68122,7 @@ fn __action1600< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1338( + __action1350( mode, __temp0, __1, @@ -68098,7 +68133,7 @@ fn __action1600< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1601< +fn __action1597< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68118,7 +68153,7 @@ fn __action1601< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1338( + __action1350( mode, __temp0, __3, @@ -68129,7 +68164,7 @@ fn __action1601< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1602< +fn __action1598< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68151,7 +68186,7 @@ fn __action1602< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1338( + __action1350( mode, __temp0, __4, @@ -68162,7 +68197,7 @@ fn __action1602< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1603< +fn __action1599< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68175,7 +68210,7 @@ fn __action1603< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1339( + __action1351( mode, __temp0, ) @@ -68183,7 +68218,7 @@ fn __action1603< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1604< +fn __action1600< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68200,7 +68235,7 @@ fn __action1604< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1339( + __action1351( mode, __temp0, ) @@ -68208,7 +68243,7 @@ fn __action1604< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1605< +fn __action1601< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68227,7 +68262,7 @@ fn __action1605< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1339( + __action1351( mode, __temp0, ) @@ -68235,7 +68270,7 @@ fn __action1605< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1606< +fn __action1602< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68251,7 +68286,7 @@ fn __action1606< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1340( + __action1352( mode, __temp0, __1, @@ -68262,7 +68297,7 @@ fn __action1606< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1607< +fn __action1603< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68282,7 +68317,7 @@ fn __action1607< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1340( + __action1352( mode, __temp0, __3, @@ -68293,7 +68328,7 @@ fn __action1607< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1608< +fn __action1604< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68315,7 +68350,7 @@ fn __action1608< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1340( + __action1352( mode, __temp0, __4, @@ -68326,7 +68361,7 @@ fn __action1608< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1609< +fn __action1605< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68341,7 +68376,7 @@ fn __action1609< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1341( + __action1353( mode, __temp0, __1, @@ -68351,7 +68386,7 @@ fn __action1609< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1610< +fn __action1606< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68370,7 +68405,7 @@ fn __action1610< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1341( + __action1353( mode, __temp0, __3, @@ -68380,7 +68415,7 @@ fn __action1610< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1611< +fn __action1607< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68401,7 +68436,7 @@ fn __action1611< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1341( + __action1353( mode, __temp0, __4, @@ -68411,7 +68446,7 @@ fn __action1611< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1612< +fn __action1608< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68430,7 +68465,7 @@ fn __action1612< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1360( + __action1372( mode, __temp0, __1, @@ -68444,7 +68479,7 @@ fn __action1612< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1613< +fn __action1609< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68467,7 +68502,7 @@ fn __action1613< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1360( + __action1372( mode, __temp0, __3, @@ -68479,151 +68514,151 @@ fn __action1613< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1610< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Parameter, TextSize), + __7: (TextSize, token::Tok, TextSize), + __8: (TextSize, Option>, TextSize), + __9: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action682( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1372( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1611< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, Option>, TextSize), + __5: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action430( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1373( + mode, + __temp0, + __1, + __2, + __3, + __4, + __5, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1612< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, Option>, TextSize), + __7: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __2.2; + let __temp0 = __action681( + mode, + __0, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1373( + mode, + __temp0, + __3, + __4, + __5, + __6, + __7, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1613< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, token::Tok, TextSize), + __7: (TextSize, Option>, TextSize), + __8: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action682( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1373( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1614< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Parameter, TextSize), - __7: (TextSize, token::Tok, TextSize), - __8: (TextSize, Option>, TextSize), - __9: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action682( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1360( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1615< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, Option>, TextSize), - __5: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action430( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1361( - mode, - __temp0, - __1, - __2, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1616< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, Option>, TextSize), - __7: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action681( - mode, - __0, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1361( - mode, - __temp0, - __3, - __4, - __5, - __6, - __7, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1617< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, Option>, TextSize), - __8: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action682( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1361( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1618< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68643,7 +68678,7 @@ fn __action1618< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1362( + __action1374( mode, __temp0, __1, @@ -68658,7 +68693,7 @@ fn __action1618< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1619< +fn __action1615< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68682,7 +68717,7 @@ fn __action1619< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1362( + __action1374( mode, __temp0, __3, @@ -68695,159 +68730,159 @@ fn __action1619< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1616< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Parameter, TextSize), + __7: (TextSize, alloc::vec::Vec, TextSize), + __8: (TextSize, token::Tok, TextSize), + __9: (TextSize, Option>, TextSize), + __10: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action682( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1374( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + __10, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1617< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), + __6: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action430( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1375( + mode, + __temp0, + __1, + __2, + __3, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1618< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), + __6: (TextSize, token::Tok, TextSize), + __7: (TextSize, Option>, TextSize), + __8: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __2.2; + let __temp0 = __action681( + mode, + __0, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1375( + mode, + __temp0, + __3, + __4, + __5, + __6, + __7, + __8, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1619< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, alloc::vec::Vec, TextSize), + __7: (TextSize, token::Tok, TextSize), + __8: (TextSize, Option>, TextSize), + __9: (TextSize, token::Tok, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action682( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1375( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1620< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Parameter, TextSize), - __7: (TextSize, alloc::vec::Vec, TextSize), - __8: (TextSize, token::Tok, TextSize), - __9: (TextSize, Option>, TextSize), - __10: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action682( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1362( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - __10, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1621< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), - __6: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action430( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1363( - mode, - __temp0, - __1, - __2, - __3, - __4, - __5, - __6, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1622< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), - __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, Option>, TextSize), - __8: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action681( - mode, - __0, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1363( - mode, - __temp0, - __3, - __4, - __5, - __6, - __7, - __8, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1623< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, alloc::vec::Vec, TextSize), - __7: (TextSize, token::Tok, TextSize), - __8: (TextSize, Option>, TextSize), - __9: (TextSize, token::Tok, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action682( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1363( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1624< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68864,7 +68899,7 @@ fn __action1624< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1364( + __action1376( mode, __temp0, __1, @@ -68876,7 +68911,7 @@ fn __action1624< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1625< +fn __action1621< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68897,7 +68932,7 @@ fn __action1625< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1364( + __action1376( mode, __temp0, __3, @@ -68909,7 +68944,7 @@ fn __action1625< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1626< +fn __action1622< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68932,7 +68967,7 @@ fn __action1626< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1364( + __action1376( mode, __temp0, __4, @@ -68944,7 +68979,7 @@ fn __action1626< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1627< +fn __action1623< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68960,7 +68995,7 @@ fn __action1627< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1365( + __action1377( mode, __temp0, __1, @@ -68971,7 +69006,7 @@ fn __action1627< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1628< +fn __action1624< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -68991,7 +69026,7 @@ fn __action1628< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1365( + __action1377( mode, __temp0, __3, @@ -69002,7 +69037,7 @@ fn __action1628< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1629< +fn __action1625< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69024,7 +69059,7 @@ fn __action1629< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1365( + __action1377( mode, __temp0, __4, @@ -69035,7 +69070,7 @@ fn __action1629< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1630< +fn __action1626< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69053,7 +69088,7 @@ fn __action1630< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1366( + __action1378( mode, __temp0, __1, @@ -69066,7 +69101,7 @@ fn __action1630< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1631< +fn __action1627< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69088,7 +69123,7 @@ fn __action1631< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1366( + __action1378( mode, __temp0, __3, @@ -69101,7 +69136,7 @@ fn __action1631< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1632< +fn __action1628< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69125,7 +69160,7 @@ fn __action1632< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1366( + __action1378( mode, __temp0, __4, @@ -69138,7 +69173,7 @@ fn __action1632< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1633< +fn __action1629< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69155,7 +69190,7 @@ fn __action1633< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1367( + __action1379( mode, __temp0, __1, @@ -69167,7 +69202,7 @@ fn __action1633< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1634< +fn __action1630< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69188,7 +69223,7 @@ fn __action1634< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1367( + __action1379( mode, __temp0, __3, @@ -69200,7 +69235,7 @@ fn __action1634< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1635< +fn __action1631< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69223,7 +69258,7 @@ fn __action1635< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1367( + __action1379( mode, __temp0, __4, @@ -69235,7 +69270,7 @@ fn __action1635< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1636< +fn __action1632< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69249,7 +69284,7 @@ fn __action1636< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1368( + __action1380( mode, __temp0, __1, @@ -69258,7 +69293,7 @@ fn __action1636< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1637< +fn __action1633< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69276,7 +69311,7 @@ fn __action1637< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1368( + __action1380( mode, __temp0, __3, @@ -69285,7 +69320,7 @@ fn __action1637< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1638< +fn __action1634< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69305,7 +69340,7 @@ fn __action1638< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1368( + __action1380( mode, __temp0, __4, @@ -69314,7 +69349,7 @@ fn __action1638< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1639< +fn __action1635< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69332,7 +69367,7 @@ fn __action1639< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1369( + __action1381( mode, __temp0, __1, @@ -69345,7 +69380,7 @@ fn __action1639< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1640< +fn __action1636< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69367,7 +69402,7 @@ fn __action1640< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1369( + __action1381( mode, __temp0, __3, @@ -69380,7 +69415,7 @@ fn __action1640< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1641< +fn __action1637< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69404,7 +69439,7 @@ fn __action1641< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1369( + __action1381( mode, __temp0, __4, @@ -69417,7 +69452,7 @@ fn __action1641< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1642< +fn __action1638< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69434,7 +69469,7 @@ fn __action1642< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1370( + __action1382( mode, __temp0, __1, @@ -69446,7 +69481,7 @@ fn __action1642< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1643< +fn __action1639< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69467,7 +69502,7 @@ fn __action1643< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1370( + __action1382( mode, __temp0, __3, @@ -69479,7 +69514,7 @@ fn __action1643< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1644< +fn __action1640< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69502,7 +69537,7 @@ fn __action1644< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1370( + __action1382( mode, __temp0, __4, @@ -69514,7 +69549,7 @@ fn __action1644< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1645< +fn __action1641< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69533,7 +69568,7 @@ fn __action1645< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1371( + __action1383( mode, __temp0, __1, @@ -69547,7 +69582,7 @@ fn __action1645< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1646< +fn __action1642< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69570,7 +69605,7 @@ fn __action1646< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1371( + __action1383( mode, __temp0, __3, @@ -69582,151 +69617,151 @@ fn __action1646< ) } +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1643< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, ast::Parameter, TextSize), + __7: (TextSize, alloc::vec::Vec, TextSize), + __8: (TextSize, token::Tok, TextSize), + __9: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action682( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1383( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + __9, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1644< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action430( + mode, + __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1384( + mode, + __temp0, + __1, + __2, + __3, + __4, + __5, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1645< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, token::Tok, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, alloc::vec::Vec, TextSize), + __6: (TextSize, token::Tok, TextSize), + __7: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __2.2; + let __temp0 = __action681( + mode, + __0, + __1, + __2, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1384( + mode, + __temp0, + __3, + __4, + __5, + __6, + __7, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1646< +>( + mode: Mode, + __0: (TextSize, Vec, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, alloc::vec::Vec, TextSize), + __4: (TextSize, token::Tok, TextSize), + __5: (TextSize, token::Tok, TextSize), + __6: (TextSize, alloc::vec::Vec, TextSize), + __7: (TextSize, token::Tok, TextSize), + __8: (TextSize, Option>, TextSize), +) -> Result> +{ + let __start0 = __0.0; + let __end0 = __3.2; + let __temp0 = __action682( + mode, + __0, + __1, + __2, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1384( + mode, + __temp0, + __4, + __5, + __6, + __7, + __8, + ) +} + #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1647< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Parameter, TextSize), - __7: (TextSize, alloc::vec::Vec, TextSize), - __8: (TextSize, token::Tok, TextSize), - __9: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action682( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1371( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - __9, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1648< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action430( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1372( - mode, - __temp0, - __1, - __2, - __3, - __4, - __5, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1649< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, alloc::vec::Vec, TextSize), - __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __2.2; - let __temp0 = __action681( - mode, - __0, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1372( - mode, - __temp0, - __3, - __4, - __5, - __6, - __7, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1650< ->( - mode: Mode, - __0: (TextSize, Vec, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, alloc::vec::Vec, TextSize), - __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, alloc::vec::Vec, TextSize), - __7: (TextSize, token::Tok, TextSize), - __8: (TextSize, Option>, TextSize), -) -> Result> -{ - let __start0 = __0.0; - let __end0 = __3.2; - let __temp0 = __action682( - mode, - __0, - __1, - __2, - __3, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1372( - mode, - __temp0, - __4, - __5, - __6, - __7, - __8, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1651< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69742,7 +69777,7 @@ fn __action1651< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1373( + __action1385( mode, __temp0, __1, @@ -69753,7 +69788,7 @@ fn __action1651< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1652< +fn __action1648< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69773,7 +69808,7 @@ fn __action1652< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1373( + __action1385( mode, __temp0, __3, @@ -69784,7 +69819,7 @@ fn __action1652< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1653< +fn __action1649< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69806,7 +69841,7 @@ fn __action1653< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1373( + __action1385( mode, __temp0, __4, @@ -69817,7 +69852,7 @@ fn __action1653< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1654< +fn __action1650< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69832,7 +69867,7 @@ fn __action1654< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1374( + __action1386( mode, __temp0, __1, @@ -69842,7 +69877,7 @@ fn __action1654< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1655< +fn __action1651< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69861,7 +69896,7 @@ fn __action1655< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1374( + __action1386( mode, __temp0, __3, @@ -69871,7 +69906,7 @@ fn __action1655< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1656< +fn __action1652< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69892,7 +69927,7 @@ fn __action1656< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1374( + __action1386( mode, __temp0, __4, @@ -69902,7 +69937,7 @@ fn __action1656< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1657< +fn __action1653< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69919,7 +69954,7 @@ fn __action1657< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1375( + __action1387( mode, __temp0, __1, @@ -69931,7 +69966,7 @@ fn __action1657< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1658< +fn __action1654< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69952,7 +69987,7 @@ fn __action1658< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1375( + __action1387( mode, __temp0, __3, @@ -69964,7 +69999,7 @@ fn __action1658< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1659< +fn __action1655< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -69987,7 +70022,7 @@ fn __action1659< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1375( + __action1387( mode, __temp0, __4, @@ -69999,7 +70034,7 @@ fn __action1659< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1660< +fn __action1656< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70015,7 +70050,7 @@ fn __action1660< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1376( + __action1388( mode, __temp0, __1, @@ -70026,7 +70061,7 @@ fn __action1660< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1661< +fn __action1657< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70046,7 +70081,7 @@ fn __action1661< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1376( + __action1388( mode, __temp0, __3, @@ -70057,7 +70092,7 @@ fn __action1661< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1662< +fn __action1658< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70079,7 +70114,7 @@ fn __action1662< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1376( + __action1388( mode, __temp0, __4, @@ -70090,7 +70125,7 @@ fn __action1662< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1663< +fn __action1659< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70103,7 +70138,7 @@ fn __action1663< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1377( + __action1389( mode, __temp0, ) @@ -70111,7 +70146,7 @@ fn __action1663< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1664< +fn __action1660< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70128,7 +70163,7 @@ fn __action1664< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1377( + __action1389( mode, __temp0, ) @@ -70136,7 +70171,7 @@ fn __action1664< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1665< +fn __action1661< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70155,7 +70190,7 @@ fn __action1665< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1377( + __action1389( mode, __temp0, ) @@ -70163,7 +70198,7 @@ fn __action1665< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1666< +fn __action1662< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70179,7 +70214,7 @@ fn __action1666< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1378( + __action1390( mode, __temp0, __1, @@ -70190,7 +70225,7 @@ fn __action1666< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1667< +fn __action1663< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70210,7 +70245,7 @@ fn __action1667< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1378( + __action1390( mode, __temp0, __3, @@ -70221,7 +70256,7 @@ fn __action1667< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1668< +fn __action1664< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70243,7 +70278,7 @@ fn __action1668< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1378( + __action1390( mode, __temp0, __4, @@ -70254,7 +70289,7 @@ fn __action1668< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1669< +fn __action1665< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70269,7 +70304,7 @@ fn __action1669< __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1379( + __action1391( mode, __temp0, __1, @@ -70279,7 +70314,7 @@ fn __action1669< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1670< +fn __action1666< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70298,7 +70333,7 @@ fn __action1670< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1379( + __action1391( mode, __temp0, __3, @@ -70308,7 +70343,7 @@ fn __action1670< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1671< +fn __action1667< >( mode: Mode, __0: (TextSize, Vec, TextSize), @@ -70329,7 +70364,7 @@ fn __action1671< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1379( + __action1391( mode, __temp0, __4, @@ -70339,14 +70374,14 @@ fn __action1671< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1672< +fn __action1668< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Parameters, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), -) -> Result> + __3: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Result> { let __start0 = __1.0; let __end0 = __1.2; @@ -70355,7 +70390,115 @@ fn __action1672< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1291( + __action1303( + mode, + __0, + __temp0, + __2, + __3, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1669< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Result> +{ + let __start0 = __0.2; + let __end0 = __1.0; + let __temp0 = __action259( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1303( + mode, + __0, + __temp0, + __1, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1670< +>( + mode: Mode, + __0: (TextSize, core::option::Option, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, core::option::Option, TextSize), + __3: (TextSize, Option, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __3.0; + let __end0 = __3.2; + let __temp0 = __action254( + mode, + __3, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1442( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1671< +>( + mode: Mode, + __0: (TextSize, core::option::Option, TextSize), + __1: (TextSize, token::Tok, TextSize), + __2: (TextSize, core::option::Option, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __2.2; + let __end0 = __2.2; + let __temp0 = __action255( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1442( + mode, + __0, + __1, + __2, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1672< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, token::Tok, TextSize), + __3: (TextSize, ast::Suite, TextSize), +) -> ast::ExceptHandler +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action302( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action769( mode, __0, __temp0, @@ -70371,18 +70514,18 @@ fn __action1673< mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> Result> + __2: (TextSize, ast::Suite, TextSize), +) -> ast::ExceptHandler { let __start0 = __0.2; let __end0 = __1.0; - let __temp0 = __action259( + let __temp0 = __action303( mode, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1291( + __action769( mode, __0, __temp0, @@ -70396,24 +70539,20 @@ fn __action1673< fn __action1674< >( mode: Mode, - __0: (TextSize, core::option::Option, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option, TextSize), - __3: (TextSize, Option, TextSize), -) -> ast::Expr + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> Option { - let __start0 = __3.0; - let __end0 = __3.2; - let __temp0 = __action254( + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action302( mode, - __3, + __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1430( + __action899( mode, __0, - __1, - __2, __temp0, ) } @@ -70421,114 +70560,10 @@ fn __action1674< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] fn __action1675< ->( - mode: Mode, - __0: (TextSize, core::option::Option, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, core::option::Option, TextSize), -) -> ast::Expr -{ - let __start0 = __2.2; - let __end0 = __2.2; - let __temp0 = __action255( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1430( - mode, - __0, - __1, - __2, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1676< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Suite, TextSize), -) -> ast::ExceptHandler -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action302( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action767( - mode, - __0, - __temp0, - __2, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1677< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Suite, TextSize), -) -> ast::ExceptHandler -{ - let __start0 = __0.2; - let __end0 = __1.0; - let __temp0 = __action303( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action767( - mode, - __0, - __temp0, - __1, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1678< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> Option -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action302( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action897( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1679< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> Option +) -> Option { let __start0 = __0.2; let __end0 = __0.2; @@ -70538,7 +70573,7 @@ fn __action1679< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action897( + __action899( mode, __0, __temp0, @@ -70547,14 +70582,14 @@ fn __action1679< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1680< +fn __action1676< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), - __3: (TextSize, Option, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), + __3: (TextSize, Option, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.2; @@ -70570,7 +70605,7 @@ fn __action1680< __2, ); let __temp1 = (__start1, __temp1, __end1); - __action1674( + __action1670( mode, __temp0, __1, @@ -70581,13 +70616,13 @@ fn __action1680< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1681< +fn __action1677< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, Option, TextSize), -) -> ast::Expr + __2: (TextSize, Option, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.2; @@ -70604,7 +70639,7 @@ fn __action1681< &__end1, ); let __temp1 = (__start1, __temp1, __end1); - __action1674( + __action1670( mode, __temp0, __1, @@ -70615,13 +70650,13 @@ fn __action1681< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1682< +fn __action1678< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, Option, TextSize), -) -> ast::Expr + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, Option, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -70638,7 +70673,7 @@ fn __action1682< __1, ); let __temp1 = (__start1, __temp1, __end1); - __action1674( + __action1670( mode, __temp0, __0, @@ -70649,12 +70684,12 @@ fn __action1682< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1683< +fn __action1679< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, Option, TextSize), -) -> ast::Expr + __1: (TextSize, Option, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -70672,7 +70707,7 @@ fn __action1683< &__end1, ); let __temp1 = (__start1, __temp1, __end1); - __action1674( + __action1670( mode, __temp0, __0, @@ -70683,13 +70718,13 @@ fn __action1683< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1684< +fn __action1680< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __2: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.2; @@ -70705,7 +70740,7 @@ fn __action1684< __2, ); let __temp1 = (__start1, __temp1, __end1); - __action1675( + __action1671( mode, __temp0, __1, @@ -70715,12 +70750,12 @@ fn __action1684< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1685< +fn __action1681< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.2; @@ -70737,7 +70772,7 @@ fn __action1685< &__end1, ); let __temp1 = (__start1, __temp1, __end1); - __action1675( + __action1671( mode, __temp0, __1, @@ -70747,12 +70782,12 @@ fn __action1685< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1686< +fn __action1682< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -70769,7 +70804,7 @@ fn __action1686< __1, ); let __temp1 = (__start1, __temp1, __end1); - __action1675( + __action1671( mode, __temp0, __0, @@ -70779,11 +70814,11 @@ fn __action1686< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1687< +fn __action1683< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.0; @@ -70801,7 +70836,7 @@ fn __action1687< &__end1, ); let __temp1 = (__start1, __temp1, __end1); - __action1675( + __action1671( mode, __temp0, __0, @@ -70811,14 +70846,14 @@ fn __action1687< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1688< +fn __action1684< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), __7: (TextSize, token::Tok, TextSize), @@ -70833,7 +70868,7 @@ fn __action1688< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action1095( + __action1093( mode, __0, __1, @@ -70850,14 +70885,14 @@ fn __action1688< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1689< +fn __action1685< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, token::Tok, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -70869,7 +70904,7 @@ fn __action1689< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action1096( + __action1094( mode, __0, __1, @@ -70883,13 +70918,13 @@ fn __action1689< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1690< +fn __action1686< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, ast::Suite, TextSize), __6: (TextSize, token::Tok, TextSize), @@ -70904,7 +70939,7 @@ fn __action1690< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1097( + __action1095( mode, __0, __1, @@ -70920,13 +70955,13 @@ fn __action1690< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1691< +fn __action1687< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), __4: (TextSize, token::Tok, TextSize), __5: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -70938,7 +70973,7 @@ fn __action1691< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1098( + __action1096( mode, __0, __1, @@ -70951,11 +70986,11 @@ fn __action1691< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1692< +fn __action1688< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> core::option::Option + __0: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> core::option::Option { let __start0 = __0.0; let __end0 = __0.2; @@ -70972,11 +71007,11 @@ fn __action1692< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1693< +fn __action1689< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.2; @@ -70993,11 +71028,11 @@ fn __action1693< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1694< +fn __action1690< >( mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> ast::Expr + __0: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr { let __start0 = __0.0; let __end0 = __0.2; @@ -71014,11 +71049,11 @@ fn __action1694< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1695< +fn __action1691< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Mod { let __start0 = __1.0; @@ -71028,7 +71063,101 @@ fn __action1695< __1, ); let __temp0 = (__start0, __temp0, __end0); - __action1440( + __action1451( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1692< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), + __2: (TextSize, alloc::vec::Vec, TextSize), +) -> ast::Mod +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action222( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1452( + mode, + __0, + __temp0, + __2, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1693< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::Stmt +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action1688( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1278( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1694< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), +) -> ast::Stmt +{ + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action376( + mode, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1278( + mode, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +#[allow(clippy::too_many_arguments)] +fn __action1695< +>( + mode: Mode, + __0: (TextSize, token::Tok, TextSize), + __1: (TextSize, ast::ParenthesizedExpr, TextSize), +) -> ast::ParenthesizedExpr +{ + let __start0 = __1.0; + let __end0 = __1.2; + let __temp0 = __action1688( + mode, + __1, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1476( mode, __0, __temp0, @@ -71041,22 +71170,20 @@ fn __action1696< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), - __2: (TextSize, alloc::vec::Vec, TextSize), -) -> ast::Mod +) -> ast::ParenthesizedExpr { - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action222( + let __start0 = __0.2; + let __end0 = __0.2; + let __temp0 = __action376( mode, - __1, + &__start0, + &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1441( + __action1476( mode, __0, __temp0, - __2, ) } @@ -71065,20 +71192,18 @@ fn __action1696< fn __action1697< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action1692( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1266( + let __start0 = __0.0; + let __end0 = __0.2; + let __temp0 = __action1690( mode, __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1490( + mode, __temp0, ) } @@ -71088,21 +71213,21 @@ fn __action1697< fn __action1698< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), + __1: (TextSize, alloc::vec::Vec, TextSize), ) -> ast::Stmt { - let __start0 = __0.2; + let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action376( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1266( + let __temp0 = __action1690( mode, __0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action1491( + mode, __temp0, + __1, ) } @@ -71111,109 +71236,19 @@ fn __action1698< fn __action1699< >( mode: Mode, - __0: (TextSize, token::Tok, TextSize), - __1: (TextSize, ast::Expr, TextSize), -) -> ast::Expr -{ - let __start0 = __1.0; - let __end0 = __1.2; - let __temp0 = __action1692( - mode, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1468( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1700< ->( - mode: Mode, - __0: (TextSize, token::Tok, TextSize), -) -> ast::Expr -{ - let __start0 = __0.2; - let __end0 = __0.2; - let __temp0 = __action376( - mode, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1468( - mode, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1701< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), -) -> ast::Stmt -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action1694( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1494( - mode, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1702< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), - __1: (TextSize, alloc::vec::Vec, TextSize), -) -> ast::Stmt -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action1694( - mode, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1495( - mode, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] -fn __action1703< ->( - mode: Mode, - __0: (TextSize, ast::Expr, TextSize), + __0: (TextSize, ast::ParenthesizedExpr, TextSize), __1: (TextSize, ast::Operator, TextSize), - __2: (TextSize, ast::Expr, TextSize), + __2: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __0.0; let __end0 = __0.2; - let __temp0 = __action1694( + let __temp0 = __action1690( mode, __0, ); let __temp0 = (__start0, __temp0, __end0); - __action1260( + __action1272( mode, __temp0, __1, @@ -71223,7 +71258,7 @@ fn __action1703< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1704< +fn __action1700< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71241,7 +71276,7 @@ fn __action1704< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1520( + __action1516( mode, __0, __1, @@ -71254,7 +71289,7 @@ fn __action1704< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1705< +fn __action1701< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71272,7 +71307,7 @@ fn __action1705< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1520( + __action1516( mode, __0, __1, @@ -71285,7 +71320,7 @@ fn __action1705< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1706< +fn __action1702< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71304,7 +71339,7 @@ fn __action1706< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1521( + __action1517( mode, __0, __1, @@ -71318,7 +71353,7 @@ fn __action1706< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1707< +fn __action1703< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71337,7 +71372,7 @@ fn __action1707< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1521( + __action1517( mode, __0, __1, @@ -71351,7 +71386,7 @@ fn __action1707< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1708< +fn __action1704< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71368,7 +71403,7 @@ fn __action1708< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1522( + __action1518( mode, __0, __1, @@ -71380,7 +71415,7 @@ fn __action1708< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1709< +fn __action1705< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71397,7 +71432,7 @@ fn __action1709< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1522( + __action1518( mode, __0, __1, @@ -71409,7 +71444,7 @@ fn __action1709< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1710< +fn __action1706< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71427,7 +71462,7 @@ fn __action1710< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1523( + __action1519( mode, __0, __1, @@ -71440,7 +71475,7 @@ fn __action1710< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1711< +fn __action1707< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71458,7 +71493,7 @@ fn __action1711< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1523( + __action1519( mode, __0, __1, @@ -71471,7 +71506,7 @@ fn __action1711< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1712< +fn __action1708< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71480,7 +71515,7 @@ fn __action1712< __3: (TextSize, ast::TypeParams, TextSize), __4: (TextSize, ast::Parameters, TextSize), __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Expr, TextSize), + __6: (TextSize, ast::ParenthesizedExpr, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71492,7 +71527,7 @@ fn __action1712< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1524( + __action1520( mode, __0, __1, @@ -71508,7 +71543,7 @@ fn __action1712< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1713< +fn __action1709< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71516,7 +71551,7 @@ fn __action1713< __2: (TextSize, ast::Identifier, TextSize), __3: (TextSize, ast::Parameters, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, ast::Expr, TextSize), + __5: (TextSize, ast::ParenthesizedExpr, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71529,7 +71564,7 @@ fn __action1713< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1524( + __action1520( mode, __0, __1, @@ -71545,7 +71580,7 @@ fn __action1713< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1714< +fn __action1710< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71555,7 +71590,7 @@ fn __action1714< __4: (TextSize, ast::TypeParams, TextSize), __5: (TextSize, ast::Parameters, TextSize), __6: (TextSize, token::Tok, TextSize), - __7: (TextSize, ast::Expr, TextSize), + __7: (TextSize, ast::ParenthesizedExpr, TextSize), __8: (TextSize, token::Tok, TextSize), __9: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71567,7 +71602,7 @@ fn __action1714< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action1525( + __action1521( mode, __0, __1, @@ -71584,7 +71619,7 @@ fn __action1714< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1715< +fn __action1711< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71593,7 +71628,7 @@ fn __action1715< __3: (TextSize, ast::Identifier, TextSize), __4: (TextSize, ast::Parameters, TextSize), __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Expr, TextSize), + __6: (TextSize, ast::ParenthesizedExpr, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71606,7 +71641,7 @@ fn __action1715< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1525( + __action1521( mode, __0, __1, @@ -71623,7 +71658,7 @@ fn __action1715< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1716< +fn __action1712< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71642,7 +71677,7 @@ fn __action1716< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1526( + __action1522( mode, __0, __1, @@ -71656,7 +71691,7 @@ fn __action1716< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1717< +fn __action1713< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71675,7 +71710,7 @@ fn __action1717< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1526( + __action1522( mode, __0, __1, @@ -71689,7 +71724,7 @@ fn __action1717< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1718< +fn __action1714< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71709,7 +71744,7 @@ fn __action1718< __4, ); let __temp0 = (__start0, __temp0, __end0); - __action1527( + __action1523( mode, __0, __1, @@ -71724,7 +71759,7 @@ fn __action1718< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1719< +fn __action1715< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71744,7 +71779,7 @@ fn __action1719< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1527( + __action1523( mode, __0, __1, @@ -71759,7 +71794,7 @@ fn __action1719< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1720< +fn __action1716< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71767,7 +71802,7 @@ fn __action1720< __2: (TextSize, ast::TypeParams, TextSize), __3: (TextSize, ast::Parameters, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, ast::Expr, TextSize), + __5: (TextSize, ast::ParenthesizedExpr, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71779,7 +71814,7 @@ fn __action1720< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1528( + __action1524( mode, __0, __1, @@ -71794,14 +71829,14 @@ fn __action1720< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1721< +fn __action1717< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Identifier, TextSize), __2: (TextSize, ast::Parameters, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), __5: (TextSize, token::Tok, TextSize), __6: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71814,7 +71849,7 @@ fn __action1721< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1528( + __action1524( mode, __0, __1, @@ -71829,7 +71864,7 @@ fn __action1721< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1722< +fn __action1718< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71838,7 +71873,7 @@ fn __action1722< __3: (TextSize, ast::TypeParams, TextSize), __4: (TextSize, ast::Parameters, TextSize), __5: (TextSize, token::Tok, TextSize), - __6: (TextSize, ast::Expr, TextSize), + __6: (TextSize, ast::ParenthesizedExpr, TextSize), __7: (TextSize, token::Tok, TextSize), __8: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71850,7 +71885,7 @@ fn __action1722< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1529( + __action1525( mode, __0, __1, @@ -71866,7 +71901,7 @@ fn __action1722< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1723< +fn __action1719< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71874,7 +71909,7 @@ fn __action1723< __2: (TextSize, ast::Identifier, TextSize), __3: (TextSize, ast::Parameters, TextSize), __4: (TextSize, token::Tok, TextSize), - __5: (TextSize, ast::Expr, TextSize), + __5: (TextSize, ast::ParenthesizedExpr, TextSize), __6: (TextSize, token::Tok, TextSize), __7: (TextSize, ast::Suite, TextSize), ) -> ast::Stmt @@ -71887,7 +71922,7 @@ fn __action1723< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1529( + __action1525( mode, __0, __1, @@ -71903,7 +71938,7 @@ fn __action1723< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1724< +fn __action1720< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71921,7 +71956,7 @@ fn __action1724< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1530( + __action1526( mode, __0, __1, @@ -71934,7 +71969,7 @@ fn __action1724< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1725< +fn __action1721< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), @@ -71952,7 +71987,7 @@ fn __action1725< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1530( + __action1526( mode, __0, __1, @@ -71965,7 +72000,7 @@ fn __action1725< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1726< +fn __action1722< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -71984,7 +72019,7 @@ fn __action1726< __3, ); let __temp0 = (__start0, __temp0, __end0); - __action1531( + __action1527( mode, __0, __1, @@ -71998,7 +72033,7 @@ fn __action1726< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1727< +fn __action1723< >( mode: Mode, __0: (TextSize, alloc::vec::Vec, TextSize), @@ -72017,7 +72052,7 @@ fn __action1727< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1531( + __action1527( mode, __0, __1, @@ -72031,14 +72066,14 @@ fn __action1727< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1728< +fn __action1724< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Expr, TextSize), __2: (TextSize, ast::TypeParams, TextSize), __3: (TextSize, token::Tok, TextSize), - __4: (TextSize, ast::Expr, TextSize), + __4: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __2.0; @@ -72048,7 +72083,7 @@ fn __action1728< __2, ); let __temp0 = (__start0, __temp0, __end0); - __action1451( + __action1462( mode, __0, __1, @@ -72060,13 +72095,13 @@ fn __action1728< #[allow(unused_variables)] #[allow(clippy::too_many_arguments)] -fn __action1729< +fn __action1725< >( mode: Mode, __0: (TextSize, token::Tok, TextSize), __1: (TextSize, ast::Expr, TextSize), __2: (TextSize, token::Tok, TextSize), - __3: (TextSize, ast::Expr, TextSize), + __3: (TextSize, ast::ParenthesizedExpr, TextSize), ) -> ast::Stmt { let __start0 = __1.2; @@ -72077,7 +72112,7 @@ fn __action1729< &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action1451( + __action1462( mode, __0, __1, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__ann_assign_name.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__ann_assign_name.snap index dcc66532d9..3c0df82555 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__ann_assign_name.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__ann_assign_name.snap @@ -27,7 +27,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_attribute.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_attribute.snap index 64bf5bff6d..32a8e89e7d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_attribute.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_attribute.snap @@ -35,7 +35,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -44,7 +43,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -53,7 +51,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_for.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_for.snap index 2d4bf6ba9b..27d264d04f 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_for.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_for.snap @@ -24,7 +24,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -33,7 +32,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -42,7 +40,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list.snap index a7303252c6..3ff39502f3 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list.snap @@ -40,7 +40,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -49,7 +48,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -58,7 +56,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list_comp.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list_comp.snap index 247a636cb8..87867da60d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list_comp.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_list_comp.snap @@ -45,7 +45,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -54,7 +53,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -63,7 +61,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_name.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_name.snap index b358265457..000931fc19 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_name.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_name.snap @@ -25,7 +25,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -34,7 +33,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -43,7 +41,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_named_expr.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_named_expr.snap index d758617752..7cb15989d9 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_named_expr.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_named_expr.snap @@ -22,7 +22,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_set_comp.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_set_comp.snap index cc1480d630..92049ffffb 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_set_comp.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_set_comp.snap @@ -45,7 +45,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -54,7 +53,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -63,7 +61,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_starred.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_starred.snap index 7f0719e51a..035f4aa0ce 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_starred.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_starred.snap @@ -46,7 +46,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -55,7 +54,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -64,7 +62,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_subscript.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_subscript.snap index fef424d935..6b1b52325b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_subscript.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_subscript.snap @@ -38,7 +38,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -47,7 +46,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -56,7 +54,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_tuple.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_tuple.snap index 9291385f35..455b995728 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_tuple.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_tuple.snap @@ -40,7 +40,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -49,7 +48,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -58,7 +56,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_with.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_with.snap index f977b37549..8951904b64 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_with.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__assign_with.snap @@ -16,7 +16,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), optional_vars: Some( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_attribute.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_attribute.snap index 5c93b41285..e0c517de83 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_attribute.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_attribute.snap @@ -34,7 +34,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -43,7 +42,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -52,7 +50,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_name.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_name.snap index f568177cb4..5bdb12571d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_name.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_name.snap @@ -20,7 +20,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_subscript.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_subscript.snap index 62b3def51a..a427014c7b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_subscript.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__context__tests__aug_assign_subscript.snap @@ -37,7 +37,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -46,7 +45,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), Constant( @@ -55,7 +53,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_kw_only_args_with_defaults.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_kw_only_args_with_defaults.snap index 33a05a02ec..d2928c89a4 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_kw_only_args_with_defaults.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_kw_only_args_with_defaults.snap @@ -49,7 +49,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -71,7 +70,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap index 4276b8915b..892d7d8cd1 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults.snap @@ -86,7 +86,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -108,7 +107,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap index ba1ece7a57..eb52560edc 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs.snap @@ -95,7 +95,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -117,7 +116,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap index dc2888c7bd..8c36f8acb0 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_and_kw_only_args_with_defaults_and_varargs_and_kwargs.snap @@ -95,7 +95,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -117,7 +116,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_args_with_defaults.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_args_with_defaults.snap index 7c0459ab6c..4ef26c7957 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_args_with_defaults.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__function_pos_args_with_defaults.snap @@ -47,7 +47,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -69,7 +68,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args.snap index f5d230cfc2..c40d94e9b6 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args.snap @@ -63,7 +63,6 @@ Ok( value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args_with_defaults.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args_with_defaults.snap index 838ab8abd4..84eec0e2bf 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args_with_defaults.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_kw_only_args_with_defaults.snap @@ -46,7 +46,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -68,7 +67,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), @@ -83,7 +81,6 @@ Ok( value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_no_args.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_no_args.snap index 4b90995b00..305dc3c54f 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_no_args.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_no_args.snap @@ -17,7 +17,6 @@ Ok( value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_and_kw_only_args.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_and_kw_only_args.snap index a3eff7188b..cdd389a9a4 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_and_kw_only_args.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_and_kw_only_args.snap @@ -88,7 +88,6 @@ Ok( value: Int( 0, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args.snap index 1f8c1d0d3a..895dd7d413 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args.snap @@ -63,7 +63,6 @@ Ok( value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args_with_defaults.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args_with_defaults.snap index 9760d71f28..07c2993d30 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args_with_defaults.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__function__tests__lambda_pos_args_with_defaults.snap @@ -44,7 +44,6 @@ Ok( value: Int( 20, ), - kind: None, }, ), ), @@ -66,7 +65,6 @@ Ok( value: Int( 30, ), - kind: None, }, ), ), @@ -83,7 +81,6 @@ Ok( value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__assignment.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__assignment.snap index 89978a14e8..c4232bccf1 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__assignment.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__assignment.snap @@ -3,20 +3,44 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_source(source) --- [ - Name { - name: "a_variable", - }, - Equal, - Int { - value: 99, - }, - Plus, - Int { - value: 2, - }, - Minus, - Int { - value: 0, - }, - Newline, + ( + Name { + name: "a_variable", + }, + 0..10, + ), + ( + Equal, + 11..12, + ), + ( + Int { + value: 99, + }, + 13..15, + ), + ( + Plus, + 16..17, + ), + ( + Int { + value: 2, + }, + 18..19, + ), + ( + Minus, + 19..20, + ), + ( + Int { + value: 0, + }, + 20..21, + ), + ( + Newline, + 21..21, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_mac_eol.snap new file mode 100644 index 0000000000..5a0e7933e9 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_mac_eol.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: comment_until_eol(MAC_EOL) +--- +[ + ( + Int { + value: 123, + }, + 0..3, + ), + ( + Comment( + "# Foo", + ), + 5..10, + ), + ( + Newline, + 10..11, + ), + ( + Int { + value: 456, + }, + 11..14, + ), + ( + Newline, + 14..14, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_unix_eol.snap new file mode 100644 index 0000000000..3fdbd4c10f --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_unix_eol.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: comment_until_eol(UNIX_EOL) +--- +[ + ( + Int { + value: 123, + }, + 0..3, + ), + ( + Comment( + "# Foo", + ), + 5..10, + ), + ( + Newline, + 10..11, + ), + ( + Int { + value: 456, + }, + 11..14, + ), + ( + Newline, + 14..14, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_windows_eol.snap new file mode 100644 index 0000000000..fcf5cfcb80 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__comment_until_windows_eol.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: comment_until_eol(WINDOWS_EOL) +--- +[ + ( + Int { + value: 123, + }, + 0..3, + ), + ( + Comment( + "# Foo", + ), + 5..10, + ), + ( + Newline, + 10..12, + ), + ( + Int { + value: 456, + }, + 12..15, + ), + ( + Newline, + 15..15, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_mac_eol.snap new file mode 100644 index 0000000000..498d3cc426 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_mac_eol.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: double_dedent_with_eol(MAC_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..11, + ), + ( + Indent, + 11..12, + ), + ( + If, + 12..14, + ), + ( + Name { + name: "x", + }, + 15..16, + ), + ( + Colon, + 16..17, + ), + ( + Newline, + 17..18, + ), + ( + NonLogicalNewline, + 18..19, + ), + ( + Indent, + 19..21, + ), + ( + Return, + 21..27, + ), + ( + Int { + value: 99, + }, + 28..30, + ), + ( + Newline, + 30..31, + ), + ( + NonLogicalNewline, + 31..32, + ), + ( + Dedent, + 32..32, + ), + ( + Dedent, + 32..32, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_mac_eol.snap new file mode 100644 index 0000000000..a27a11a6cb --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_mac_eol.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: double_dedent_with_tabs_eol(MAC_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..11, + ), + ( + Indent, + 11..12, + ), + ( + If, + 12..14, + ), + ( + Name { + name: "x", + }, + 15..16, + ), + ( + Colon, + 16..17, + ), + ( + Newline, + 17..18, + ), + ( + NonLogicalNewline, + 18..19, + ), + ( + Indent, + 19..22, + ), + ( + Return, + 22..28, + ), + ( + Int { + value: 99, + }, + 29..31, + ), + ( + Newline, + 31..32, + ), + ( + NonLogicalNewline, + 32..33, + ), + ( + Dedent, + 33..33, + ), + ( + Dedent, + 33..33, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_unix_eol.snap new file mode 100644 index 0000000000..69fe4a3cce --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_unix_eol.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: double_dedent_with_tabs_eol(UNIX_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..11, + ), + ( + Indent, + 11..12, + ), + ( + If, + 12..14, + ), + ( + Name { + name: "x", + }, + 15..16, + ), + ( + Colon, + 16..17, + ), + ( + Newline, + 17..18, + ), + ( + NonLogicalNewline, + 18..19, + ), + ( + Indent, + 19..22, + ), + ( + Return, + 22..28, + ), + ( + Int { + value: 99, + }, + 29..31, + ), + ( + Newline, + 31..32, + ), + ( + NonLogicalNewline, + 32..33, + ), + ( + Dedent, + 33..33, + ), + ( + Dedent, + 33..33, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_windows_eol.snap new file mode 100644 index 0000000000..f07534c23e --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_tabs_windows_eol.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: double_dedent_with_tabs_eol(WINDOWS_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..12, + ), + ( + Indent, + 12..13, + ), + ( + If, + 13..15, + ), + ( + Name { + name: "x", + }, + 16..17, + ), + ( + Colon, + 17..18, + ), + ( + Newline, + 18..20, + ), + ( + NonLogicalNewline, + 20..22, + ), + ( + Indent, + 22..25, + ), + ( + Return, + 25..31, + ), + ( + Int { + value: 99, + }, + 32..34, + ), + ( + Newline, + 34..36, + ), + ( + NonLogicalNewline, + 36..38, + ), + ( + Dedent, + 38..38, + ), + ( + Dedent, + 38..38, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_unix_eol.snap new file mode 100644 index 0000000000..49b3db404d --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_unix_eol.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: double_dedent_with_eol(UNIX_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..11, + ), + ( + Indent, + 11..12, + ), + ( + If, + 12..14, + ), + ( + Name { + name: "x", + }, + 15..16, + ), + ( + Colon, + 16..17, + ), + ( + Newline, + 17..18, + ), + ( + NonLogicalNewline, + 18..19, + ), + ( + Indent, + 19..21, + ), + ( + Return, + 21..27, + ), + ( + Int { + value: 99, + }, + 28..30, + ), + ( + Newline, + 30..31, + ), + ( + NonLogicalNewline, + 31..32, + ), + ( + Dedent, + 32..32, + ), + ( + Dedent, + 32..32, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_windows_eol.snap new file mode 100644 index 0000000000..2ebebf4483 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__double_dedent_with_windows_eol.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: double_dedent_with_eol(WINDOWS_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..12, + ), + ( + Indent, + 12..13, + ), + ( + If, + 13..15, + ), + ( + Name { + name: "x", + }, + 16..17, + ), + ( + Colon, + 17..18, + ), + ( + Newline, + 18..20, + ), + ( + NonLogicalNewline, + 20..22, + ), + ( + Indent, + 22..24, + ), + ( + Return, + 24..30, + ), + ( + Int { + value: 99, + }, + 31..33, + ), + ( + Newline, + 33..35, + ), + ( + NonLogicalNewline, + 35..37, + ), + ( + Dedent, + 37..37, + ), + ( + Dedent, + 37..37, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__empty_ipython_escape_command.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__empty_ipython_escape_command.snap index a64dbdcce5..133690977b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__empty_ipython_escape_command.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__empty_ipython_escape_command.snap @@ -3,49 +3,103 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_jupyter_source(source) --- [ - IpyEscapeCommand { - value: "", - kind: Magic, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Magic2, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Shell, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: ShCap, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Paren, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Quote, - }, - Newline, - IpyEscapeCommand { - value: "", - kind: Quote2, - }, - Newline, + ( + IpyEscapeCommand { + value: "", + kind: Magic, + }, + 0..1, + ), + ( + Newline, + 1..2, + ), + ( + IpyEscapeCommand { + value: "", + kind: Magic2, + }, + 2..4, + ), + ( + Newline, + 4..5, + ), + ( + IpyEscapeCommand { + value: "", + kind: Shell, + }, + 5..6, + ), + ( + Newline, + 6..7, + ), + ( + IpyEscapeCommand { + value: "", + kind: ShCap, + }, + 7..9, + ), + ( + Newline, + 9..10, + ), + ( + IpyEscapeCommand { + value: "", + kind: Help, + }, + 10..11, + ), + ( + Newline, + 11..12, + ), + ( + IpyEscapeCommand { + value: "", + kind: Help2, + }, + 12..14, + ), + ( + Newline, + 14..15, + ), + ( + IpyEscapeCommand { + value: "", + kind: Paren, + }, + 15..16, + ), + ( + Newline, + 16..17, + ), + ( + IpyEscapeCommand { + value: "", + kind: Quote, + }, + 17..18, + ), + ( + Newline, + 18..19, + ), + ( + IpyEscapeCommand { + value: "", + kind: Quote2, + }, + 19..20, + ), + ( + Newline, + 20..20, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__escape_unicode_name.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__escape_unicode_name.snap new file mode 100644 index 0000000000..e161662695 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__escape_unicode_name.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: lex_source(source) +--- +[ + ( + String { + value: "\\N{EN SPACE}", + kind: String, + triple_quoted: false, + }, + 0..14, + ), + ( + Newline, + 14..14, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_mac_eol.snap new file mode 100644 index 0000000000..96de2fd392 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_mac_eol.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: indentation_with_eol(MAC_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..11, + ), + ( + Indent, + 11..15, + ), + ( + Return, + 15..21, + ), + ( + Int { + value: 99, + }, + 22..24, + ), + ( + Newline, + 24..25, + ), + ( + NonLogicalNewline, + 25..26, + ), + ( + Dedent, + 26..26, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_unix_eol.snap new file mode 100644 index 0000000000..c680d32089 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_unix_eol.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: indentation_with_eol(UNIX_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..11, + ), + ( + Indent, + 11..15, + ), + ( + Return, + 15..21, + ), + ( + Int { + value: 99, + }, + 22..24, + ), + ( + Newline, + 24..25, + ), + ( + NonLogicalNewline, + 25..26, + ), + ( + Dedent, + 26..26, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_windows_eol.snap new file mode 100644 index 0000000000..acd7bc7f68 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__indentation_with_windows_eol.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: indentation_with_eol(WINDOWS_EOL) +--- +[ + ( + Def, + 0..3, + ), + ( + Name { + name: "foo", + }, + 4..7, + ), + ( + Lpar, + 7..8, + ), + ( + Rpar, + 8..9, + ), + ( + Colon, + 9..10, + ), + ( + Newline, + 10..12, + ), + ( + Indent, + 12..16, + ), + ( + Return, + 16..22, + ), + ( + Int { + value: 99, + }, + 23..25, + ), + ( + Newline, + 25..27, + ), + ( + NonLogicalNewline, + 27..29, + ), + ( + Dedent, + 29..29, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command.snap index 2948f80190..dc3d3ec217 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command.snap @@ -3,59 +3,125 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_jupyter_source(source) --- [ - IpyEscapeCommand { - value: "foo", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "timeit a = b", - kind: Magic, - }, - Newline, - IpyEscapeCommand { - value: "timeit a % 3", - kind: Magic, - }, - Newline, - IpyEscapeCommand { - value: "matplotlib --inline", - kind: Magic, - }, - Newline, - IpyEscapeCommand { - value: "pwd && ls -a | sed 's/^/\\\\ /'", - kind: Shell, - }, - Newline, - IpyEscapeCommand { - value: "cd /Users/foo/Library/Application\\ Support/", - kind: ShCap, - }, - Newline, - IpyEscapeCommand { - value: "foo 1 2", - kind: Paren, - }, - Newline, - IpyEscapeCommand { - value: "foo 1 2", - kind: Quote, - }, - Newline, - IpyEscapeCommand { - value: "foo 1 2", - kind: Quote2, - }, - Newline, - IpyEscapeCommand { - value: "ls", - kind: Shell, - }, - Newline, + ( + IpyEscapeCommand { + value: "foo", + kind: Help, + }, + 0..4, + ), + ( + Newline, + 4..5, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help2, + }, + 5..10, + ), + ( + Newline, + 10..11, + ), + ( + IpyEscapeCommand { + value: "timeit a = b", + kind: Magic, + }, + 11..24, + ), + ( + Newline, + 24..25, + ), + ( + IpyEscapeCommand { + value: "timeit a % 3", + kind: Magic, + }, + 25..38, + ), + ( + Newline, + 38..39, + ), + ( + IpyEscapeCommand { + value: "matplotlib --inline", + kind: Magic, + }, + 39..65, + ), + ( + Newline, + 65..66, + ), + ( + IpyEscapeCommand { + value: "pwd && ls -a | sed 's/^/\\\\ /'", + kind: Shell, + }, + 66..103, + ), + ( + Newline, + 103..104, + ), + ( + IpyEscapeCommand { + value: "cd /Users/foo/Library/Application\\ Support/", + kind: ShCap, + }, + 104..149, + ), + ( + Newline, + 149..150, + ), + ( + IpyEscapeCommand { + value: "foo 1 2", + kind: Paren, + }, + 150..158, + ), + ( + Newline, + 158..159, + ), + ( + IpyEscapeCommand { + value: "foo 1 2", + kind: Quote, + }, + 159..167, + ), + ( + Newline, + 167..168, + ), + ( + IpyEscapeCommand { + value: "foo 1 2", + kind: Quote2, + }, + 168..176, + ), + ( + Newline, + 176..177, + ), + ( + IpyEscapeCommand { + value: "ls", + kind: Shell, + }, + 177..180, + ), + ( + Newline, + 180..180, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_assignment.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_assignment.snap index 8556594ddd..07b029d90d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_assignment.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_assignment.snap @@ -3,40 +3,88 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_jupyter_source(source) --- [ - Name { - name: "pwd", - }, - Equal, - IpyEscapeCommand { - value: "pwd", - kind: Shell, - }, - Newline, - Name { - name: "foo", - }, - Equal, - IpyEscapeCommand { - value: "timeit a = b", - kind: Magic, - }, - Newline, - Name { - name: "bar", - }, - Equal, - IpyEscapeCommand { - value: "timeit a % 3", - kind: Magic, - }, - Newline, - Name { - name: "baz", - }, - Equal, - IpyEscapeCommand { - value: "matplotlib inline", - kind: Magic, - }, - Newline, + ( + Name { + name: "pwd", + }, + 0..3, + ), + ( + Equal, + 4..5, + ), + ( + IpyEscapeCommand { + value: "pwd", + kind: Shell, + }, + 6..10, + ), + ( + Newline, + 10..11, + ), + ( + Name { + name: "foo", + }, + 11..14, + ), + ( + Equal, + 15..16, + ), + ( + IpyEscapeCommand { + value: "timeit a = b", + kind: Magic, + }, + 17..30, + ), + ( + Newline, + 30..31, + ), + ( + Name { + name: "bar", + }, + 31..34, + ), + ( + Equal, + 35..36, + ), + ( + IpyEscapeCommand { + value: "timeit a % 3", + kind: Magic, + }, + 37..50, + ), + ( + Newline, + 50..51, + ), + ( + Name { + name: "baz", + }, + 51..54, + ), + ( + Equal, + 55..56, + ), + ( + IpyEscapeCommand { + value: "matplotlib inline", + kind: Magic, + }, + 57..85, + ), + ( + Newline, + 85..85, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_indentation.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_indentation.snap index a9dc876c1c..1a3d7e016c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_indentation.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_indentation.snap @@ -3,15 +3,39 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_jupyter_source(source) --- [ - If, - True, - Colon, - Newline, - Indent, - IpyEscapeCommand { - value: "matplotlib --inline", - kind: Magic, - }, - Newline, - Dedent, + ( + If, + 0..2, + ), + ( + True, + 3..7, + ), + ( + Colon, + 7..8, + ), + ( + Newline, + 8..9, + ), + ( + Indent, + 9..13, + ), + ( + IpyEscapeCommand { + value: "matplotlib --inline", + kind: Magic, + }, + 13..43, + ), + ( + Newline, + 43..43, + ), + ( + Dedent, + 43..43, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_mac_eol.snap new file mode 100644 index 0000000000..c10f2fb977 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_mac_eol.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: ipython_escape_command_line_continuation_eol(MAC_EOL) +--- +[ + ( + IpyEscapeCommand { + value: "matplotlib --inline", + kind: Magic, + }, + 0..24, + ), + ( + Newline, + 24..24, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_unix_eol.snap new file mode 100644 index 0000000000..938d150f9e --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_unix_eol.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: ipython_escape_command_line_continuation_eol(UNIX_EOL) +--- +[ + ( + IpyEscapeCommand { + value: "matplotlib --inline", + kind: Magic, + }, + 0..24, + ), + ( + Newline, + 24..24, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_windows_eol.snap new file mode 100644 index 0000000000..c5f5d29dd0 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_windows_eol.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: ipython_escape_command_line_continuation_eol(WINDOWS_EOL) +--- +[ + ( + IpyEscapeCommand { + value: "matplotlib --inline", + kind: Magic, + }, + 0..25, + ), + ( + Newline, + 25..25, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_mac_eol_and_eof.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_mac_eol_and_eof.snap new file mode 100644 index 0000000000..ffee4a7eec --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_mac_eol_and_eof.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: ipython_escape_command_line_continuation_with_eol_and_eof(MAC_EOL) +--- +[ + ( + IpyEscapeCommand { + value: "matplotlib ", + kind: Magic, + }, + 0..14, + ), + ( + Newline, + 14..14, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_unix_eol_and_eof.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_unix_eol_and_eof.snap new file mode 100644 index 0000000000..e5227d0a06 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_unix_eol_and_eof.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: ipython_escape_command_line_continuation_with_eol_and_eof(UNIX_EOL) +--- +[ + ( + IpyEscapeCommand { + value: "matplotlib ", + kind: Magic, + }, + 0..14, + ), + ( + Newline, + 14..14, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_windows_eol_and_eof.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_windows_eol_and_eof.snap new file mode 100644 index 0000000000..7950d33905 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_escape_command_line_continuation_with_windows_eol_and_eof.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: ipython_escape_command_line_continuation_with_eol_and_eof(WINDOWS_EOL) +--- +[ + ( + IpyEscapeCommand { + value: "matplotlib ", + kind: Magic, + }, + 0..15, + ), + ( + Newline, + 15..15, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_help_end_escape_command.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_help_end_escape_command.snap index bcdfb44e19..b760410a5e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_help_end_escape_command.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__ipython_help_end_escape_command.snap @@ -3,84 +3,180 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_jupyter_source(source) --- [ - IpyEscapeCommand { - value: "foo", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: " foo ?", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "foo???", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "?foo???", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "foo", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: " ?", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "??", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "%foo", - kind: Help, - }, - Newline, - IpyEscapeCommand { - value: "%foo", - kind: Help2, - }, - Newline, - IpyEscapeCommand { - value: "foo???", - kind: Magic2, - }, - Newline, - IpyEscapeCommand { - value: "pwd", - kind: Help, - }, - Newline, + ( + IpyEscapeCommand { + value: "foo", + kind: Help, + }, + 0..5, + ), + ( + Newline, + 5..6, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help, + }, + 6..15, + ), + ( + Newline, + 15..16, + ), + ( + IpyEscapeCommand { + value: " foo ?", + kind: Help2, + }, + 16..27, + ), + ( + Newline, + 27..28, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help2, + }, + 28..34, + ), + ( + Newline, + 34..35, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help2, + }, + 35..42, + ), + ( + Newline, + 42..43, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help, + }, + 43..50, + ), + ( + Newline, + 50..51, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help2, + }, + 51..59, + ), + ( + Newline, + 59..60, + ), + ( + IpyEscapeCommand { + value: "foo???", + kind: Help2, + }, + 60..68, + ), + ( + Newline, + 68..69, + ), + ( + IpyEscapeCommand { + value: "?foo???", + kind: Help2, + }, + 69..78, + ), + ( + Newline, + 78..79, + ), + ( + IpyEscapeCommand { + value: "foo", + kind: Help, + }, + 79..92, + ), + ( + Newline, + 92..93, + ), + ( + IpyEscapeCommand { + value: " ?", + kind: Help2, + }, + 93..99, + ), + ( + Newline, + 99..100, + ), + ( + IpyEscapeCommand { + value: "??", + kind: Help2, + }, + 100..104, + ), + ( + Newline, + 104..105, + ), + ( + IpyEscapeCommand { + value: "%foo", + kind: Help, + }, + 105..110, + ), + ( + Newline, + 110..111, + ), + ( + IpyEscapeCommand { + value: "%foo", + kind: Help2, + }, + 111..117, + ), + ( + Newline, + 117..118, + ), + ( + IpyEscapeCommand { + value: "foo???", + kind: Magic2, + }, + 118..126, + ), + ( + Newline, + 126..127, + ), + ( + IpyEscapeCommand { + value: "pwd", + kind: Help, + }, + 127..132, + ), + ( + Newline, + 132..132, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_empty.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_empty.snap new file mode 100644 index 0000000000..34d9125a63 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_empty.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: lex_source(&source) +--- +[ + ( + Int { + value: 99232, + }, + 0..5, + ), + ( + Comment( + "#", + ), + 7..8, + ), + ( + Newline, + 8..8, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_long.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_long.snap new file mode 100644 index 0000000000..0731cf4711 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_long.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: lex_source(&source) +--- +[ + ( + Int { + value: 99232, + }, + 0..5, + ), + ( + Comment( + "# foo", + ), + 7..12, + ), + ( + Newline, + 12..12, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_single_whitespace.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_single_whitespace.snap new file mode 100644 index 0000000000..f248b93ef1 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_single_whitespace.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: lex_source(&source) +--- +[ + ( + Int { + value: 99232, + }, + 0..5, + ), + ( + Comment( + "# ", + ), + 7..9, + ), + ( + Newline, + 9..9, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_whitespace.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_whitespace.snap new file mode 100644 index 0000000000..4593910098 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__line_comment_whitespace.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: lex_source(&source) +--- +[ + ( + Int { + value: 99232, + }, + 0..5, + ), + ( + Comment( + "# ", + ), + 7..10, + ), + ( + Newline, + 10..10, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__logical_newline_line_comment.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__logical_newline_line_comment.snap index ac0200ef45..944ad882a0 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__logical_newline_line_comment.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__logical_newline_line_comment.snap @@ -3,12 +3,24 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_source(source) --- [ - Comment( - "#Hello", + ( + Comment( + "#Hello", + ), + 0..6, ), - NonLogicalNewline, - Comment( - "#World", + ( + NonLogicalNewline, + 6..7, + ), + ( + Comment( + "#World", + ), + 7..13, + ), + ( + NonLogicalNewline, + 13..14, ), - NonLogicalNewline, ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_mac_eol.snap new file mode 100644 index 0000000000..0a0a9fb1da --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_mac_eol.snap @@ -0,0 +1,142 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: newline_in_brackets_eol(MAC_EOL) +--- +[ + ( + Name { + name: "x", + }, + 0..1, + ), + ( + Equal, + 2..3, + ), + ( + Lsqb, + 4..5, + ), + ( + NonLogicalNewline, + 5..6, + ), + ( + NonLogicalNewline, + 6..7, + ), + ( + Int { + value: 1, + }, + 11..12, + ), + ( + Comma, + 12..13, + ), + ( + Int { + value: 2, + }, + 13..14, + ), + ( + NonLogicalNewline, + 14..15, + ), + ( + Comma, + 15..16, + ), + ( + Lpar, + 16..17, + ), + ( + Int { + value: 3, + }, + 17..18, + ), + ( + Comma, + 18..19, + ), + ( + NonLogicalNewline, + 19..20, + ), + ( + Int { + value: 4, + }, + 20..21, + ), + ( + Comma, + 21..22, + ), + ( + NonLogicalNewline, + 22..23, + ), + ( + Rpar, + 23..24, + ), + ( + Comma, + 24..25, + ), + ( + Lbrace, + 26..27, + ), + ( + NonLogicalNewline, + 27..28, + ), + ( + Int { + value: 5, + }, + 28..29, + ), + ( + Comma, + 29..30, + ), + ( + NonLogicalNewline, + 30..31, + ), + ( + Int { + value: 6, + }, + 31..32, + ), + ( + Comma, + 32..33, + ), + ( + Int { + value: 7, + }, + 35..36, + ), + ( + Rbrace, + 36..37, + ), + ( + Rsqb, + 37..38, + ), + ( + Newline, + 38..39, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_unix_eol.snap new file mode 100644 index 0000000000..c3df5dbd24 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_unix_eol.snap @@ -0,0 +1,142 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: newline_in_brackets_eol(UNIX_EOL) +--- +[ + ( + Name { + name: "x", + }, + 0..1, + ), + ( + Equal, + 2..3, + ), + ( + Lsqb, + 4..5, + ), + ( + NonLogicalNewline, + 5..6, + ), + ( + NonLogicalNewline, + 6..7, + ), + ( + Int { + value: 1, + }, + 11..12, + ), + ( + Comma, + 12..13, + ), + ( + Int { + value: 2, + }, + 13..14, + ), + ( + NonLogicalNewline, + 14..15, + ), + ( + Comma, + 15..16, + ), + ( + Lpar, + 16..17, + ), + ( + Int { + value: 3, + }, + 17..18, + ), + ( + Comma, + 18..19, + ), + ( + NonLogicalNewline, + 19..20, + ), + ( + Int { + value: 4, + }, + 20..21, + ), + ( + Comma, + 21..22, + ), + ( + NonLogicalNewline, + 22..23, + ), + ( + Rpar, + 23..24, + ), + ( + Comma, + 24..25, + ), + ( + Lbrace, + 26..27, + ), + ( + NonLogicalNewline, + 27..28, + ), + ( + Int { + value: 5, + }, + 28..29, + ), + ( + Comma, + 29..30, + ), + ( + NonLogicalNewline, + 30..31, + ), + ( + Int { + value: 6, + }, + 31..32, + ), + ( + Comma, + 32..33, + ), + ( + Int { + value: 7, + }, + 35..36, + ), + ( + Rbrace, + 36..37, + ), + ( + Rsqb, + 37..38, + ), + ( + Newline, + 38..39, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_windows_eol.snap new file mode 100644 index 0000000000..34184c68a9 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__newline_in_brackets_windows_eol.snap @@ -0,0 +1,142 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: newline_in_brackets_eol(WINDOWS_EOL) +--- +[ + ( + Name { + name: "x", + }, + 0..1, + ), + ( + Equal, + 2..3, + ), + ( + Lsqb, + 4..5, + ), + ( + NonLogicalNewline, + 5..7, + ), + ( + NonLogicalNewline, + 7..9, + ), + ( + Int { + value: 1, + }, + 13..14, + ), + ( + Comma, + 14..15, + ), + ( + Int { + value: 2, + }, + 15..16, + ), + ( + NonLogicalNewline, + 16..18, + ), + ( + Comma, + 18..19, + ), + ( + Lpar, + 19..20, + ), + ( + Int { + value: 3, + }, + 20..21, + ), + ( + Comma, + 21..22, + ), + ( + NonLogicalNewline, + 22..24, + ), + ( + Int { + value: 4, + }, + 24..25, + ), + ( + Comma, + 25..26, + ), + ( + NonLogicalNewline, + 26..28, + ), + ( + Rpar, + 28..29, + ), + ( + Comma, + 29..30, + ), + ( + Lbrace, + 31..32, + ), + ( + NonLogicalNewline, + 32..34, + ), + ( + Int { + value: 5, + }, + 34..35, + ), + ( + Comma, + 35..36, + ), + ( + NonLogicalNewline, + 36..38, + ), + ( + Int { + value: 6, + }, + 38..39, + ), + ( + Comma, + 39..40, + ), + ( + Int { + value: 7, + }, + 43..44, + ), + ( + Rbrace, + 44..45, + ), + ( + Rsqb, + 45..46, + ), + ( + Newline, + 46..48, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__non_logical_newline_in_string_continuation.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__non_logical_newline_in_string_continuation.snap index 96203f7c24..8722395390 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__non_logical_newline_in_string_continuation.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__non_logical_newline_in_string_continuation.snap @@ -3,32 +3,68 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_source(source) --- [ - Lpar, - NonLogicalNewline, - String { - value: "a", - kind: String, - triple_quoted: false, - }, - NonLogicalNewline, - String { - value: "b", - kind: String, - triple_quoted: false, - }, - NonLogicalNewline, - NonLogicalNewline, - String { - value: "c", - kind: String, - triple_quoted: false, - }, - String { - value: "d", - kind: String, - triple_quoted: false, - }, - NonLogicalNewline, - Rpar, - Newline, + ( + Lpar, + 0..1, + ), + ( + NonLogicalNewline, + 1..2, + ), + ( + String { + value: "a", + kind: String, + triple_quoted: false, + }, + 6..9, + ), + ( + NonLogicalNewline, + 9..10, + ), + ( + String { + value: "b", + kind: String, + triple_quoted: false, + }, + 14..17, + ), + ( + NonLogicalNewline, + 17..18, + ), + ( + NonLogicalNewline, + 18..19, + ), + ( + String { + value: "c", + kind: String, + triple_quoted: false, + }, + 23..26, + ), + ( + String { + value: "d", + kind: String, + triple_quoted: false, + }, + 33..36, + ), + ( + NonLogicalNewline, + 36..37, + ), + ( + Rpar, + 37..38, + ), + ( + Newline, + 38..38, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__numbers.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__numbers.snap index 272d88b186..91493ac6b0 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__numbers.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__numbers.snap @@ -3,40 +3,76 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_source(source) --- [ - Int { - value: 47, - }, - Int { - value: 10, - }, - Int { - value: 13, - }, - Int { - value: 0, - }, - Int { - value: 123, - }, - Int { - value: 1234567890, - }, - Float { - value: 0.2, - }, - Float { - value: 100.0, - }, - Float { - value: 2100.0, - }, - Complex { - real: 0.0, - imag: 2.0, - }, - Complex { - real: 0.0, - imag: 2.2, - }, - Newline, + ( + Int { + value: 47, + }, + 0..4, + ), + ( + Int { + value: 10, + }, + 5..9, + ), + ( + Int { + value: 13, + }, + 10..16, + ), + ( + Int { + value: 0, + }, + 17..18, + ), + ( + Int { + value: 123, + }, + 19..22, + ), + ( + Int { + value: 1234567890, + }, + 23..36, + ), + ( + Float { + value: 0.2, + }, + 37..40, + ), + ( + Float { + value: 100.0, + }, + 41..45, + ), + ( + Float { + value: 2100.0, + }, + 46..51, + ), + ( + Complex { + real: 0.0, + imag: 2.0, + }, + 52..54, + ), + ( + Complex { + real: 0.0, + imag: 2.2, + }, + 55..59, + ), + ( + Newline, + 59..59, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__operators.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__operators.snap index cc5b0e86f7..9da473b1d5 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__operators.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__operators.snap @@ -3,10 +3,28 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_source(source) --- [ - DoubleSlash, - DoubleSlash, - DoubleSlashEqual, - Slash, - Slash, - Newline, + ( + DoubleSlash, + 0..2, + ), + ( + DoubleSlash, + 2..4, + ), + ( + DoubleSlashEqual, + 4..7, + ), + ( + Slash, + 7..8, + ), + ( + Slash, + 9..10, + ), + ( + Newline, + 10..10, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string.snap index d4d89e878d..91e6df9067 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string.snap @@ -3,50 +3,80 @@ source: crates/ruff_python_parser/src/lexer.rs expression: lex_source(source) --- [ - String { - value: "double", - kind: String, - triple_quoted: false, - }, - String { - value: "single", - kind: String, - triple_quoted: false, - }, - String { - value: "can\\'t", - kind: String, - triple_quoted: false, - }, - String { - value: "\\\\\\\"", - kind: String, - triple_quoted: false, - }, - String { - value: "\\t\\r\\n", - kind: String, - triple_quoted: false, - }, - String { - value: "\\g", - kind: String, - triple_quoted: false, - }, - String { - value: "raw\\'", - kind: RawString, - triple_quoted: false, - }, - String { - value: "\\420", - kind: String, - triple_quoted: false, - }, - String { - value: "\\200\\0a", - kind: String, - triple_quoted: false, - }, - Newline, + ( + String { + value: "double", + kind: String, + triple_quoted: false, + }, + 0..8, + ), + ( + String { + value: "single", + kind: String, + triple_quoted: false, + }, + 9..17, + ), + ( + String { + value: "can\\'t", + kind: String, + triple_quoted: false, + }, + 18..26, + ), + ( + String { + value: "\\\\\\\"", + kind: String, + triple_quoted: false, + }, + 27..33, + ), + ( + String { + value: "\\t\\r\\n", + kind: String, + triple_quoted: false, + }, + 34..42, + ), + ( + String { + value: "\\g", + kind: String, + triple_quoted: false, + }, + 43..47, + ), + ( + String { + value: "raw\\'", + kind: RawString, + triple_quoted: false, + }, + 48..56, + ), + ( + String { + value: "\\420", + kind: String, + triple_quoted: false, + }, + 57..63, + ), + ( + String { + value: "\\200\\0a", + kind: String, + triple_quoted: false, + }, + 64..73, + ), + ( + Newline, + 73..73, + ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_mac_eol.snap new file mode 100644 index 0000000000..3b87087587 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_mac_eol.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: string_continuation_with_eol(MAC_EOL) +--- +[ + ( + String { + value: "abc\\\rdef", + kind: String, + triple_quoted: false, + }, + 0..10, + ), + ( + Newline, + 10..10, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_unix_eol.snap new file mode 100644 index 0000000000..3c048c9288 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_unix_eol.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: string_continuation_with_eol(UNIX_EOL) +--- +[ + ( + String { + value: "abc\\\ndef", + kind: String, + triple_quoted: false, + }, + 0..10, + ), + ( + Newline, + 10..10, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_windows_eol.snap new file mode 100644 index 0000000000..6fcab6148c --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__string_continuation_with_windows_eol.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: string_continuation_with_eol(WINDOWS_EOL) +--- +[ + ( + String { + value: "abc\\\r\ndef", + kind: String, + triple_quoted: false, + }, + 0..11, + ), + ( + Newline, + 11..11, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_mac_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_mac_eol.snap new file mode 100644 index 0000000000..2dbdd88758 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_mac_eol.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: triple_quoted_eol(MAC_EOL) +--- +[ + ( + String { + value: "\r test string\r ", + kind: String, + triple_quoted: true, + }, + 0..21, + ), + ( + Newline, + 21..21, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_unix_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_unix_eol.snap new file mode 100644 index 0000000000..15c12ec794 --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_unix_eol.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: triple_quoted_eol(UNIX_EOL) +--- +[ + ( + String { + value: "\n test string\n ", + kind: String, + triple_quoted: true, + }, + 0..21, + ), + ( + Newline, + 21..21, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_windows_eol.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_windows_eol.snap new file mode 100644 index 0000000000..42b181d25b --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__lexer__tests__triple_quoted_windows_eol.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_python_parser/src/lexer.rs +expression: triple_quoted_eol(WINDOWS_EOL) +--- +[ + ( + String { + value: "\r\n test string\r\n ", + kind: String, + triple_quoted: true, + }, + 0..23, + ), + ( + Newline, + 23..23, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__dict_unpacking.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__dict_unpacking.snap index ff72ab9daf..8a488120ea 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__dict_unpacking.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__dict_unpacking.snap @@ -13,10 +13,10 @@ Dict( value: Str( StringConstant { value: "a", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), @@ -28,10 +28,10 @@ Dict( value: Str( StringConstant { value: "d", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), @@ -43,10 +43,10 @@ Dict( value: Str( StringConstant { value: "b", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), Name( @@ -62,10 +62,10 @@ Dict( value: Str( StringConstant { value: "e", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__generator_expression_argument.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__generator_expression_argument.snap index 4617a2a863..b5ffa4e7a6 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__generator_expression_argument.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__generator_expression_argument.snap @@ -14,10 +14,10 @@ Call( value: Str( StringConstant { value: " ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), attr: Identifier { @@ -73,10 +73,10 @@ Call( value: Str( StringConstant { value: "LIMIT %d", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), op: Mod, @@ -93,7 +93,6 @@ Call( ExprConstant { range: 76..80, value: None, - kind: None, }, ), }, @@ -117,10 +116,10 @@ Call( value: Str( StringConstant { value: "OFFSET %d", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), op: Mod, @@ -137,7 +136,6 @@ Call( ExprConstant { range: 128..132, value: None, - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap index 3d06cd7aeb..240f724d1b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__ipython_escape_commands.snap @@ -227,7 +227,6 @@ Module( value: Int( 5, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match.snap index 3725090fcc..dc723a1468 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match.snap @@ -17,10 +17,10 @@ expression: parse_ast value: Str( StringConstant { value: "test", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), @@ -32,7 +32,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ], @@ -105,10 +104,10 @@ expression: parse_ast value: Str( StringConstant { value: "label", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), @@ -120,10 +119,10 @@ expression: parse_ast value: Str( StringConstant { value: "test", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], @@ -142,10 +141,10 @@ expression: parse_ast value: Str( StringConstant { value: "label", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], @@ -260,7 +259,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -274,7 +272,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -302,7 +299,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -338,7 +334,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -352,7 +347,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -380,7 +374,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -416,7 +409,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -444,7 +436,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match_as_identifier.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match_as_identifier.snap index 38a83842e2..af623dab7c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match_as_identifier.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__match_as_identifier.snap @@ -633,7 +633,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -670,7 +669,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -695,7 +693,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 2, ), - kind: None, }, ), }, @@ -813,7 +810,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 12, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals.snap index 563840d8a7..183ac67430 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals.snap @@ -1,6 +1,6 @@ --- source: crates/ruff_python_parser/src/parser.rs -expression: "ast::Suite::parse(source, \"\").unwrap()" +expression: "parse_suite(source, \"\").unwrap()" --- [ Assign( @@ -21,7 +21,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 123456789, ), - kind: None, }, ), }, @@ -44,7 +43,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 123456, ), - kind: None, }, ), }, @@ -67,7 +65,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 0.1, ), - kind: None, }, ), }, @@ -90,7 +87,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 1.0, ), - kind: None, }, ), }, @@ -113,7 +109,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 10.0, ), - kind: None, }, ), }, @@ -136,7 +131,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 0.1, ), - kind: None, }, ), }, @@ -159,7 +153,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 1.00000001, ), - kind: None, }, ), }, @@ -182,7 +175,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 123456789.12345679, ), - kind: None, }, ), }, @@ -205,7 +197,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( inf, ), - kind: None, }, ), }, @@ -228,7 +219,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( inf, ), - kind: None, }, ), }, @@ -252,7 +242,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" real: 0.0, imag: 123456789.0, }, - kind: None, }, ), }, @@ -276,7 +265,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" real: 0.0, imag: 123456789.12345679, }, - kind: None, }, ), }, @@ -299,7 +287,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 727756, ), - kind: None, }, ), }, @@ -322,7 +309,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 11, ), - kind: None, }, ), }, @@ -345,7 +331,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 511, ), - kind: None, }, ), }, @@ -368,7 +353,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Float( 6e-9, ), - kind: None, }, ), }, @@ -391,7 +375,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 10000, ), - kind: None, }, ), }, @@ -414,7 +397,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 133333, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals_attribute_access.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals_attribute_access.snap index 5b5e4e8acf..a4f07acef7 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals_attribute_access.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__numeric_literals_attribute_access.snap @@ -27,7 +27,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( 0.1, ), - kind: None, }, ), attr: Identifier { @@ -67,7 +66,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( 1.0, ), - kind: None, }, ), attr: Identifier { @@ -100,7 +98,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( 10.0, ), - kind: None, }, ), attr: Identifier { @@ -133,7 +130,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( 0.1, ), - kind: None, }, ), attr: Identifier { @@ -169,7 +165,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( 123456789.12345679, ), - kind: None, }, ), attr: Identifier { @@ -209,7 +204,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( inf, ), - kind: None, }, ), attr: Identifier { @@ -245,7 +239,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( inf, ), - kind: None, }, ), attr: Identifier { @@ -286,7 +279,6 @@ expression: "parse_suite(source, \"\").unwrap()" real: 0.0, imag: 123456789.0, }, - kind: None, }, ), attr: Identifier { @@ -323,7 +315,6 @@ expression: "parse_suite(source, \"\").unwrap()" real: 0.0, imag: 123456789.12345679, }, - kind: None, }, ), attr: Identifier { @@ -348,7 +339,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 11, ), - kind: None, }, ), attr: Identifier { @@ -396,7 +386,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 727756, ), - kind: None, }, ), attr: Identifier { @@ -439,7 +428,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 11, ), - kind: None, }, ), attr: Identifier { @@ -479,7 +467,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 511, ), - kind: None, }, ), attr: Identifier { @@ -515,7 +502,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Float( 6e-9, ), - kind: None, }, ), attr: Identifier { @@ -557,7 +543,6 @@ expression: "parse_suite(source, \"\").unwrap()" real: 0.0, imag: 100.0, }, - kind: None, }, ), }, @@ -576,7 +561,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 10, ), - kind: None, }, ), attr: Identifier { @@ -594,7 +578,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 363..366, value: Ellipsis, - kind: None, }, ), }, @@ -624,7 +607,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 100, ), - kind: None, }, ), slice: Name( @@ -660,7 +642,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 100, ), - kind: None, }, ), arguments: Arguments { diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parenthesized_with_statement.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parenthesized_with_statement.snap new file mode 100644 index 0000000000..12e66dfc7e --- /dev/null +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parenthesized_with_statement.snap @@ -0,0 +1,676 @@ +--- +source: crates/ruff_python_parser/src/parser.rs +expression: "parse_suite(source, \"\").unwrap()" +--- +[ + With( + StmtWith { + range: 0..21, + is_async: false, + items: [ + WithItem { + range: 6..9, + context_expr: Name( + ExprName { + range: 7..8, + id: "a", + ctx: Load, + }, + ), + optional_vars: None, + }, + WithItem { + range: 11..14, + context_expr: Name( + ExprName { + range: 12..13, + id: "b", + ctx: Load, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 17..21, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 22..56, + is_async: false, + items: [ + WithItem { + range: 28..31, + context_expr: Name( + ExprName { + range: 29..30, + id: "a", + ctx: Load, + }, + ), + optional_vars: None, + }, + WithItem { + range: 33..36, + context_expr: Name( + ExprName { + range: 34..35, + id: "b", + ctx: Load, + }, + ), + optional_vars: None, + }, + WithItem { + range: 38..44, + context_expr: Name( + ExprName { + range: 38..39, + id: "c", + ctx: Load, + }, + ), + optional_vars: Some( + Name( + ExprName { + range: 43..44, + id: "d", + ctx: Store, + }, + ), + ), + }, + WithItem { + range: 46..49, + context_expr: Name( + ExprName { + range: 47..48, + id: "e", + ctx: Load, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 52..56, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 57..74, + is_async: false, + items: [ + WithItem { + range: 63..64, + context_expr: Name( + ExprName { + range: 63..64, + id: "a", + ctx: Load, + }, + ), + optional_vars: None, + }, + WithItem { + range: 66..67, + context_expr: Name( + ExprName { + range: 66..67, + id: "b", + ctx: Load, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 70..74, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 75..97, + is_async: false, + items: [ + WithItem { + range: 80..91, + context_expr: Tuple( + ExprTuple { + range: 80..86, + elts: [ + Name( + ExprName { + range: 81..82, + id: "a", + ctx: Load, + }, + ), + Name( + ExprName { + range: 84..85, + id: "b", + ctx: Load, + }, + ), + ], + ctx: Load, + }, + ), + optional_vars: Some( + Name( + ExprName { + range: 90..91, + id: "c", + ctx: Store, + }, + ), + ), + }, + ], + body: [ + Pass( + StmtPass { + range: 93..97, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 98..122, + is_async: false, + items: [ + WithItem { + range: 104..115, + context_expr: Tuple( + ExprTuple { + range: 104..110, + elts: [ + Name( + ExprName { + range: 105..106, + id: "a", + ctx: Load, + }, + ), + Name( + ExprName { + range: 108..109, + id: "b", + ctx: Load, + }, + ), + ], + ctx: Load, + }, + ), + optional_vars: Some( + Name( + ExprName { + range: 114..115, + id: "c", + ctx: Store, + }, + ), + ), + }, + ], + body: [ + Pass( + StmtPass { + range: 118..122, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 123..142, + is_async: false, + items: [ + WithItem { + range: 129..135, + context_expr: Name( + ExprName { + range: 129..130, + id: "a", + ctx: Load, + }, + ), + optional_vars: Some( + Name( + ExprName { + range: 134..135, + id: "b", + ctx: Store, + }, + ), + ), + }, + ], + body: [ + Pass( + StmtPass { + range: 138..142, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 143..157, + is_async: false, + items: [ + WithItem { + range: 149..150, + context_expr: Name( + ExprName { + range: 149..150, + id: "a", + ctx: Load, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 153..157, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 158..177, + is_async: false, + items: [ + WithItem { + range: 164..170, + context_expr: NamedExpr( + ExprNamedExpr { + range: 164..170, + target: Name( + ExprName { + range: 164..165, + id: "a", + ctx: Store, + }, + ), + value: Constant( + ExprConstant { + range: 169..170, + value: Int( + 0, + ), + }, + ), + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 173..177, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 178..202, + is_async: false, + items: [ + WithItem { + range: 184..195, + context_expr: NamedExpr( + ExprNamedExpr { + range: 184..190, + target: Name( + ExprName { + range: 184..185, + id: "a", + ctx: Store, + }, + ), + value: Constant( + ExprConstant { + range: 189..190, + value: Int( + 0, + ), + }, + ), + }, + ), + optional_vars: Some( + Name( + ExprName { + range: 195..196, + id: "x", + ctx: Store, + }, + ), + ), + }, + ], + body: [ + Pass( + StmtPass { + range: 198..202, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 203..219, + is_async: false, + items: [ + WithItem { + range: 209..212, + context_expr: Name( + ExprName { + range: 210..211, + id: "a", + ctx: Load, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 215..219, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 220..241, + is_async: false, + items: [ + WithItem { + range: 226..234, + context_expr: NamedExpr( + ExprNamedExpr { + range: 227..233, + target: Name( + ExprName { + range: 227..228, + id: "a", + ctx: Store, + }, + ), + value: Constant( + ExprConstant { + range: 232..233, + value: Int( + 0, + ), + }, + ), + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 237..241, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 242..271, + is_async: false, + items: [ + WithItem { + range: 248..254, + context_expr: Name( + ExprName { + range: 248..249, + id: "a", + ctx: Load, + }, + ), + optional_vars: Some( + Name( + ExprName { + range: 253..254, + id: "b", + ctx: Store, + }, + ), + ), + }, + WithItem { + range: 256..264, + context_expr: NamedExpr( + ExprNamedExpr { + range: 257..263, + target: Name( + ExprName { + range: 257..258, + id: "a", + ctx: Store, + }, + ), + value: Constant( + ExprConstant { + range: 262..263, + value: Int( + 0, + ), + }, + ), + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 267..271, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 272..296, + is_async: false, + items: [ + WithItem { + range: 278..279, + context_expr: Name( + ExprName { + range: 278..279, + id: "a", + ctx: Load, + }, + ), + optional_vars: None, + }, + WithItem { + range: 281..289, + context_expr: NamedExpr( + ExprNamedExpr { + range: 282..288, + target: Name( + ExprName { + range: 282..283, + id: "a", + ctx: Store, + }, + ), + value: Constant( + ExprConstant { + range: 287..288, + value: Int( + 0, + ), + }, + ), + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 292..296, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 297..315, + is_async: false, + items: [ + WithItem { + range: 303..308, + context_expr: Yield( + ExprYield { + range: 303..308, + value: None, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 311..315, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 316..341, + is_async: false, + items: [ + WithItem { + range: 322..334, + context_expr: YieldFrom( + ExprYieldFrom { + range: 322..334, + value: Name( + ExprName { + range: 333..334, + id: "a", + ctx: Load, + }, + ), + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 337..341, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 342..362, + is_async: false, + items: [ + WithItem { + range: 348..355, + context_expr: Yield( + ExprYield { + range: 349..354, + value: None, + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 358..362, + }, + ), + ], + }, + ), + With( + StmtWith { + range: 363..390, + is_async: false, + items: [ + WithItem { + range: 369..383, + context_expr: YieldFrom( + ExprYieldFrom { + range: 370..382, + value: Name( + ExprName { + range: 381..382, + id: "a", + ctx: Load, + }, + ), + }, + ), + optional_vars: None, + }, + ], + body: [ + Pass( + StmtPass { + range: 386..390, + }, + ), + ], + }, + ), +] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class.snap index e567e1d4e4..e604da964b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class.snap @@ -119,10 +119,10 @@ expression: "parse_suite(source, \"\").unwrap()" value: Str( StringConstant { value: "default", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class_generic_types.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class_generic_types.snap index 7353f1cc14..e6e6d0cb2a 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class_generic_types.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_class_generic_types.snap @@ -43,7 +43,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 26..29, value: Ellipsis, - kind: None, }, ), }, @@ -99,7 +98,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 73..76, value: Ellipsis, - kind: None, }, ), }, @@ -170,7 +168,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 135..138, value: Ellipsis, - kind: None, }, ), }, @@ -228,7 +225,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 178..181, value: Ellipsis, - kind: None, }, ), }, @@ -286,7 +282,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 220..223, value: Ellipsis, - kind: None, }, ), }, @@ -333,7 +328,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 258..261, value: Ellipsis, - kind: None, }, ), }, @@ -380,7 +374,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 293..296, value: Ellipsis, - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_double_list_comprehension.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_double_list_comprehension.snap index 6fc16e9abf..33b3655934 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_double_list_comprehension.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_double_list_comprehension.snap @@ -84,7 +84,6 @@ ListComp( value: Int( 5, ), - kind: None, }, ), ], @@ -110,7 +109,6 @@ ListComp( value: Int( 10, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_f_string.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_f_string.snap index f65e153bea..edf6c9b3a7 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_f_string.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_f_string.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_function_definition.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_function_definition.snap index cf0f7df886..a3c85c3621 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_function_definition.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_function_definition.snap @@ -43,7 +43,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 17..20, value: Ellipsis, - kind: None, }, ), }, @@ -123,7 +122,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 50..53, value: Ellipsis, - kind: None, }, ), }, @@ -211,7 +209,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 88..91, value: Ellipsis, - kind: None, }, ), }, @@ -314,7 +311,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 135..138, value: Ellipsis, - kind: None, }, ), }, @@ -387,7 +383,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 168..171, value: Ellipsis, - kind: None, }, ), }, @@ -491,7 +486,6 @@ expression: "parse_suite(source, \"\").unwrap()" ExprConstant { range: 227..230, value: Ellipsis, - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_if_elif_else.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_if_elif_else.snap index 3601f016e0..2d6d498b5c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_if_elif_else.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_if_elif_else.snap @@ -12,7 +12,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), body: [ @@ -25,7 +24,6 @@ expression: parse_ast value: Int( 10, ), - kind: None, }, ), }, @@ -41,7 +39,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ), @@ -55,7 +52,6 @@ expression: parse_ast value: Int( 20, ), - kind: None, }, ), }, @@ -75,7 +71,6 @@ expression: parse_ast value: Int( 30, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_kwargs.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_kwargs.snap index dbf2ae2258..c5b72bceaf 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_kwargs.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_kwargs.snap @@ -25,10 +25,10 @@ expression: parse_ast value: Str( StringConstant { value: "positional", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], @@ -47,7 +47,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_lambda_no_args.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_lambda_no_args.snap index c8c73c80c8..3e92dce298 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_lambda_no_args.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_lambda_no_args.snap @@ -16,7 +16,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_named_expression_generator_comprehension.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_named_expression_generator_comprehension.snap index 6455470589..0c42ad4b82 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_named_expression_generator_comprehension.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_named_expression_generator_comprehension.snap @@ -32,7 +32,6 @@ GeneratorExp( value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_2.snap index 583746f9dd..8da6210beb 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_2.snap @@ -25,10 +25,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), Constant( @@ -37,7 +37,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_hello.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_hello.snap index fab7de1e6a..67d725d1ff 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_hello.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_print_hello.snap @@ -25,10 +25,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_string.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_string.snap index 301501a7d9..40dd83f830 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_string.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_string.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_tuples.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_tuples.snap index d3d1e40f71..105599e5e3 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_tuples.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_tuples.snap @@ -1,6 +1,6 @@ --- source: crates/ruff_python_parser/src/parser.rs -expression: "ast::Suite::parse(source, \"\").unwrap()" +expression: "parse_suite(source, \"\").unwrap()" --- [ Assign( @@ -40,7 +40,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 4, ), - kind: None, }, ), Constant( @@ -49,7 +48,6 @@ expression: "ast::Suite::parse(source, \"\").unwrap()" value: Int( 5, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_type_declaration.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_type_declaration.snap index 2186cc9152..7b0b60304e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_type_declaration.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__parse_type_declaration.snap @@ -84,10 +84,10 @@ expression: "parse_suite(source, \"\").unwrap()" value: Str( StringConstant { value: "ForwardRefY", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__patma.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__patma.snap index 65e4d11977..622287a6be 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__patma.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__patma.snap @@ -30,7 +30,6 @@ expression: parse_ast real: 0.0, imag: 0.0, }, - kind: None, }, ), }, @@ -57,7 +56,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -130,7 +128,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -162,7 +159,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -174,7 +170,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ), @@ -197,7 +192,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -215,7 +209,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -227,7 +220,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ), @@ -250,7 +242,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -269,7 +260,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), cases: [ @@ -288,7 +278,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -302,7 +291,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -316,7 +304,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -330,7 +317,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), }, @@ -358,7 +344,6 @@ expression: parse_ast value: Bool( true, ), - kind: None, }, ), }, @@ -398,7 +383,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -412,7 +396,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -433,7 +416,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -447,7 +429,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -478,7 +459,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -526,10 +506,10 @@ expression: parse_ast value: Str( StringConstant { value: "seq", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), @@ -559,10 +539,10 @@ expression: parse_ast value: Str( StringConstant { value: "map", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ), @@ -596,7 +576,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -614,7 +593,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -628,7 +606,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -668,7 +645,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -691,7 +667,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -713,7 +688,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -727,7 +701,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -768,7 +741,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ], @@ -800,7 +772,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -818,7 +789,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -832,7 +802,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -867,10 +836,10 @@ expression: parse_ast value: Str( StringConstant { value: "X", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, @@ -906,7 +875,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -941,7 +909,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -976,7 +943,6 @@ expression: parse_ast value: Float( 0.25, ), - kind: None, }, ), op: Add, @@ -987,7 +953,6 @@ expression: parse_ast real: 0.0, imag: 1.75, }, - kind: None, }, ), }, @@ -1014,7 +979,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1051,7 +1015,6 @@ expression: parse_ast real: 0.0, imag: 0.0, }, - kind: None, }, ), }, @@ -1078,7 +1041,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1097,7 +1059,6 @@ expression: parse_ast value: Int( 4, ), - kind: None, }, ), cases: [ @@ -1116,7 +1077,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1130,7 +1090,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1144,7 +1103,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -1158,7 +1116,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), }, @@ -1186,7 +1143,6 @@ expression: parse_ast value: Bool( true, ), - kind: None, }, ), }, @@ -1218,7 +1174,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1251,7 +1206,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1284,7 +1238,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ], @@ -1298,7 +1251,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1327,7 +1279,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1346,7 +1297,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -1360,7 +1310,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1389,7 +1338,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1431,7 +1379,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -1497,7 +1444,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1529,7 +1475,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1554,7 +1499,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1572,7 +1516,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1597,7 +1540,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1630,10 +1572,10 @@ expression: parse_ast value: Str( StringConstant { value: "foo", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], @@ -1695,7 +1637,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), Constant( @@ -1704,7 +1645,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -1713,7 +1653,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ], @@ -1736,7 +1675,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1750,7 +1688,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1775,7 +1712,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -1803,7 +1739,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1839,7 +1774,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1867,7 +1801,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1889,7 +1822,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1903,7 +1835,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -1943,7 +1874,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ), @@ -1975,7 +1905,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -1997,7 +1926,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -2011,7 +1939,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2039,7 +1966,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -2119,7 +2045,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2158,7 +2083,6 @@ expression: parse_ast value: Float( 0.25, ), - kind: None, }, ), }, @@ -2171,7 +2095,6 @@ expression: parse_ast real: 0.0, imag: 1.75, }, - kind: None, }, ), }, @@ -2198,7 +2121,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2268,7 +2190,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2353,7 +2274,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2402,7 +2322,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2434,7 +2353,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2459,7 +2377,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2510,7 +2427,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2559,7 +2475,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2581,10 +2496,10 @@ expression: parse_ast value: Str( StringConstant { value: "", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, @@ -2612,7 +2527,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -2630,10 +2544,10 @@ expression: parse_ast value: Str( StringConstant { value: "", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, @@ -2658,7 +2572,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -2713,7 +2626,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2798,7 +2710,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2838,7 +2749,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -2865,7 +2775,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -2892,7 +2801,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -2941,7 +2849,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -2969,7 +2876,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3002,7 +2908,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -3020,7 +2925,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -3034,7 +2938,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -3074,7 +2977,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3097,7 +2999,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -3119,7 +3020,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -3133,7 +3033,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -3174,7 +3073,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ], @@ -3206,7 +3104,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), ], @@ -3224,7 +3121,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -3238,7 +3134,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -3273,10 +3168,10 @@ expression: parse_ast value: Str( StringConstant { value: "X", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, @@ -3312,7 +3207,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -3347,7 +3241,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -3370,7 +3263,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), Constant( @@ -3379,7 +3271,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -3388,7 +3279,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ], @@ -3411,7 +3301,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3450,7 +3339,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3473,7 +3361,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), Constant( @@ -3482,7 +3369,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), Constant( @@ -3491,7 +3377,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ], @@ -3525,7 +3410,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), }, @@ -3553,7 +3437,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3615,7 +3498,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3704,7 +3586,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, @@ -3791,7 +3672,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__slice.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__slice.snap index f74e2cf50f..ed8946f614 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__slice.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__slice.snap @@ -22,7 +22,6 @@ Subscript( value: Int( 1, ), - kind: None, }, ), ), @@ -33,7 +32,6 @@ Subscript( value: Int( 2, ), - kind: None, }, ), ), @@ -44,7 +42,6 @@ Subscript( value: Int( 3, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__star_index.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__star_index.snap index 988198e3e5..a00b0453c3 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__star_index.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__star_index.snap @@ -35,7 +35,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), Starred( @@ -61,7 +60,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -99,7 +97,6 @@ expression: parse_ast value: Int( 0, ), - kind: None, }, ), Starred( @@ -125,7 +122,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), }, @@ -226,7 +222,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ), @@ -237,7 +232,6 @@ expression: parse_ast value: Int( 5, ), - kind: None, }, ), ), diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try.snap index e3fd432492..b9aab97c0d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try.snap @@ -30,7 +30,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ], @@ -89,10 +88,10 @@ expression: parse_ast value: Str( StringConstant { value: "caught ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -187,10 +186,10 @@ expression: parse_ast value: Str( StringConstant { value: "caught ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try_star.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try_star.snap index 7940ea7359..5f691af0cf 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try_star.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__try_star.snap @@ -30,10 +30,10 @@ expression: parse_ast value: Str( StringConstant { value: "eg", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), List( @@ -59,7 +59,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ], @@ -86,7 +85,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ], @@ -113,7 +111,6 @@ expression: parse_ast value: Int( 3, ), - kind: None, }, ), ], @@ -140,7 +137,6 @@ expression: parse_ast value: Int( 4, ), - kind: None, }, ), ], @@ -208,10 +204,10 @@ expression: parse_ast value: Str( StringConstant { value: "caught ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -253,10 +249,10 @@ expression: parse_ast value: Str( StringConstant { value: " with nested ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -343,10 +339,10 @@ expression: parse_ast value: Str( StringConstant { value: "caught ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -388,10 +384,10 @@ expression: parse_ast value: Str( StringConstant { value: " with nested ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__type_as_identifier.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__type_as_identifier.snap index 8b10562a32..5d6787776a 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__type_as_identifier.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__type_as_identifier.snap @@ -633,7 +633,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -749,7 +748,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 12, ), - kind: None, }, ), ], @@ -928,7 +926,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -958,7 +955,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -988,7 +984,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__variadic_generics.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__variadic_generics.snap index 891e02d914..5c43a8b07d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__variadic_generics.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__variadic_generics.snap @@ -80,7 +80,6 @@ expression: parse_ast ExprConstant { range: 46..49, value: Ellipsis, - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__with_statement.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__with_statement.snap index abae0fb4bc..74b8279ae4 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__with_statement.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__parser__tests__with_statement.snap @@ -16,7 +16,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: None, @@ -44,7 +43,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -80,7 +78,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: None, @@ -93,7 +90,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), optional_vars: None, @@ -121,7 +117,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -142,7 +137,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), optional_vars: Some( @@ -181,7 +175,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), body: Constant( @@ -190,7 +183,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), orelse: Constant( @@ -199,7 +191,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 2, ), - kind: None, }, ), }, @@ -232,7 +223,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), body: Constant( @@ -241,7 +231,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), orelse: Constant( @@ -250,7 +239,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 2, ), - kind: None, }, ), }, @@ -348,7 +336,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: None, @@ -376,7 +363,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -412,7 +398,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: None, @@ -444,7 +429,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), ], @@ -477,27 +461,25 @@ expression: "parse_suite(source, \"\").unwrap()" is_async: false, items: [ WithItem { - range: 239..243, + range: 239..240, context_expr: Constant( ExprConstant { range: 239..240, value: Int( 0, ), - kind: None, }, ), optional_vars: None, }, WithItem { - range: 239..243, + range: 242..243, context_expr: Constant( ExprConstant { range: 242..243, value: Int( 1, ), - kind: None, }, ), optional_vars: None, @@ -529,7 +511,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), Constant( @@ -538,7 +519,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), ], @@ -670,7 +650,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), Starred( @@ -719,7 +698,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), Starred( @@ -765,7 +743,7 @@ expression: "parse_suite(source, \"\").unwrap()" is_async: false, items: [ WithItem { - range: 361..369, + range: 362..368, context_expr: NamedExpr( ExprNamedExpr { range: 362..368, @@ -782,7 +760,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), }, @@ -805,7 +782,7 @@ expression: "parse_suite(source, \"\").unwrap()" is_async: false, items: [ WithItem { - range: 381..394, + range: 382..393, context_expr: NamedExpr( ExprNamedExpr { range: 382..388, @@ -822,7 +799,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), }, @@ -874,7 +850,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), }, @@ -895,7 +870,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -943,7 +917,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), }, @@ -964,7 +937,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), }, @@ -1006,7 +978,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -1042,7 +1013,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -1078,7 +1048,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -1099,7 +1068,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), optional_vars: Some( @@ -1135,7 +1103,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 0, ), - kind: None, }, ), optional_vars: Some( @@ -1156,7 +1123,6 @@ expression: "parse_suite(source, \"\").unwrap()" value: Int( 1, ), - kind: None, }, ), optional_vars: Some( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__backspace_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__backspace_alias.snap index 1d1aef73a6..f05fffeb99 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__backspace_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__backspace_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{8}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__bell_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__bell_alias.snap index 5c4b9fda0f..e0ef3c542a 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__bell_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__bell_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{7}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__carriage_return_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__carriage_return_alias.snap index f16ca7fce6..0f1a81266c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__carriage_return_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__carriage_return_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\r", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__character_tabulation_with_justification_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__character_tabulation_with_justification_alias.snap index ba1969efc4..f86cadd6cd 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__character_tabulation_with_justification_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__character_tabulation_with_justification_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{89}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__delete_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__delete_alias.snap index 4c9ef1738a..7ad63ab23d 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__delete_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__delete_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{7f}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__double_quoted_byte.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__double_quoted_byte.snap index 7ec79b41ff..99b35c5b40 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__double_quoted_byte.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__double_quoted_byte.snap @@ -272,7 +272,6 @@ expression: parse_ast implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_alias.snap index 7777636fcc..5efa42a127 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{1b}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_char_in_byte_literal.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_char_in_byte_literal.snap index 85a4d7705d..ff789cab8f 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_char_in_byte_literal.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_char_in_byte_literal.snap @@ -26,7 +26,6 @@ expression: parse_ast implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_octet.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_octet.snap index fc484d7a07..d32f060205 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_octet.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__escape_octet.snap @@ -21,7 +21,6 @@ expression: parse_ast implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__form_feed_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__form_feed_alias.snap index 2ec6f9f544..c974de85af 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__form_feed_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__form_feed_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{c}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap index 6b4a1a92c8..245d664aa8 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_constant_range.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "aaa", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -43,10 +43,10 @@ expression: parse_ast value: Str( StringConstant { value: "ccc", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -70,10 +70,10 @@ expression: parse_ast value: Str( StringConstant { value: "eee", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap index d96a1cef58..796b97b9ea 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_character.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "\\", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap index fe3c6d028e..17dc9dbe2b 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_escaped_newline.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "\n", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap index 35cff59a24..fcf985cc79 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_line_continuation.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "\\\n", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap index 655b3cc3d8..346124137f 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_base_more.snap @@ -9,10 +9,10 @@ expression: parse_ast value: Str( StringConstant { value: "mix ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( @@ -41,10 +41,10 @@ expression: parse_ast value: Str( StringConstant { value: " with text and ", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap index 22b250a8ce..e22f1f70ae 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_parse_self_documenting_format.snap @@ -31,10 +31,10 @@ expression: parse_ast value: Str( StringConstant { value: ">10", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap index 0b711c8cc9..654b947387 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__fstring_unescaped_newline.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "\n", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), FormattedValue( diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__hts_alias.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__hts_alias.snap index 8017bb4b35..3e699ccf70 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__hts_alias.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__hts_alias.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "\u{88}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap index 8680272f60..db3c59a638 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_1.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap index 8680272f60..db3c59a638 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_2.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap index 2c5e80aad5..d7887a62aa 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_3.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), FormattedValue( @@ -31,10 +31,10 @@ expression: parse_ast value: Str( StringConstant { value: "!", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), debug_text: None, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap index 19e8b7ae04..86e8c4f5b8 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_f_string_concat_4.snap @@ -16,10 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), FormattedValue( @@ -31,10 +31,10 @@ expression: parse_ast value: Str( StringConstant { value: "!", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), debug_text: None, @@ -48,10 +48,10 @@ expression: parse_ast value: Str( StringConstant { value: "again!", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap index 282eb79f97..ea76fa6ad4 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring.snap @@ -39,10 +39,10 @@ expression: parse_ast value: Str( StringConstant { value: "{foo}", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ] diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap index 5fc8c4d264..8a4ae20ea4 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_equals.snap @@ -15,7 +15,6 @@ expression: parse_ast value: Int( 42, ), - kind: None, }, ), ops: [ @@ -28,7 +27,6 @@ expression: parse_ast value: Int( 42, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap index 97525a5e10..752f06e9b2 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_concatenation_string_spec.snap @@ -29,10 +29,10 @@ expression: parse_ast value: Str( StringConstant { value: "", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), debug_text: None, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap index 31db5e6cf8..8a1149aa5c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_nested_string_spec.snap @@ -29,10 +29,10 @@ expression: parse_ast value: Str( StringConstant { value: "", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), debug_text: None, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap index 070ea1f20b..759c8bc9ad 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_equals.snap @@ -15,7 +15,6 @@ expression: parse_ast value: Int( 1, ), - kind: None, }, ), ops: [ @@ -28,7 +27,6 @@ expression: parse_ast value: Int( 2, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap index 5a621fc857..f4294c5bb3 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_fstring_not_nested_spec.snap @@ -26,10 +26,10 @@ expression: parse_ast value: Str( StringConstant { value: "spec", + unicode: false, implicit_concatenated: false, }, ), - kind: None, }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_concat.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_concat.snap index 2c5d32050d..2e3e059ba3 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_concat.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_concat.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_triple_quotes_with_kind.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_triple_quotes_with_kind.snap index 8e2e003f91..b7acd40d9e 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_triple_quotes_with_kind.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_string_triple_quotes_with_kind.snap @@ -12,12 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello, world!", + unicode: true, implicit_concatenated: false, }, ), - kind: Some( - "u", - ), }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap index 23593fee07..5f0ecabfed 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_1.snap @@ -16,12 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: true, implicit_concatenated: true, }, ), - kind: Some( - "u", - ), }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap index e6a8a74995..39610847fe 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_f_string_concat_2.snap @@ -16,12 +16,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world!", + unicode: true, implicit_concatenated: true, }, ), - kind: Some( - "u", - ), }, ), ], diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_1.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_1.snap index cb8d2848a9..9b1eeaf602 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_1.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_1.snap @@ -12,10 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: false, implicit_concatenated: true, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_2.snap index 6fdde47ad2..ea32b3ef27 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__parse_u_string_concat_2.snap @@ -12,12 +12,10 @@ expression: parse_ast value: Str( StringConstant { value: "Hello world", + unicode: true, implicit_concatenated: true, }, ), - kind: Some( - "u", - ), }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_1.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_1.snap index 37273bc676..b2d4114002 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_1.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_1.snap @@ -20,7 +20,6 @@ expression: parse_ast implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_2.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_2.snap index 558aae8c95..bd22e64b0c 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_2.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__raw_byte_literal_2.snap @@ -18,7 +18,6 @@ expression: parse_ast implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__single_quoted_byte.snap b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__single_quoted_byte.snap index 7ec79b41ff..99b35c5b40 100644 --- a/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__single_quoted_byte.snap +++ b/crates/ruff_python_parser/src/snapshots/ruff_python_parser__string__tests__single_quoted_byte.snap @@ -272,7 +272,6 @@ expression: parse_ast implicit_concatenated: false, }, ), - kind: None, }, ), }, diff --git a/crates/ruff_python_parser/src/string.rs b/crates/ruff_python_parser/src/string.rs index 936c4fdef1..0524473f12 100644 --- a/crates/ruff_python_parser/src/string.rs +++ b/crates/ruff_python_parser/src/string.rs @@ -386,7 +386,6 @@ impl<'a> StringParser<'a> { if !constant_piece.is_empty() { spec_constructor.push(Expr::from(ast::ExprConstant { value: std::mem::take(&mut constant_piece).into(), - kind: None, range: self.range(start_location), })); } @@ -407,7 +406,6 @@ impl<'a> StringParser<'a> { if !constant_piece.is_empty() { spec_constructor.push(Expr::from(ast::ExprConstant { value: std::mem::take(&mut constant_piece).into(), - kind: None, range: self.range(start_location), })); } @@ -445,7 +443,6 @@ impl<'a> StringParser<'a> { if !content.is_empty() { values.push(Expr::from(ast::ExprConstant { value: std::mem::take(&mut content).into(), - kind: None, range: self.range(start_location), })); } @@ -480,7 +477,6 @@ impl<'a> StringParser<'a> { if !content.is_empty() { values.push(Expr::from(ast::ExprConstant { value: content.into(), - kind: None, range: self.range(start_location), })); } @@ -512,7 +508,6 @@ impl<'a> StringParser<'a> { Ok(Expr::from(ast::ExprConstant { value: content.chars().map(|c| c as u8).collect::>().into(), - kind: None, range: self.range(start_location), })) } @@ -529,8 +524,11 @@ impl<'a> StringParser<'a> { } } Ok(Expr::from(ast::ExprConstant { - value: value.into(), - kind: self.kind.is_unicode().then(|| "u".to_string()), + value: ast::Constant::Str(ast::StringConstant { + value, + unicode: self.kind.is_unicode(), + implicit_concatenated: false, + }), range: self.range(start_location), })) } @@ -566,7 +564,7 @@ pub(crate) fn parse_strings( // Preserve the initial location and kind. let initial_start = values[0].0; let last_end = values.last().unwrap().2; - let initial_kind = (values[0].1 .1 == StringKind::Unicode).then(|| "u".to_owned()); + let is_initial_kind_unicode = values[0].1 .1 == StringKind::Unicode; let has_fstring = values .iter() .any(|(_, (_, kind, ..), _)| kind.is_any_fstring()); @@ -604,7 +602,6 @@ pub(crate) fn parse_strings( value: content, implicit_concatenated, }), - kind: None, range: TextRange::new(initial_start, last_end), } .into()); @@ -626,9 +623,9 @@ pub(crate) fn parse_strings( return Ok(ast::ExprConstant { value: Constant::Str(StringConstant { value: content.join(""), + unicode: is_initial_kind_unicode, implicit_concatenated, }), - kind: initial_kind, range: TextRange::new(initial_start, last_end), } .into()); @@ -644,9 +641,9 @@ pub(crate) fn parse_strings( Expr::Constant(ast::ExprConstant { value: Constant::Str(StringConstant { value: current.drain(..).collect::(), + unicode: is_initial_kind_unicode, implicit_concatenated, }), - kind: initial_kind.clone(), range: TextRange::new(start, end), }) }; diff --git a/crates/ruff_python_parser/src/token.rs b/crates/ruff_python_parser/src/token.rs index db159a0340..9bec604b8d 100644 --- a/crates/ruff_python_parser/src/token.rs +++ b/crates/ruff_python_parser/src/token.rs @@ -45,7 +45,7 @@ pub enum Tok { triple_quoted: bool, }, /// Token value for IPython escape commands. These are recognized by the lexer - /// only when the mode is [`Mode::Jupyter`]. + /// only when the mode is [`Mode::Ipython`]. IpyEscapeCommand { /// The magic command value. value: String, @@ -64,7 +64,7 @@ pub enum Tok { /// Token value for a dedent. Dedent, EndOfFile, - /// Token value for a question mark `?`. This is only used in [`Mode::Jupyter`]. + /// Token value for a question mark `?`. This is only used in [`Mode::Ipython`]. Question, /// Token value for a left parenthesis `(`. Lpar, @@ -211,7 +211,7 @@ pub enum Tok { impl Tok { pub fn start_marker(mode: Mode) -> Self { match mode { - Mode::Module | Mode::Jupyter => Tok::StartModule, + Mode::Module | Mode::Ipython => Tok::StartModule, Mode::Expression => Tok::StartExpression, } } diff --git a/crates/ruff_python_stdlib/Cargo.toml b/crates/ruff_python_stdlib/Cargo.toml index 167b9fad04..807ccc0f5c 100644 --- a/crates/ruff_python_stdlib/Cargo.toml +++ b/crates/ruff_python_stdlib/Cargo.toml @@ -13,3 +13,4 @@ license = { workspace = true } [lib] [dependencies] +unicode-ident = { workspace = true } diff --git a/crates/ruff_python_stdlib/src/identifiers.rs b/crates/ruff_python_stdlib/src/identifiers.rs index 18c0f9a4e6..ab29b3877c 100644 --- a/crates/ruff_python_stdlib/src/identifiers.rs +++ b/crates/ruff_python_stdlib/src/identifiers.rs @@ -1,3 +1,5 @@ +use unicode_ident::{is_xid_continue, is_xid_start}; + use crate::keyword::is_keyword; /// Returns `true` if a string is a valid Python identifier (e.g., variable @@ -5,12 +7,12 @@ use crate::keyword::is_keyword; pub fn is_identifier(name: &str) -> bool { // Is the first character a letter or underscore? let mut chars = name.chars(); - if !chars.next().is_some_and(|c| c.is_alphabetic() || c == '_') { + if !chars.next().is_some_and(is_identifier_start) { return false; } // Are the rest of the characters letters, digits, or underscores? - if !chars.all(|c| c.is_alphanumeric() || c == '_') { + if !chars.all(is_identifier_continuation) { return false; } @@ -22,6 +24,21 @@ pub fn is_identifier(name: &str) -> bool { true } +// Checks if the character c is a valid starting character as described +// in https://docs.python.org/3/reference/lexical_analysis.html#identifiers +fn is_identifier_start(c: char) -> bool { + matches!(c, 'a'..='z' | 'A'..='Z' | '_') || is_xid_start(c) +} + +// Checks if the character c is a valid continuation character as described +// in https://docs.python.org/3/reference/lexical_analysis.html#identifiers +fn is_identifier_continuation(c: char) -> bool { + match c { + 'a'..='z' | 'A'..='Z' | '_' | '0'..='9' => true, + c => is_xid_continue(c), + } +} + /// Returns `true` if a string is a private identifier, such that, when the /// identifier is defined in a class definition, it will be mangled prior to /// code generation. @@ -76,7 +93,25 @@ pub fn is_migration_name(name: &str) -> bool { #[cfg(test)] mod tests { - use crate::identifiers::{is_migration_name, is_module_name}; + use crate::identifiers::{is_identifier, is_migration_name, is_module_name}; + + #[test] + fn valid_identifiers() { + assert!(is_identifier("_abc")); + assert!(is_identifier("abc")); + assert!(is_identifier("_")); + assert!(is_identifier("a_b_c")); + assert!(is_identifier("abc123")); + assert!(is_identifier("abc_123")); + assert!(is_identifier("漢字")); + assert!(is_identifier("ひらがな")); + assert!(is_identifier("العربية")); + assert!(is_identifier("кириллица")); + assert!(is_identifier("πr")); + assert!(!is_identifier("")); + assert!(!is_identifier("percentile_co³t")); + assert!(!is_identifier("HelloWorld❤️")); + } #[test] fn module_name() { diff --git a/crates/ruff_python_trivia/Cargo.toml b/crates/ruff_python_trivia/Cargo.toml index f0f9861e5a..8ae3fad931 100644 --- a/crates/ruff_python_trivia/Cargo.toml +++ b/crates/ruff_python_trivia/Cargo.toml @@ -18,7 +18,7 @@ ruff_source_file = { path = "../ruff_source_file" } memchr = { workspace = true } smallvec = { workspace = true } -unic-ucd-ident = "0.9.0" +unicode-ident = { workspace = true } [dev-dependencies] insta = { workspace = true } diff --git a/crates/ruff_python_trivia/src/tokenizer.rs b/crates/ruff_python_trivia/src/tokenizer.rs index 93aa9fb16a..d7d0645f3f 100644 --- a/crates/ruff_python_trivia/src/tokenizer.rs +++ b/crates/ruff_python_trivia/src/tokenizer.rs @@ -1,5 +1,5 @@ use memchr::{memchr2, memchr3, memrchr3_iter}; -use unic_ucd_ident::{is_xid_continue, is_xid_start}; +use unicode_ident::{is_xid_continue, is_xid_start}; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; diff --git a/crates/ruff_source_file/src/locator.rs b/crates/ruff_source_file/src/locator.rs index 5198f1131f..9fc7a071bc 100644 --- a/crates/ruff_source_file/src/locator.rs +++ b/crates/ruff_source_file/src/locator.rs @@ -388,6 +388,59 @@ impl<'a> Locator<'a> { &self.contents[usize::from(offset)..] } + /// Finds the closest [`TextSize`] not exceeding the offset for which `is_char_boundary` is + /// `true`. + /// + /// Can be replaced with `str#floor_char_boundary` once it's stable. + /// + /// ## Examples + /// + /// ``` + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; + /// # use ruff_source_file::Locator; + /// + /// let locator = Locator::new("Hello"); + /// + /// assert_eq!( + /// locator.floor_char_boundary(TextSize::from(0)), + /// TextSize::from(0) + /// ); + /// + /// assert_eq!( + /// locator.floor_char_boundary(TextSize::from(5)), + /// TextSize::from(5) + /// ); + /// + /// let locator = Locator::new("α"); + /// + /// assert_eq!( + /// locator.floor_char_boundary(TextSize::from(0)), + /// TextSize::from(0) + /// ); + /// + /// assert_eq!( + /// locator.floor_char_boundary(TextSize::from(1)), + /// TextSize::from(0) + /// ); + /// + /// assert_eq!( + /// locator.floor_char_boundary(TextSize::from(2)), + /// TextSize::from(2) + /// ); + /// ``` + pub fn floor_char_boundary(&self, offset: TextSize) -> TextSize { + if offset >= self.text_len() { + self.text_len() + } else { + // We know that the character boundary is within four bytes. + (0u32..=3u32) + .map(TextSize::from) + .filter_map(|index| offset.checked_sub(index)) + .find(|offset| self.contents.is_char_boundary(offset.to_usize())) + .unwrap_or_default() + } + } + /// Take the source code between the given [`TextRange`]. #[inline] pub fn slice(&self, ranged: T) -> &'a str { diff --git a/crates/ruff_source_file/src/newlines.rs b/crates/ruff_source_file/src/newlines.rs index 91cb953dc7..ae8b3f2e6a 100644 --- a/crates/ruff_source_file/src/newlines.rs +++ b/crates/ruff_source_file/src/newlines.rs @@ -32,6 +32,7 @@ impl UniversalNewlines for str { /// assert_eq!(lines.next_back(), Some(Line::new("\r\n", TextSize::from(8)))); /// assert_eq!(lines.next(), None); /// ``` +#[derive(Clone)] pub struct UniversalNewlineIterator<'a> { text: &'a str, offset: TextSize, diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index 07a5b749bb..24d2359325 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -1,3 +1,4 @@ +use std::num::NonZeroU16; use std::path::Path; use js_sys::Error; @@ -8,9 +9,10 @@ use ruff::directives; use ruff::line_width::{LineLength, TabSize}; use ruff::linter::{check_path, LinterResult}; use ruff::registry::AsRule; -use ruff::settings::types::PythonVersion; +use ruff::settings::types::{PreviewMode, PythonVersion}; use ruff::settings::{defaults, flags, Settings}; -use ruff_formatter::{FormatResult, Formatted}; +use ruff::source_kind::SourceKind; +use ruff_formatter::{FormatResult, Formatted, LineWidth}; use ruff_python_ast::{Mod, PySourceType}; use ruff_python_codegen::Stylist; use ruff_python_formatter::{format_node, pretty_comments, PyFormatContext, PyFormatOptions}; @@ -128,6 +130,7 @@ impl Workspace { external: Some(Vec::default()), ignore: Some(Vec::default()), line_length: Some(LineLength::default()), + preview: Some(false), select: Some(defaults::PREFIXES.to_vec()), tab_size: Some(TabSize::default()), target_version: Some(PythonVersion::default()), @@ -164,6 +167,9 @@ impl Workspace { pub fn check(&self, contents: &str) -> Result { let source_type = PySourceType::default(); + // TODO(dhruvmanila): Support Jupyter Notebooks + let source_kind = SourceKind::Python(contents.to_string()); + // Tokenize once. let tokens: Vec = ruff_python_parser::tokenize(contents, source_type.as_mode()); @@ -194,7 +200,7 @@ impl Workspace { &directives, &self.settings, flags::Noqa::Enabled, - None, + &source_kind, source_type, ); @@ -232,7 +238,7 @@ impl Workspace { pub fn format(&self, contents: &str) -> Result { let parsed = ParsedModule::from_source(contents)?; - let formatted = parsed.format().map_err(into_error)?; + let formatted = parsed.format(&self.settings).map_err(into_error)?; let printed = formatted.print().map_err(into_error)?; Ok(printed.into_code()) @@ -240,16 +246,14 @@ impl Workspace { pub fn format_ir(&self, contents: &str) -> Result { let parsed = ParsedModule::from_source(contents)?; - let formatted = parsed.format().map_err(into_error)?; + let formatted = parsed.format(&self.settings).map_err(into_error)?; Ok(format!("{formatted}")) } pub fn comments(&self, contents: &str) -> Result { let parsed = ParsedModule::from_source(contents)?; - let formatted = parsed.format().map_err(into_error)?; - let comments = pretty_comments(&formatted, contents); - + let comments = pretty_comments(&parsed.module, &parsed.comment_ranges, contents); Ok(comments) } @@ -295,9 +299,14 @@ impl<'a> ParsedModule<'a> { }) } - fn format(&self) -> FormatResult> { + fn format(&self, settings: &Settings) -> FormatResult> { // TODO(konstin): Add an options for py/pyi to the UI (2/2) - let options = PyFormatOptions::from_source_type(PySourceType::default()); + let options = PyFormatOptions::from_source_type(PySourceType::default()) + .with_preview(match settings.preview { + PreviewMode::Disabled => ruff_python_formatter::PreviewMode::Disabled, + PreviewMode::Enabled => ruff_python_formatter::PreviewMode::Enabled, + }) + .with_line_width(LineWidth::from(NonZeroU16::from(settings.line_length))); format_node( &self.module, diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index a7ad93e686..105ef947fa 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -23,10 +23,11 @@ use ruff::registry::{Rule, RuleSet, INCOMPATIBLE_CODES}; use ruff::rule_selector::Specificity; use ruff::settings::rule_table::RuleTable; use ruff::settings::types::{ - FilePattern, FilePatternSet, PerFileIgnore, PythonVersion, SerializationFormat, Version, + FilePattern, FilePatternSet, PerFileIgnore, PreviewMode, PythonVersion, SerializationFormat, + Version, }; use ruff::settings::{defaults, resolve_per_file_ignores, AllSettings, CliSettings, Settings}; -use ruff::{fs, warn_user_once_by_id, RuleSelector, RUFF_PKG_VERSION}; +use ruff::{fs, warn_user, warn_user_once, warn_user_once_by_id, RuleSelector, RUFF_PKG_VERSION}; use ruff_cache::cache_dir; use rustc_hash::{FxHashMap, FxHashSet}; use shellexpand; @@ -67,6 +68,7 @@ pub struct Configuration { pub line_length: Option, pub logger_objects: Option>, pub namespace_packages: Option>, + pub preview: Option, pub required_version: Option, pub respect_gitignore: Option, pub show_fixes: Option, @@ -174,6 +176,7 @@ impl Configuration { .collect() }), logger_objects: self.logger_objects.unwrap_or_default(), + preview: self.preview.unwrap_or_default(), typing_modules: self.typing_modules.unwrap_or_default(), // Plugins flake8_annotations: self @@ -387,6 +390,7 @@ impl Configuration { .namespace_packages .map(|namespace_package| resolve_src(&namespace_package, project_root)) .transpose()?, + preview: options.preview.map(PreviewMode::from), per_file_ignores: options.per_file_ignores.map(|per_file_ignores| { per_file_ignores .into_iter() @@ -436,14 +440,17 @@ impl Configuration { } pub fn as_rule_table(&self) -> RuleTable { + let preview = self.preview.unwrap_or_default(); + // The select_set keeps track of which rules have been selected. - let mut select_set: RuleSet = defaults::PREFIXES.iter().flatten().collect(); - // The fixable set keeps track of which rules are fixable. - let mut fixable_set: RuleSet = RuleSelector::All - .into_iter() - .chain(&RuleSelector::Nursery) + let mut select_set: RuleSet = defaults::PREFIXES + .iter() + .flat_map(|selector| selector.rules(preview)) .collect(); + // The fixable set keeps track of which rules are fixable. + let mut fixable_set: RuleSet = RuleSelector::All.rules(preview).collect(); + // Ignores normally only subtract from the current set of selected // rules. By that logic the ignore in `select = [], ignore = ["E501"]` // would be effectless. Instead we carry over the ignores to the next @@ -453,7 +460,10 @@ impl Configuration { let mut carryover_ignores: Option<&[RuleSelector]> = None; let mut carryover_unfixables: Option<&[RuleSelector]> = None; + // Store selectors for displaying warnings let mut redirects = FxHashMap::default(); + let mut deprecated_nursery_selectors = FxHashSet::default(); + let mut ignored_preview_selectors = FxHashSet::default(); for selection in &self.rule_selections { // If a selection only specifies extend-select we cannot directly @@ -478,7 +488,7 @@ impl Configuration { .chain(selection.extend_select.iter()) .filter(|s| s.specificity() == spec) { - for rule in selector { + for rule in selector.rules(preview) { select_map_updates.insert(rule, true); } } @@ -488,7 +498,7 @@ impl Configuration { .chain(carriedover_ignores.into_iter().flatten()) .filter(|s| s.specificity() == spec) { - for rule in selector { + for rule in selector.rules(preview) { select_map_updates.insert(rule, false); } } @@ -500,7 +510,7 @@ impl Configuration { .chain(selection.extend_fixable.iter()) .filter(|s| s.specificity() == spec) { - for rule in selector { + for rule in selector.rules(preview) { fixable_map_updates.insert(rule, true); } } @@ -510,7 +520,7 @@ impl Configuration { .chain(carriedover_unfixables.into_iter().flatten()) .filter(|s| s.specificity() == spec) { - for rule in selector { + for rule in selector.rules(preview) { fixable_map_updates.insert(rule, false); } } @@ -564,8 +574,7 @@ impl Configuration { } } - // We insert redirects into the hashmap so that we - // can warn the users about remapped rule codes. + // Check for selections that require a warning for selector in selection .select .iter() @@ -576,6 +585,29 @@ impl Configuration { .chain(selection.unfixable.iter()) .chain(selection.extend_fixable.iter()) { + #[allow(deprecated)] + if matches!(selector, RuleSelector::Nursery) { + let suggestion = if preview.is_disabled() { + "Use the `--preview` flag instead." + } else { + "Use the `PREVIEW` selector instead." + }; + warn_user_once!("The `NURSERY` selector has been deprecated. {suggestion}"); + } + + if preview.is_disabled() { + if let RuleSelector::Rule { prefix, .. } = selector { + if prefix.rules().any(|rule| rule.is_nursery()) { + deprecated_nursery_selectors.insert(selector); + } + } + + // Check if the selector is empty because preview mode is disabled + if selector.rules(PreviewMode::Disabled).next().is_none() { + ignored_preview_selectors.insert(selector); + } + } + if let RuleSelector::Prefix { prefix, redirected_from: Some(redirect_from), @@ -596,6 +628,18 @@ impl Configuration { ); } + for selection in deprecated_nursery_selectors { + let (prefix, code) = selection.prefix_and_code(); + warn_user!("Selection of nursery rule `{prefix}{code}` without the `--preview` flag is deprecated.",); + } + + for selection in ignored_preview_selectors { + let (prefix, code) = selection.prefix_and_code(); + warn_user!( + "Selection `{prefix}{code}` has no effect because the `--preview` flag was not included.", + ); + } + let mut rules = RuleTable::empty(); for rule in select_set { @@ -676,6 +720,7 @@ impl Configuration { show_fixes: self.show_fixes.or(config.show_fixes), src: self.src.or(config.src), target_version: self.target_version.or(config.target_version), + preview: self.preview.or(config.preview), task_tags: self.task_tags.or(config.task_tags), typing_modules: self.typing_modules.or(config.typing_modules), // Plugins @@ -756,26 +801,124 @@ pub fn resolve_src(src: &[String], project_root: &Path) -> Result> #[cfg(test)] mod tests { use crate::configuration::{Configuration, RuleSelection}; - use ruff::codes::Pycodestyle; - use ruff::registry::{Rule, RuleSet}; + use ruff::codes::{Flake8Copyright, Pycodestyle, Refurb}; + use ruff::registry::{Linter, Rule, RuleSet}; + use ruff::settings::types::PreviewMode; + use ruff::RuleSelector; + + const NURSERY_RULES: &[Rule] = &[ + Rule::MissingCopyrightNotice, + Rule::IndentationWithInvalidMultiple, + Rule::NoIndentedBlock, + Rule::UnexpectedIndentation, + Rule::IndentationWithInvalidMultipleComment, + Rule::NoIndentedBlockComment, + Rule::UnexpectedIndentationComment, + Rule::OverIndented, + Rule::WhitespaceAfterOpenBracket, + Rule::WhitespaceBeforeCloseBracket, + Rule::WhitespaceBeforePunctuation, + Rule::WhitespaceBeforeParameters, + Rule::MultipleSpacesBeforeOperator, + Rule::MultipleSpacesAfterOperator, + Rule::TabBeforeOperator, + Rule::TabAfterOperator, + Rule::MissingWhitespaceAroundOperator, + Rule::MissingWhitespaceAroundArithmeticOperator, + Rule::MissingWhitespaceAroundBitwiseOrShiftOperator, + Rule::MissingWhitespaceAroundModuloOperator, + Rule::MissingWhitespace, + Rule::MultipleSpacesAfterComma, + Rule::TabAfterComma, + Rule::UnexpectedSpacesAroundKeywordParameterEquals, + Rule::MissingWhitespaceAroundParameterEquals, + Rule::TooFewSpacesBeforeInlineComment, + Rule::NoSpaceAfterInlineComment, + Rule::NoSpaceAfterBlockComment, + Rule::MultipleLeadingHashesForBlockComment, + Rule::MultipleSpacesAfterKeyword, + Rule::MultipleSpacesBeforeKeyword, + Rule::TabAfterKeyword, + Rule::TabBeforeKeyword, + Rule::MissingWhitespaceAfterKeyword, + Rule::CompareToEmptyString, + Rule::NoSelfUse, + Rule::EqWithoutHash, + Rule::BadDunderMethodName, + Rule::RepeatedAppend, + Rule::DeleteFullSlice, + Rule::CheckAndRemoveFromSet, + Rule::QuadraticListSummation, + ]; + + const PREVIEW_RULES: &[Rule] = &[Rule::SliceCopy]; #[allow(clippy::needless_pass_by_value)] - fn resolve_rules(selections: impl IntoIterator) -> RuleSet { + fn resolve_rules( + selections: impl IntoIterator, + preview: Option, + ) -> RuleSet { Configuration { rule_selections: selections.into_iter().collect(), + preview, ..Configuration::default() } .as_rule_table() .iter_enabled() + // Filter out rule gated behind `#[cfg(feature = "unreachable-code")]`, which is off-by-default + .filter(|rule| rule.noqa_code() != "RUF014") .collect() } #[test] - fn rule_codes() { - let actual = resolve_rules([RuleSelection { - select: Some(vec![Pycodestyle::W.into()]), - ..RuleSelection::default() - }]); + fn select_linter() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Linter::Pycodestyle.into()]), + ..RuleSelection::default() + }], + None, + ); + + let expected = RuleSet::from_rules(&[ + Rule::MixedSpacesAndTabs, + Rule::MultipleImportsOnOneLine, + Rule::ModuleImportNotAtTopOfFile, + Rule::LineTooLong, + Rule::MultipleStatementsOnOneLineColon, + Rule::MultipleStatementsOnOneLineSemicolon, + Rule::UselessSemicolon, + Rule::NoneComparison, + Rule::TrueFalseComparison, + Rule::NotInTest, + Rule::NotIsTest, + Rule::TypeComparison, + Rule::BareExcept, + Rule::LambdaAssignment, + Rule::AmbiguousVariableName, + Rule::AmbiguousClassName, + Rule::AmbiguousFunctionName, + Rule::IOError, + Rule::SyntaxError, + Rule::TabIndentation, + Rule::TrailingWhitespace, + Rule::MissingNewlineAtEndOfFile, + Rule::BlankLineWithWhitespace, + Rule::DocLineTooLong, + Rule::InvalidEscapeSequence, + ]); + assert_eq!(actual, expected); + } + + #[test] + fn select_one_char_prefix() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Pycodestyle::W.into()]), + ..RuleSelection::default() + }], + None, + ); let expected = RuleSet::from_rules(&[ Rule::TrailingWhitespace, @@ -786,19 +929,31 @@ mod tests { Rule::TabIndentation, ]); assert_eq!(actual, expected); + } - let actual = resolve_rules([RuleSelection { - select: Some(vec![Pycodestyle::W6.into()]), - ..RuleSelection::default() - }]); + #[test] + fn select_two_char_prefix() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Pycodestyle::W6.into()]), + ..RuleSelection::default() + }], + None, + ); let expected = RuleSet::from_rule(Rule::InvalidEscapeSequence); assert_eq!(actual, expected); + } - let actual = resolve_rules([RuleSelection { - select: Some(vec![Pycodestyle::W.into()]), - ignore: vec![Pycodestyle::W292.into()], - ..RuleSelection::default() - }]); + #[test] + fn select_prefix_ignore_code() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Pycodestyle::W.into()]), + ignore: vec![Pycodestyle::W292.into()], + ..RuleSelection::default() + }], + None, + ); let expected = RuleSet::from_rules(&[ Rule::TrailingWhitespace, Rule::BlankLineWithWhitespace, @@ -807,73 +962,100 @@ mod tests { Rule::TabIndentation, ]); assert_eq!(actual, expected); + } - let actual = resolve_rules([RuleSelection { - select: Some(vec![Pycodestyle::W292.into()]), - ignore: vec![Pycodestyle::W.into()], - ..RuleSelection::default() - }]); - let expected = RuleSet::from_rule(Rule::MissingNewlineAtEndOfFile); - assert_eq!(actual, expected); - - let actual = resolve_rules([RuleSelection { - select: Some(vec![Pycodestyle::W605.into()]), - ignore: vec![Pycodestyle::W605.into()], - ..RuleSelection::default() - }]); - let expected = RuleSet::empty(); - assert_eq!(actual, expected); - - let actual = resolve_rules([ - RuleSelection { - select: Some(vec![Pycodestyle::W.into()]), - ignore: vec![Pycodestyle::W292.into()], - ..RuleSelection::default() - }, - RuleSelection { - extend_select: vec![Pycodestyle::W292.into()], - ..RuleSelection::default() - }, - ]); - let expected = RuleSet::from_rules(&[ - Rule::TrailingWhitespace, - Rule::MissingNewlineAtEndOfFile, - Rule::BlankLineWithWhitespace, - Rule::DocLineTooLong, - Rule::InvalidEscapeSequence, - Rule::TabIndentation, - ]); - assert_eq!(actual, expected); - - let actual = resolve_rules([ - RuleSelection { - select: Some(vec![Pycodestyle::W.into()]), - ignore: vec![Pycodestyle::W292.into()], - ..RuleSelection::default() - }, - RuleSelection { - extend_select: vec![Pycodestyle::W292.into()], + #[test] + fn select_code_ignore_prefix() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Pycodestyle::W292.into()]), ignore: vec![Pycodestyle::W.into()], ..RuleSelection::default() - }, - ]); + }], + None, + ); let expected = RuleSet::from_rule(Rule::MissingNewlineAtEndOfFile); assert_eq!(actual, expected); } #[test] - fn carry_over_ignore() { - let actual = resolve_rules([ - RuleSelection { - select: Some(vec![]), - ignore: vec![Pycodestyle::W292.into()], + fn select_code_ignore_code() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Pycodestyle::W605.into()]), + ignore: vec![Pycodestyle::W605.into()], ..RuleSelection::default() - }, - RuleSelection { - select: Some(vec![Pycodestyle::W.into()]), - ..RuleSelection::default() - }, + }], + None, + ); + let expected = RuleSet::empty(); + assert_eq!(actual, expected); + } + + #[test] + fn select_prefix_ignore_code_then_extend_select_code() { + let actual = resolve_rules( + [ + RuleSelection { + select: Some(vec![Pycodestyle::W.into()]), + ignore: vec![Pycodestyle::W292.into()], + ..RuleSelection::default() + }, + RuleSelection { + extend_select: vec![Pycodestyle::W292.into()], + ..RuleSelection::default() + }, + ], + None, + ); + let expected = RuleSet::from_rules(&[ + Rule::TrailingWhitespace, + Rule::MissingNewlineAtEndOfFile, + Rule::BlankLineWithWhitespace, + Rule::DocLineTooLong, + Rule::InvalidEscapeSequence, + Rule::TabIndentation, ]); + assert_eq!(actual, expected); + } + + #[test] + fn select_prefix_ignore_code_then_extend_select_code_ignore_prefix() { + let actual = resolve_rules( + [ + RuleSelection { + select: Some(vec![Pycodestyle::W.into()]), + ignore: vec![Pycodestyle::W292.into()], + ..RuleSelection::default() + }, + RuleSelection { + extend_select: vec![Pycodestyle::W292.into()], + ignore: vec![Pycodestyle::W.into()], + ..RuleSelection::default() + }, + ], + None, + ); + let expected = RuleSet::from_rule(Rule::MissingNewlineAtEndOfFile); + assert_eq!(actual, expected); + } + + #[test] + fn ignore_code_then_select_prefix() { + let actual = resolve_rules( + [ + RuleSelection { + select: Some(vec![]), + ignore: vec![Pycodestyle::W292.into()], + ..RuleSelection::default() + }, + RuleSelection { + select: Some(vec![Pycodestyle::W.into()]), + ..RuleSelection::default() + }, + ], + None, + ); let expected = RuleSet::from_rules(&[ Rule::TrailingWhitespace, Rule::BlankLineWithWhitespace, @@ -882,19 +1064,25 @@ mod tests { Rule::TabIndentation, ]); assert_eq!(actual, expected); + } - let actual = resolve_rules([ - RuleSelection { - select: Some(vec![]), - ignore: vec![Pycodestyle::W292.into()], - ..RuleSelection::default() - }, - RuleSelection { - select: Some(vec![Pycodestyle::W.into()]), - ignore: vec![Pycodestyle::W505.into()], - ..RuleSelection::default() - }, - ]); + #[test] + fn ignore_code_then_select_prefix_ignore_code() { + let actual = resolve_rules( + [ + RuleSelection { + select: Some(vec![]), + ignore: vec![Pycodestyle::W292.into()], + ..RuleSelection::default() + }, + RuleSelection { + select: Some(vec![Pycodestyle::W.into()]), + ignore: vec![Pycodestyle::W505.into()], + ..RuleSelection::default() + }, + ], + None, + ); let expected = RuleSet::from_rules(&[ Rule::TrailingWhitespace, Rule::BlankLineWithWhitespace, @@ -903,4 +1091,149 @@ mod tests { ]); assert_eq!(actual, expected); } + + #[test] + fn select_linter_preview() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Linter::Flake8Copyright.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Disabled), + ); + let expected = RuleSet::empty(); + assert_eq!(actual, expected); + + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Linter::Flake8Copyright.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Enabled), + ); + let expected = RuleSet::from_rule(Rule::MissingCopyrightNotice); + assert_eq!(actual, expected); + } + + #[test] + fn select_prefix_preview() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Flake8Copyright::_0.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Disabled), + ); + let expected = RuleSet::empty(); + assert_eq!(actual, expected); + + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Flake8Copyright::_0.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Enabled), + ); + let expected = RuleSet::from_rule(Rule::MissingCopyrightNotice); + assert_eq!(actual, expected); + } + + #[test] + fn select_rule_preview() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Refurb::_145.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Disabled), + ); + let expected = RuleSet::empty(); + assert_eq!(actual, expected); + + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Refurb::_145.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Enabled), + ); + let expected = RuleSet::from_rule(Rule::SliceCopy); + assert_eq!(actual, expected); + } + + #[test] + fn select_preview() { + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![RuleSelector::Preview]), + ..RuleSelection::default() + }], + Some(PreviewMode::Disabled), + ); + let expected = RuleSet::empty(); + assert_eq!(actual, expected); + + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![RuleSelector::Preview]), + ..RuleSelection::default() + }], + Some(PreviewMode::Enabled), + ); + + let expected = + RuleSet::from_rules(NURSERY_RULES).union(&RuleSet::from_rules(PREVIEW_RULES)); + assert_eq!(actual, expected); + } + + #[test] + fn nursery_select_code() { + // Backwards compatible behavior allows selection of nursery rules with their exact code + // when preview is disabled + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Flake8Copyright::_001.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Disabled), + ); + let expected = RuleSet::from_rule(Rule::MissingCopyrightNotice); + assert_eq!(actual, expected); + + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![Flake8Copyright::_001.into()]), + ..RuleSelection::default() + }], + Some(PreviewMode::Enabled), + ); + let expected = RuleSet::from_rule(Rule::MissingCopyrightNotice); + assert_eq!(actual, expected); + } + + #[test] + #[allow(deprecated)] + fn select_nursery() { + // Backwards compatible behavior allows selection of nursery rules with the nursery selector + // when preview is disabled + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![RuleSelector::Nursery]), + ..RuleSelection::default() + }], + Some(PreviewMode::Disabled), + ); + let expected = RuleSet::from_rules(NURSERY_RULES); + assert_eq!(actual, expected); + + let actual = resolve_rules( + [RuleSelection { + select: Some(vec![RuleSelector::Nursery]), + ..RuleSelection::default() + }], + Some(PreviewMode::Enabled), + ); + let expected = RuleSet::from_rules(NURSERY_RULES); + assert_eq!(actual, expected); + } } diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index d318c2d2e6..3c8cc9e227 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -482,6 +482,17 @@ pub struct Options { /// field (e.g., `requires-python = ">=3.8"`). If Ruff is configured via /// `ruff.toml` or `.ruff.toml`, no such inference will be performed. pub target_version: Option, + #[option( + default = "false", + value_type = "bool", + example = r#" + # Enable preview features + preview = true + "# + )] + /// Whether to enable preview mode. When preview mode is enabled, Ruff will + /// use unstable rules and fixes. + pub preview: Option, #[option( default = r#"["TODO", "FIXME", "XXX"]"#, value_type = "list[str]", @@ -1229,16 +1240,26 @@ pub struct Flake8SelfOptions { )] /// A list of names to ignore when considering `flake8-self` violations. pub ignore_names: Option>, + #[option( + default = r#"[]"#, + value_type = "list[str]", + example = r#"extend-ignore-names = ["_base_manager", "_default_manager", "_meta"]"# + )] + /// Additional names to ignore when considering `flake8-self` violations, + /// in addition to those included in `ignore-names`. + pub extend_ignore_names: Option>, } impl Flake8SelfOptions { pub fn into_settings(self) -> flake8_self::settings::Settings { + let defaults = flake8_self::settings::Settings::default(); flake8_self::settings::Settings { - ignore_names: self.ignore_names.unwrap_or_else(|| { - flake8_self::settings::IGNORE_NAMES - .map(String::from) - .to_vec() - }), + ignore_names: self + .ignore_names + .unwrap_or(defaults.ignore_names) + .into_iter() + .chain(self.extend_ignore_names.unwrap_or_default()) + .collect(), } } } @@ -2215,3 +2236,56 @@ impl PyUpgradeOptions { } } } + +#[cfg(test)] +mod tests { + use crate::options::Flake8SelfOptions; + use ruff::rules::flake8_self; + + #[test] + fn flake8_self_options() { + let default_settings = flake8_self::settings::Settings::default(); + + // Uses defaults if no options are specified. + let options = Flake8SelfOptions { + ignore_names: None, + extend_ignore_names: None, + }; + let settings = options.into_settings(); + assert_eq!(settings.ignore_names, default_settings.ignore_names); + + // Uses ignore_names if specified. + let options = Flake8SelfOptions { + ignore_names: Some(vec!["_foo".to_string()]), + extend_ignore_names: None, + }; + let settings = options.into_settings(); + assert_eq!(settings.ignore_names, vec!["_foo".to_string()]); + + // Appends extend_ignore_names to defaults if only extend_ignore_names is specified. + let options = Flake8SelfOptions { + ignore_names: None, + extend_ignore_names: Some(vec!["_bar".to_string()]), + }; + let settings = options.into_settings(); + assert_eq!( + settings.ignore_names, + default_settings + .ignore_names + .into_iter() + .chain(["_bar".to_string()]) + .collect::>() + ); + + // Appends extend_ignore_names to ignore_names if both are specified. + let options = Flake8SelfOptions { + ignore_names: Some(vec!["_foo".to_string()]), + extend_ignore_names: Some(vec!["_bar".to_string()]), + }; + let settings = options.into_settings(); + assert_eq!( + settings.ignore_names, + vec!["_foo".to_string(), "_bar".to_string()] + ); + } +} diff --git a/crates/ruff_workspace/src/pyproject.rs b/crates/ruff_workspace/src/pyproject.rs index ed6609b5ee..8fbeda1d93 100644 --- a/crates/ruff_workspace/src/pyproject.rs +++ b/crates/ruff_workspace/src/pyproject.rs @@ -157,7 +157,6 @@ mod tests { use crate::tests::test_resource_path; use anyhow::Result; use ruff::codes; - use ruff::codes::RuleCodePrefix; use ruff::line_width::LineLength; use ruff::settings::types::PatternPrefixPair; use rustc_hash::FxHashMap; @@ -307,7 +306,7 @@ other-attribute = 1 ]), per_file_ignores: Some(FxHashMap::from_iter([( "__init__.py".to_string(), - vec![RuleCodePrefix::Pyflakes(codes::Pyflakes::_401).into()] + vec![codes::Pyflakes::_401.into()] )])), ..Options::default() } diff --git a/docs/configuration.md b/docs/configuration.md index ee70281241..b41204254f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -57,23 +57,20 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" target-version = "py38" ``` -As an example, the following would configure Ruff to: (1) enforce flake8-bugbear rules, in addition -to the defaults; (2) avoid enforcing line-length violations (`E501`); (3) avoid attempting to fix -flake8-bugbear (`B`) violations; and (3) ignore import-at-top-of-file violations (`E402`) in -`__init__.py` files: +As an example, the following would configure Ruff to: ```toml [tool.ruff] -# Enable flake8-bugbear (`B`) rules. +# 1. Enable flake8-bugbear (`B`) rules, in addition to the defaults. select = ["E", "F", "B"] -# Never enforce `E501` (line length violations). +# 2. Avoid enforcing line-length violations (`E501`) ignore = ["E501"] -# Avoid trying to fix flake8-bugbear (`B`) violations. +# 3. Avoid trying to fix flake8-bugbear (`B`) violations. unfixable = ["B"] -# Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`. +# 4. Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`. [tool.ruff.per-file-ignores] "__init__.py" = ["E402"] "path/to/file.py" = ["E402"] @@ -174,8 +171,8 @@ Options: Log levels: -v, --verbose Enable verbose logging - -q, --quiet Print lint violations, but nothing else - -s, --silent Disable all logging (but still exit with status code "1" upon detecting lint violations) + -q, --quiet Print diagnostics, but nothing else + -s, --silent Disable all logging (but still exit with status code "1" upon detecting diagnostics) For help with a specific command, see: `ruff help `. ``` @@ -215,6 +212,8 @@ Options: Specify file to write the linter output to (default: stdout) --target-version The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312] + --preview + Enable preview mode; checks will include unstable rules and fixes --config Path to the `pyproject.toml` or `ruff.toml` file to use for configuration --statistics @@ -268,8 +267,8 @@ Miscellaneous: Log levels: -v, --verbose Enable verbose logging - -q, --quiet Print lint violations, but nothing else - -s, --silent Disable all logging (but still exit with status code "1" upon detecting lint violations) + -q, --quiet Print diagnostics, but nothing else + -s, --silent Disable all logging (but still exit with status code "1" upon detecting diagnostics) ``` diff --git a/docs/faq.md b/docs/faq.md index 5394e6e184..6002a2fc45 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -145,7 +145,7 @@ Today, Ruff can be used to replace Flake8 when used with any of the following pl - [flake8-builtins](https://pypi.org/project/flake8-builtins/) - [flake8-commas](https://pypi.org/project/flake8-commas/) - [flake8-comprehensions](https://pypi.org/project/flake8-comprehensions/) -- [flake8-copyright](https://pypi.org/project/flake8-comprehensions/) +- [flake8-copyright](https://pypi.org/project/flake8-copyright/) - [flake8-datetimez](https://pypi.org/project/flake8-datetimez/) - [flake8-debugger](https://pypi.org/project/flake8-debugger/) - [flake8-django](https://pypi.org/project/flake8-django/) @@ -382,37 +382,9 @@ matter how they're provided, which avoids accidental incompatibilities and simpl By default, no `convention` is set, and so the enabled rules are determined by the `select` setting alone. -## What is the "nursery"? +## What is preview? -The "nursery" is a collection of newer rules that are considered experimental or unstable. - -If a rule is marked as part of the "nursery", it can only be enabled via direct selection. For -example, consider a hypothetical rule, `HYP001`. If `HYP001` were included in the "nursery", it -could be enabled by adding the following to your `pyproject.toml`: - -```toml -[tool.ruff] -extend-select = ["HYP001"] -``` - -However, it would _not_ be enabled by selecting the `HYP` category, like so: - -```toml -[tool.ruff] -extend-select = ["HYP"] -``` - -Similarly, it would _not_ be enabled via the `ALL` selector: - -```toml -[tool.ruff] -select = ["ALL"] -``` - -(The "nursery" terminology comes from [Clippy](https://doc.rust-lang.org/nightly/clippy/), a similar -tool for linting Rust code.) - -To see which rules are currently in the "nursery", visit the [rules reference](https://beta.ruff.rs/docs/rules/). +Preview enables a collection of newer rules and fixes that are considered experimental or unstable. See the [preview documentation](https://beta.ruff.rs/docs/preview/) for more details; or, to see which rules are currently in preview, visit the [rules reference](https://beta.ruff.rs/docs/rules/). ## How can I tell what settings Ruff is using to check my code? diff --git a/docs/preview.md b/docs/preview.md new file mode 100644 index 0000000000..0d672950e3 --- /dev/null +++ b/docs/preview.md @@ -0,0 +1,48 @@ +# Preview + +Ruff includes an opt-in preview mode to provide an opportunity for community feedback and increase confidence that +changes are a net-benefit before enabling them for everyone. + +Preview mode enables a collection of newer rules and fixes that are considered experimental or unstable. + +## Enabling preview mode + +Preview mode can be enabled with the `--preview` flag on the CLI or by setting `preview = true` in your Ruff +configuration file (e.g. `pyproject.toml`). + +## Using rules that are in preview + +If a rule is marked as preview, it can only be selected if preview mode is enabled. For example, consider a +hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding following to your +`pyproject.toml`: + +```toml +[tool.ruff] +extend-select = ["HYP001"] +``` + +It also would _not_ be enabled by selecting the `HYP` category, like so: + +```toml +[tool.ruff] +extend-select = ["HYP"] +``` + +Similarly, it would _not_ be enabled via the `ALL` selector: + +```toml +[tool.ruff] +select = ["ALL"] +``` + +However, it would be enabled in any of the above cases if you you enabled preview in your configuration file: + +```toml +[tool.ruff] +extend-select = ["HYP"] +preview = true +``` + +Or, if you provided the `--preview` CLI flag. + +To see which rules are currently in preview, visit the [rules reference](https://beta.ruff.rs/docs/rules/). diff --git a/docs/tutorial.md b/docs/tutorial.md index f23a167e9e..145a90c1ea 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -242,7 +242,7 @@ This tutorial has focused on Ruff's command-line interface, but Ruff can also be ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.286 + rev: v0.0.289 hooks: - id: ruff ``` diff --git a/docs/usage.md b/docs/usage.md index 17c2e99db7..94741516b9 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -7,6 +7,7 @@ ruff check . # Lint all files in the current directory (a ruff check path/to/code/ # Lint all files in `/path/to/code` (and any subdirectories) ruff check path/to/code/*.py # Lint all `.py` files in `/path/to/code` ruff check path/to/code/to/file.py # Lint `file.py` +ruff check @file_paths.txt # Lint using an input file and treat its contents as command-line arguments (newline delimiter) ``` You can run Ruff in `--watch` mode to automatically re-run on-change: @@ -22,7 +23,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com) hook: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.286 + rev: v0.0.289 hooks: - id: ruff ``` @@ -32,7 +33,7 @@ Or, to enable autofix: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.286 + rev: v0.0.289 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] @@ -43,7 +44,7 @@ Or, to run the hook on Jupyter Notebooks too: ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.286 + rev: v0.0.289 hooks: - id: ruff types_or: [python, pyi, jupyter] diff --git a/pyproject.toml b/pyproject.toml index f2d8851443..93ecc17a17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "maturin" [project] name = "ruff" -version = "0.0.286" +version = "0.0.289" description = "An extremely fast Python linter, written in Rust." authors = [{ name = "Charlie Marsh", email = "charlie.r.marsh@gmail.com" }] maintainers = [{ name = "Charlie Marsh", email = "charlie.r.marsh@gmail.com" }] diff --git a/ruff.schema.json b/ruff.schema.json index df5dff0e40..4402f3c797 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -441,6 +441,13 @@ } } }, + "preview": { + "description": "Whether to enable preview mode. When preview mode is enabled, Ruff will use unstable rules and fixes.", + "type": [ + "boolean", + "null" + ] + }, "pycodestyle": { "description": "Options for the `pycodestyle` plugin.", "anyOf": [ @@ -1026,6 +1033,16 @@ "Flake8SelfOptions": { "type": "object", "properties": { + "extend-ignore-names": { + "description": "Additional names to ignore when considering `flake8-self` violations, in addition to those included in `ignore-names`.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "ignore-names": { "description": "A list of names to ignore when considering `flake8-self` violations.", "type": [ @@ -1799,6 +1816,8 @@ "COM818", "COM819", "CPY", + "CPY0", + "CPY00", "CPY001", "D", "D1", @@ -1885,6 +1904,7 @@ "E1", "E10", "E101", + "E11", "E111", "E112", "E113", @@ -1892,10 +1912,14 @@ "E115", "E116", "E117", + "E2", + "E20", "E201", "E202", "E203", + "E21", "E211", + "E22", "E221", "E222", "E223", @@ -1904,15 +1928,20 @@ "E226", "E227", "E228", + "E23", "E231", + "E24", "E241", "E242", + "E25", "E251", "E252", + "E26", "E261", "E262", "E265", "E266", + "E27", "E271", "E272", "E273", @@ -2053,9 +2082,14 @@ "FLY00", "FLY002", "FURB", + "FURB1", + "FURB11", "FURB113", + "FURB13", "FURB131", "FURB132", + "FURB14", + "FURB145", "G", "G0", "G00", @@ -2198,6 +2232,9 @@ "PLC04", "PLC041", "PLC0414", + "PLC1", + "PLC19", + "PLC190", "PLC1901", "PLC3", "PLC30", @@ -2292,6 +2329,9 @@ "PLR55", "PLR550", "PLR5501", + "PLR6", + "PLR63", + "PLR630", "PLR6301", "PLW", "PLW0", @@ -2319,12 +2359,16 @@ "PLW1509", "PLW151", "PLW1510", + "PLW16", + "PLW164", "PLW1641", "PLW2", "PLW29", "PLW290", "PLW2901", "PLW3", + "PLW32", + "PLW320", "PLW3201", "PLW33", "PLW330", diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index cc31fcd4f5..0000000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.72 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..7e8f0a9aab --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.72" diff --git a/scripts/benchmarks/poetry.lock b/scripts/benchmarks/poetry.lock index ad8599f8a3..bfa48b564e 100644 --- a/scripts/benchmarks/poetry.lock +++ b/scripts/benchmarks/poetry.lock @@ -1,66 +1,35 @@ # This file is automatically @generated by Poetry and should not be changed by hand. -[[package]] -name = "astor" -version = "0.8.1" -description = "Read/rewrite/write Python ASTs" -category = "main" -optional = true -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" -files = [ - {file = "astor-0.8.1-py2.py3-none-any.whl", hash = "sha256:070a54e890cefb5b3739d19f30f5a5ec840ffc9c50ffa7d23cc9fc1a38ebbfc5"}, - {file = "astor-0.8.1.tar.gz", hash = "sha256:6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e"}, -] - [[package]] name = "astroid" -version = "2.13.2" +version = "2.15.6" description = "An abstract syntax tree for Python with inference support." category = "main" optional = false python-versions = ">=3.7.2" files = [ - {file = "astroid-2.13.2-py3-none-any.whl", hash = "sha256:8f6a8d40c4ad161d6fc419545ae4b2f275ed86d1c989c97825772120842ee0d2"}, - {file = "astroid-2.13.2.tar.gz", hash = "sha256:3bc7834720e1a24ca797fd785d77efb14f7a28ee8e635ef040b6e2d80ccb3303"}, + {file = "astroid-2.15.6-py3-none-any.whl", hash = "sha256:389656ca57b6108f939cf5d2f9a2a825a3be50ba9d589670f393236e0a03b91c"}, + {file = "astroid-2.15.6.tar.gz", hash = "sha256:903f024859b7c7687d7a7f3a3f73b17301f8e42dfd9cc9df9d4418172d3e2dbd"}, ] [package.dependencies] lazy-object-proxy = ">=1.4.0" -typing-extensions = ">=4.0.0" +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""} wrapt = [ {version = ">=1.11,<2", markers = "python_version < \"3.11\""}, {version = ">=1.14,<2", markers = "python_version >= \"3.11\""}, ] -[[package]] -name = "attrs" -version = "22.2.0" -description = "Classes Without Boilerplate" -category = "main" -optional = true -python-versions = ">=3.6" -files = [ - {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, - {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, -] - -[package.extras] -cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] -dev = ["attrs[docs,tests]"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] -tests = ["attrs[tests-no-zope]", "zope.interface"] -tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"] - [[package]] name = "autoflake" -version = "2.0.0" +version = "2.2.1" description = "Removes unused imports and unused variables" category = "main" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "autoflake-2.0.0-py3-none-any.whl", hash = "sha256:d58ed4187c6b4f623a942b9a90c43ff84bf6a266f3682f407b42ca52073c9678"}, - {file = "autoflake-2.0.0.tar.gz", hash = "sha256:7185b596e70d8970c6d4106c112ef41921e472bd26abf3613db99eca88cc8c2a"}, + {file = "autoflake-2.2.1-py3-none-any.whl", hash = "sha256:265cde0a43c1f44ecfb4f30d95b0437796759d07be7706a2f70e4719234c0f79"}, + {file = "autoflake-2.2.1.tar.gz", hash = "sha256:62b7b6449a692c3c9b0c916919bbc21648da7281e8506bcf8d3f8280e431ebc1"}, ] [package.dependencies] @@ -68,56 +37,61 @@ pyflakes = ">=3.0.0" tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} [[package]] -name = "bandit" -version = "1.7.4" -description = "Security oriented static analyser for python code." +name = "autopep8" +version = "2.0.4" +description = "A tool that automatically formats Python code to conform to the PEP 8 style guide" category = "main" -optional = true -python-versions = ">=3.7" +optional = false +python-versions = ">=3.6" files = [ - {file = "bandit-1.7.4-py3-none-any.whl", hash = "sha256:412d3f259dab4077d0e7f0c11f50f650cc7d10db905d98f6520a95a18049658a"}, - {file = "bandit-1.7.4.tar.gz", hash = "sha256:2d63a8c573417bae338962d4b9b06fbc6080f74ecd955a092849e1e65c717bd2"}, + {file = "autopep8-2.0.4-py2.py3-none-any.whl", hash = "sha256:067959ca4a07b24dbd5345efa8325f5f58da4298dab0dde0443d5ed765de80cb"}, + {file = "autopep8-2.0.4.tar.gz", hash = "sha256:2913064abd97b3419d1cc83ea71f042cb821f87e45b9c88cad5ad3c4ea87fe0c"}, ] [package.dependencies] -colorama = {version = ">=0.3.9", markers = "platform_system == \"Windows\""} -GitPython = ">=1.0.1" -PyYAML = ">=5.3.1" -stevedore = ">=1.20.0" - -[package.extras] -test = ["beautifulsoup4 (>=4.8.0)", "coverage (>=4.5.4)", "fixtures (>=3.0.0)", "flake8 (>=4.0.0)", "pylint (==1.9.4)", "stestr (>=2.5.0)", "testscenarios (>=0.5.0)", "testtools (>=2.3.0)", "toml"] -toml = ["toml"] -yaml = ["PyYAML"] +pycodestyle = ">=2.10.0" +tomli = {version = "*", markers = "python_version < \"3.11\""} [[package]] name = "black" -version = "22.12.0" +version = "23.9.1" description = "The uncompromising code formatter." category = "main" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, - {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, - {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, - {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, - {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, - {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, - {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, - {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, - {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, - {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, - {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, - {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, + {file = "black-23.9.1-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:d6bc09188020c9ac2555a498949401ab35bb6bf76d4e0f8ee251694664df6301"}, + {file = "black-23.9.1-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:13ef033794029b85dfea8032c9d3b92b42b526f1ff4bf13b2182ce4e917f5100"}, + {file = "black-23.9.1-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:75a2dc41b183d4872d3a500d2b9c9016e67ed95738a3624f4751a0cb4818fe71"}, + {file = "black-23.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13a2e4a93bb8ca74a749b6974925c27219bb3df4d42fc45e948a5d9feb5122b7"}, + {file = "black-23.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:adc3e4442eef57f99b5590b245a328aad19c99552e0bdc7f0b04db6656debd80"}, + {file = "black-23.9.1-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:8431445bf62d2a914b541da7ab3e2b4f3bc052d2ccbf157ebad18ea126efb91f"}, + {file = "black-23.9.1-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:8fc1ddcf83f996247505db6b715294eba56ea9372e107fd54963c7553f2b6dfe"}, + {file = "black-23.9.1-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:7d30ec46de88091e4316b17ae58bbbfc12b2de05e069030f6b747dfc649ad186"}, + {file = "black-23.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:031e8c69f3d3b09e1aa471a926a1eeb0b9071f80b17689a655f7885ac9325a6f"}, + {file = "black-23.9.1-cp311-cp311-win_amd64.whl", hash = "sha256:538efb451cd50f43aba394e9ec7ad55a37598faae3348d723b59ea8e91616300"}, + {file = "black-23.9.1-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:638619a559280de0c2aa4d76f504891c9860bb8fa214267358f0a20f27c12948"}, + {file = "black-23.9.1-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:a732b82747235e0542c03bf352c126052c0fbc458d8a239a94701175b17d4855"}, + {file = "black-23.9.1-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:cf3a4d00e4cdb6734b64bf23cd4341421e8953615cba6b3670453737a72ec204"}, + {file = "black-23.9.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cf99f3de8b3273a8317681d8194ea222f10e0133a24a7548c73ce44ea1679377"}, + {file = "black-23.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:14f04c990259576acd093871e7e9b14918eb28f1866f91968ff5524293f9c573"}, + {file = "black-23.9.1-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:c619f063c2d68f19b2d7270f4cf3192cb81c9ec5bc5ba02df91471d0b88c4c5c"}, + {file = "black-23.9.1-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:6a3b50e4b93f43b34a9d3ef00d9b6728b4a722c997c99ab09102fd5efdb88325"}, + {file = "black-23.9.1-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:c46767e8df1b7beefb0899c4a95fb43058fa8500b6db144f4ff3ca38eb2f6393"}, + {file = "black-23.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50254ebfa56aa46a9fdd5d651f9637485068a1adf42270148cd101cdf56e0ad9"}, + {file = "black-23.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:403397c033adbc45c2bd41747da1f7fc7eaa44efbee256b53842470d4ac5a70f"}, + {file = "black-23.9.1-py3-none-any.whl", hash = "sha256:6ccd59584cc834b6d127628713e4b6b968e5f79572da66284532525a042549f9"}, + {file = "black-23.9.1.tar.gz", hash = "sha256:24b6b3ff5c6d9ea08a8888f6977eae858e1f340d7260cf56d70a49823236b62d"}, ] [package.dependencies] click = ">=8.0.0" mypy-extensions = ">=0.4.3" +packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] @@ -127,14 +101,14 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "click" -version = "8.1.3" +version = "8.1.7" description = "Composable command line interface toolkit" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, - {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, ] [package.dependencies] @@ -154,14 +128,14 @@ files = [ [[package]] name = "dill" -version = "0.3.6" -description = "serialize all of python" +version = "0.3.7" +description = "serialize all of Python" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "dill-0.3.6-py3-none-any.whl", hash = "sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0"}, - {file = "dill-0.3.6.tar.gz", hash = "sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373"}, + {file = "dill-0.3.7-py3-none-any.whl", hash = "sha256:76b122c08ef4ce2eedcd4d1abd8e641114bfc6c2867f49f3c41facf65bf19f5e"}, + {file = "dill-0.3.7.tar.gz", hash = "sha256:cc1c8b182eb3013e24bd475ff2e9295af86c1a38eb1aff128dac8962a9ce3c03"}, ] [package.extras] @@ -169,407 +143,56 @@ graph = ["objgraph (>=1.7.2)"] [[package]] name = "flake8" -version = "6.0.0" +version = "6.1.0" description = "the modular source code checker: pep8 pyflakes and co" category = "main" optional = false python-versions = ">=3.8.1" files = [ - {file = "flake8-6.0.0-py2.py3-none-any.whl", hash = "sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7"}, - {file = "flake8-6.0.0.tar.gz", hash = "sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181"}, + {file = "flake8-6.1.0-py2.py3-none-any.whl", hash = "sha256:ffdfce58ea94c6580c77888a86506937f9a1a227dfcd15f245d694ae20a6b6e5"}, + {file = "flake8-6.1.0.tar.gz", hash = "sha256:d5b3857f07c030bdb5bf41c7f53799571d75c4491748a3adcd47de929e34cd23"}, ] [package.dependencies] mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.10.0,<2.11.0" -pyflakes = ">=3.0.0,<3.1.0" +pycodestyle = ">=2.11.0,<2.12.0" +pyflakes = ">=3.1.0,<3.2.0" [[package]] -name = "flake8-2020" -version = "1.7.0" -description = "flake8 plugin which checks for misuse of `sys.version` or `sys.version_info`" +name = "importlib-metadata" +version = "6.8.0" +description = "Read metadata from Python packages" category = "main" -optional = true -python-versions = ">=3.7" +optional = false +python-versions = ">=3.8" files = [ - {file = "flake8_2020-1.7.0-py2.py3-none-any.whl", hash = "sha256:e3e89e2fd4077c66ac8b8739e2af7c791258ba4023037e401f825284435c7dbb"}, - {file = "flake8_2020-1.7.0.tar.gz", hash = "sha256:9342902563a7d0b0233128c395be1372b8a3e8072805931639760bfe8a3935f9"}, + {file = "importlib_metadata-6.8.0-py3-none-any.whl", hash = "sha256:3ebb78df84a805d7698245025b975d9d67053cd94c79245ba4b3eb694abe68bb"}, + {file = "importlib_metadata-6.8.0.tar.gz", hash = "sha256:dbace7892d8c0c4ac1ad096662232f831d4e64f4c4545bd53016a3e9d4654743"}, ] [package.dependencies] -flake8 = ">=5" - -[[package]] -name = "flake8-annotations" -version = "2.9.1" -description = "Flake8 Type Annotation Checks" -category = "main" -optional = true -python-versions = ">=3.7,<4.0" -files = [ - {file = "flake8-annotations-2.9.1.tar.gz", hash = "sha256:11f09efb99ae63c8f9d6b492b75fe147fbc323179fddfe00b2e56eefeca42f57"}, - {file = "flake8_annotations-2.9.1-py3-none-any.whl", hash = "sha256:a4385158a7a9fc8af1d8820a2f4c8d03387997006a83f5f8bfe5bc6085bdf88a"}, -] - -[package.dependencies] -attrs = ">=21.4" -flake8 = ">=3.7" - -[[package]] -name = "flake8-bandit" -version = "4.1.1" -description = "Automated security testing with bandit and flake8." -category = "main" -optional = true -python-versions = ">=3.6" -files = [ - {file = "flake8_bandit-4.1.1-py3-none-any.whl", hash = "sha256:4c8a53eb48f23d4ef1e59293657181a3c989d0077c9952717e98a0eace43e06d"}, - {file = "flake8_bandit-4.1.1.tar.gz", hash = "sha256:068e09287189cbfd7f986e92605adea2067630b75380c6b5733dab7d87f9a84e"}, -] - -[package.dependencies] -bandit = ">=1.7.3" -flake8 = ">=5.0.0" - -[[package]] -name = "flake8-blind-except" -version = "0.2.1" -description = "A flake8 extension that checks for blind except: statements" -category = "main" -optional = true -python-versions = "*" -files = [ - {file = "flake8-blind-except-0.2.1.tar.gz", hash = "sha256:f25a575a9dcb3eeb3c760bf9c22db60b8b5a23120224ed1faa9a43f75dd7dd16"}, -] - -[[package]] -name = "flake8-bugbear" -version = "23.1.14" -description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle." -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-bugbear-23.1.14.tar.gz", hash = "sha256:ba31dd954ef9c2a8f523adee3fdd78d1f9dd1afcba59cc6ad4c116e2cc1563f3"}, - {file = "flake8_bugbear-23.1.14-py3-none-any.whl", hash = "sha256:ecaeb93acbd02f26f2246907b0e4c291cafdf65ef2ea24bbdbb596fd8d30605e"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -flake8 = ">=3.0.0" +zipp = ">=0.5" [package.extras] -dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit", "pytest", "tox"] - -[[package]] -name = "flake8-builtins" -version = "2.1.0" -description = "Check for python builtins being used as variables or parameters." -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-builtins-2.1.0.tar.gz", hash = "sha256:12ff1ee96dd4e1f3141141ee6c45a5c7d3b3c440d0949e9b8d345c42b39c51d4"}, - {file = "flake8_builtins-2.1.0-py3-none-any.whl", hash = "sha256:469e8f03d6d0edf4b1e62b6d5a97dce4598592c8a13ec8f0952e7a185eba50a1"}, -] - -[package.dependencies] -flake8 = "*" - -[package.extras] -test = ["pytest"] - -[[package]] -name = "flake8-commas" -version = "2.1.0" -description = "Flake8 lint for trailing commas." -category = "main" -optional = true -python-versions = "*" -files = [ - {file = "flake8-commas-2.1.0.tar.gz", hash = "sha256:940441ab8ee544df564ae3b3f49f20462d75d5c7cac2463e0b27436e2050f263"}, - {file = "flake8_commas-2.1.0-py2.py3-none-any.whl", hash = "sha256:ebb96c31e01d0ef1d0685a21f3f0e2f8153a0381430e748bf0bbbb5d5b453d54"}, -] - -[package.dependencies] -flake8 = ">=2" - -[[package]] -name = "flake8-comprehensions" -version = "3.10.1" -description = "A flake8 plugin to help you write better list/set/dict comprehensions." -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-comprehensions-3.10.1.tar.gz", hash = "sha256:412052ac4a947f36b891143430fef4859705af11b2572fbb689f90d372cf26ab"}, - {file = "flake8_comprehensions-3.10.1-py3-none-any.whl", hash = "sha256:d763de3c74bc18a79c039a7ec732e0a1985b0c79309ceb51e56401ad0a2cd44e"}, -] - -[package.dependencies] -flake8 = ">=3.0,<3.2.0 || >3.2.0" - -[[package]] -name = "flake8-datetimez" -version = "20.10.0" -description = "A plugin for flake8 to ban the usage of unsafe naive datetime class." -category = "main" -optional = true -python-versions = ">=3.6" -files = [ - {file = "flake8-datetimez-20.10.0.tar.gz", hash = "sha256:78939f3bcbe2b7fe48235998545c869c27cdfac3f45685099a3f7366c1ffebc6"}, - {file = "flake8_datetimez-20.10.0-py3-none-any.whl", hash = "sha256:57aa2f55eb88797e2d8c06bd536ff8049b9f1ba877d81dc06ff8d9bdc195c1fc"}, -] - -[package.dependencies] -flake8 = ">=3.0.0" - -[[package]] -name = "flake8-debugger" -version = "4.1.2" -description = "ipdb/pdb statement checker plugin for flake8" -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-debugger-4.1.2.tar.gz", hash = "sha256:52b002560941e36d9bf806fca2523dc7fb8560a295d5f1a6e15ac2ded7a73840"}, - {file = "flake8_debugger-4.1.2-py3-none-any.whl", hash = "sha256:0a5e55aeddcc81da631ad9c8c366e7318998f83ff00985a49e6b3ecf61e571bf"}, -] - -[package.dependencies] -flake8 = ">=3.0" -pycodestyle = "*" - -[[package]] -name = "flake8-docstrings" -version = "1.6.0" -description = "Extension for flake8 which uses pydocstyle to check docstrings" -category = "main" -optional = true -python-versions = "*" -files = [ - {file = "flake8-docstrings-1.6.0.tar.gz", hash = "sha256:9fe7c6a306064af8e62a055c2f61e9eb1da55f84bb39caef2b84ce53708ac34b"}, - {file = "flake8_docstrings-1.6.0-py2.py3-none-any.whl", hash = "sha256:99cac583d6c7e32dd28bbfbef120a7c0d1b6dde4adb5a9fd441c4227a6534bde"}, -] - -[package.dependencies] -flake8 = ">=3" -pydocstyle = ">=2.1" - -[[package]] -name = "flake8-errmsg" -version = "0.4.0" -description = "Flake8 checker for raw literals inside raises." -category = "main" -optional = true -python-versions = ">=3.10" -files = [ - {file = "flake8_errmsg-0.4.0-py3-none-any.whl", hash = "sha256:87b3ca16e3c12a694835bf755f107bf29eb6d9ed16064203cc499369d3325029"}, - {file = "flake8_errmsg-0.4.0.tar.gz", hash = "sha256:af4ccc699cb4004339d74338813fcb1a126afc78b1826ba4f5960d3bdf1c1b5f"}, -] - -[package.extras] -dev = ["flake8", "pytest (>=7)"] -test = ["pytest (>=7)"] - -[[package]] -name = "flake8-implicit-str-concat" -version = "0.3.0" -description = "Flake8 plugin to encourage correct string literal concatenation." -category = "main" -optional = true -python-versions = "~=3.7" -files = [ - {file = "flake8_implicit_str_concat-0.3.0-py2.py3-none-any.whl", hash = "sha256:a89ebc50567790fb7b83e032ed4014ae0db70e35d89e269c3323967135023600"}, - {file = "flake8_implicit_str_concat-0.3.0.tar.gz", hash = "sha256:c0e6ae227e46238e4c87844091f8072892caeccd3bb266576a7d449eadbf53a0"}, -] - -[package.dependencies] -attrs = ">=19.3" -more-itertools = ">=8.0.2,<9" - -[[package]] -name = "flake8-isort" -version = "6.0.0" -description = "flake8 plugin that integrates isort ." -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-isort-6.0.0.tar.gz", hash = "sha256:537f453a660d7e903f602ecfa36136b140de279df58d02eb1b6a0c84e83c528c"}, - {file = "flake8_isort-6.0.0-py3-none-any.whl", hash = "sha256:aa0cac02a62c7739e370ce6b9c31743edac904bae4b157274511fc8a19c75bbc"}, -] - -[package.dependencies] -flake8 = "*" -isort = ">=5.0.0,<6" - -[package.extras] -test = ["pytest"] - -[[package]] -name = "flake8-pie" -version = "0.16.0" -description = "A flake8 extension that implements misc. lints" -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-pie-0.16.0.tar.gz", hash = "sha256:b8dcb7b92706fa33d05d92a4b3e49b7a9fd3f0041849166275b646ba50e515ba"}, - {file = "flake8_pie-0.16.0-py3-none-any.whl", hash = "sha256:24cd7849b0eee22e2328b9e9d2a1dea40013b0a3106864bbadd06a4b05dbb71f"}, -] - -[package.dependencies] -typing_extensions = "*" - -[[package]] -name = "flake8-plugin-utils" -version = "1.3.2" -description = "The package provides base classes and utils for flake8 plugin writing" -category = "main" -optional = true -python-versions = ">=3.6,<4.0" -files = [ - {file = "flake8-plugin-utils-1.3.2.tar.gz", hash = "sha256:20fa2a8ca2decac50116edb42e6af0a1253ef639ad79941249b840531889c65a"}, - {file = "flake8_plugin_utils-1.3.2-py3-none-any.whl", hash = "sha256:1fe43e3e9acf3a7c0f6b88f5338cad37044d2f156c43cb6b080b5f9da8a76f06"}, -] - -[[package]] -name = "flake8-print" -version = "5.0.0" -description = "print statement checker plugin for flake8" -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-print-5.0.0.tar.gz", hash = "sha256:76915a2a389cc1c0879636c219eb909c38501d3a43cc8dae542081c9ba48bdf9"}, - {file = "flake8_print-5.0.0-py3-none-any.whl", hash = "sha256:84a1a6ea10d7056b804221ac5e62b1cee1aefc897ce16f2e5c42d3046068f5d8"}, -] - -[package.dependencies] -flake8 = ">=3.0" -pycodestyle = "*" - -[[package]] -name = "flake8-quotes" -version = "3.3.2" -description = "Flake8 lint for quotes." -category = "main" -optional = true -python-versions = "*" -files = [ - {file = "flake8-quotes-3.3.2.tar.gz", hash = "sha256:6e26892b632dacba517bf27219c459a8396dcfac0f5e8204904c5a4ba9b480e1"}, -] - -[package.dependencies] -flake8 = "*" - -[[package]] -name = "flake8-return" -version = "1.2.0" -description = "Flake8 plugin that checks return values" -category = "main" -optional = true -python-versions = ">=3.6,<4.0" -files = [ - {file = "flake8-return-1.2.0.tar.gz", hash = "sha256:68dfa56582cd704febd02ad86dcf5df67e38e0836d62f1ceae7930d76d3dd955"}, - {file = "flake8_return-1.2.0-py3-none-any.whl", hash = "sha256:1f07af12954ed03ebe2c2aac2418f78b55374e9929d4956109664588f31582a1"}, -] - -[package.dependencies] -flake8-plugin-utils = ">=1.0,<2.0" - -[[package]] -name = "flake8-simplify" -version = "0.19.3" -description = "flake8 plugin which checks for code that can be simplified" -category = "main" -optional = true -python-versions = ">=3.6.1" -files = [ - {file = "flake8_simplify-0.19.3-py3-none-any.whl", hash = "sha256:1057320e9312d75849541fee822900d27bcad05b2405edc84713affee635629e"}, - {file = "flake8_simplify-0.19.3.tar.gz", hash = "sha256:2fb083bf5142a98d9c9554755cf2f56f8926eb4a33eae30c0809041b1546879e"}, -] - -[package.dependencies] -astor = ">=0.1" -flake8 = ">=3.7" - -[[package]] -name = "flake8-super" -version = "0.1.3" -description = "Python 3 super() check for flake8" -category = "main" -optional = true -python-versions = "*" -files = [ - {file = "flake8_super-0.1.3-py3-none-any.whl", hash = "sha256:595cd65af908574867accfaa3ea2b3e4790637711859306550dc433d9105cbba"}, -] - -[package.dependencies] -flake8 = ">3.0.0" -flake8-plugin-utils = ">=1.3.2,<1.4.0" - -[[package]] -name = "flake8-tidy-imports" -version = "4.8.0" -description = "A flake8 plugin that helps you write tidier imports." -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "flake8-tidy-imports-4.8.0.tar.gz", hash = "sha256:df44f9c841b5dfb3a7a1f0da8546b319d772c2a816a1afefcce43e167a593d83"}, - {file = "flake8_tidy_imports-4.8.0-py3-none-any.whl", hash = "sha256:25bd9799358edefa0e010ce2c587b093c3aba942e96aeaa99b6d0500ae1bf09c"}, -] - -[package.dependencies] -flake8 = ">=3.8.0" - -[[package]] -name = "gitdb" -version = "4.0.10" -description = "Git Object Database" -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "gitdb-4.0.10-py3-none-any.whl", hash = "sha256:c286cf298426064079ed96a9e4a9d39e7f3e9bf15ba60701e95f5492f28415c7"}, - {file = "gitdb-4.0.10.tar.gz", hash = "sha256:6eb990b69df4e15bad899ea868dc46572c3f75339735663b81de79b06f17eb9a"}, -] - -[package.dependencies] -smmap = ">=3.0.1,<6" - -[[package]] -name = "gitpython" -version = "3.1.30" -description = "GitPython is a python library used to interact with Git repositories" -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "GitPython-3.1.30-py3-none-any.whl", hash = "sha256:cd455b0000615c60e286208ba540271af9fe531fa6a87cc590a7298785ab2882"}, - {file = "GitPython-3.1.30.tar.gz", hash = "sha256:769c2d83e13f5d938b7688479da374c4e3d49f71549aaf462b646db9602ea6f8"}, -] - -[package.dependencies] -gitdb = ">=4.0.1,<5" +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] [[package]] name = "isort" -version = "5.11.4" +version = "5.12.0" description = "A Python utility / library to sort Python imports." category = "main" optional = false -python-versions = ">=3.7.0" +python-versions = ">=3.8.0" files = [ - {file = "isort-5.11.4-py3-none-any.whl", hash = "sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b"}, - {file = "isort-5.11.4.tar.gz", hash = "sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6"}, + {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, + {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, ] [package.extras] -colors = ["colorama (>=0.4.3,<0.5.0)"] -pipfile-deprecated-finder = ["pipreqs", "requirementslib"] +colors = ["colorama (>=0.4.3)"] +pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] plugins = ["setuptools"] requirements-deprecated-finder = ["pip-api", "pipreqs"] @@ -631,157 +254,96 @@ files = [ {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, ] -[[package]] -name = "more-itertools" -version = "8.14.0" -description = "More routines for operating on iterables, beyond itertools" -category = "main" -optional = true -python-versions = ">=3.5" -files = [ - {file = "more-itertools-8.14.0.tar.gz", hash = "sha256:c09443cd3d5438b8dafccd867a6bc1cb0894389e90cb53d227456b0b0bccb750"}, - {file = "more_itertools-8.14.0-py3-none-any.whl", hash = "sha256:1bc4f91ee5b1b31ac7ceacc17c09befe6a40a503907baf9c839c229b5095cfd2"}, -] - [[package]] name = "mypy-extensions" -version = "0.4.3" -description = "Experimental type system extensions for programs checked with the mypy typechecker." +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." category = "main" optional = false -python-versions = "*" +python-versions = ">=3.5" files = [ - {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, - {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, ] [[package]] -name = "pandas-vet" -version = "0.2.3" -description = "A flake8 plugin to lint pandas in an opinionated way" +name = "packaging" +version = "23.1" +description = "Core utilities for Python packages" category = "main" -optional = true -python-versions = "*" +optional = false +python-versions = ">=3.7" files = [ - {file = "pandas-vet-0.2.3.tar.gz", hash = "sha256:58b64027a4c192b4b62272c1d8fdecc1733352452401282b697c1a32abe4656a"}, - {file = "pandas_vet-0.2.3-py3-none-any.whl", hash = "sha256:349e4240399ead316f64f9afc8e94a5bd5cfff45d7f448c5c22989e86c4ac782"}, + {file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"}, + {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, ] -[package.dependencies] -attrs = "*" -flake8 = ">3.0.0" - [[package]] name = "pathspec" -version = "0.10.3" +version = "0.11.2" description = "Utility library for gitignore style pattern matching of file paths." category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "pathspec-0.10.3-py3-none-any.whl", hash = "sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6"}, - {file = "pathspec-0.10.3.tar.gz", hash = "sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6"}, + {file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"}, + {file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"}, ] -[[package]] -name = "pbr" -version = "5.11.1" -description = "Python Build Reasonableness" -category = "main" -optional = true -python-versions = ">=2.6" -files = [ - {file = "pbr-5.11.1-py2.py3-none-any.whl", hash = "sha256:567f09558bae2b3ab53cb3c1e2e33e726ff3338e7bae3db5dc954b3a44eef12b"}, - {file = "pbr-5.11.1.tar.gz", hash = "sha256:aefc51675b0b533d56bb5fd1c8c6c0522fe31896679882e1c4c63d5e4a0fccb3"}, -] - -[[package]] -name = "pep8-naming" -version = "0.13.3" -description = "Check PEP-8 naming conventions, plugin for flake8" -category = "main" -optional = true -python-versions = ">=3.7" -files = [ - {file = "pep8-naming-0.13.3.tar.gz", hash = "sha256:1705f046dfcd851378aac3be1cd1551c7c1e5ff363bacad707d43007877fa971"}, - {file = "pep8_naming-0.13.3-py3-none-any.whl", hash = "sha256:1a86b8c71a03337c97181917e2b472f0f5e4ccb06844a0d6f0a33522549e7a80"}, -] - -[package.dependencies] -flake8 = ">=5.0.0" - [[package]] name = "platformdirs" -version = "2.6.2" +version = "3.10.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "platformdirs-2.6.2-py3-none-any.whl", hash = "sha256:83c8f6d04389165de7c9b6f0c682439697887bca0aa2f1c87ef1826be3584490"}, - {file = "platformdirs-2.6.2.tar.gz", hash = "sha256:e1fea1fe471b9ff8332e229df3cb7de4f53eeea4998d3b6bfff542115e998bd2"}, + {file = "platformdirs-3.10.0-py3-none-any.whl", hash = "sha256:d7c24979f292f916dc9cbf8648319032f551ea8c49a4c9bf2fb556a02070ec1d"}, + {file = "platformdirs-3.10.0.tar.gz", hash = "sha256:b45696dab2d7cc691a3226759c0d3b00c47c8b6e293d96f6436f733303f77f6d"}, ] [package.extras] -docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-autodoc-typehints (>=1.19.5)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] [[package]] name = "pycodestyle" -version = "2.10.0" +version = "2.11.0" description = "Python style guide checker" category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"}, - {file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"}, + {file = "pycodestyle-2.11.0-py2.py3-none-any.whl", hash = "sha256:5d1013ba8dc7895b548be5afb05740ca82454fd899971563d2ef625d090326f8"}, + {file = "pycodestyle-2.11.0.tar.gz", hash = "sha256:259bcc17857d8a8b3b4a2327324b79e5f020a13c16074670f9c8c8f872ea76d0"}, ] -[[package]] -name = "pydocstyle" -version = "6.2.3" -description = "Python docstring style checker" -category = "main" -optional = true -python-versions = ">=3.6" -files = [ - {file = "pydocstyle-6.2.3-py3-none-any.whl", hash = "sha256:a04ed1e6fe0be0970eddbb1681a7ab59b11eb92729fdb4b9b24f0eb11a25629e"}, - {file = "pydocstyle-6.2.3.tar.gz", hash = "sha256:d867acad25e48471f2ad8a40ef9813125e954ad675202245ca836cb6e28b2297"}, -] - -[package.dependencies] -snowballstemmer = ">=2.2.0" - -[package.extras] -toml = ["tomli (>=1.2.3)"] - [[package]] name = "pyflakes" -version = "3.0.1" +version = "3.1.0" description = "passive checker of Python programs" category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pyflakes-3.0.1-py2.py3-none-any.whl", hash = "sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf"}, - {file = "pyflakes-3.0.1.tar.gz", hash = "sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd"}, + {file = "pyflakes-3.1.0-py2.py3-none-any.whl", hash = "sha256:4132f6d49cb4dae6819e5379898f2b8cce3c5f23994194c24b77d5da2e36f774"}, + {file = "pyflakes-3.1.0.tar.gz", hash = "sha256:a0aae034c444db0071aa077972ba4768d40c830d9539fd45bf4cd3f8f6992efc"}, ] [[package]] name = "pylint" -version = "2.15.10" +version = "2.17.5" description = "python code static checker" category = "main" optional = false python-versions = ">=3.7.2" files = [ - {file = "pylint-2.15.10-py3-none-any.whl", hash = "sha256:9df0d07e8948a1c3ffa3b6e2d7e6e63d9fb457c5da5b961ed63106594780cc7e"}, - {file = "pylint-2.15.10.tar.gz", hash = "sha256:b3dc5ef7d33858f297ac0d06cc73862f01e4f2e74025ec3eff347ce0bc60baf5"}, + {file = "pylint-2.17.5-py3-none-any.whl", hash = "sha256:73995fb8216d3bed149c8d51bba25b2c52a8251a2c8ac846ec668ce38fab5413"}, + {file = "pylint-2.17.5.tar.gz", hash = "sha256:f7b601cbc06fef7e62a754e2b41294c2aa31f1cb659624b9a85bcba29eaf8252"}, ] [package.dependencies] -astroid = ">=2.12.13,<=2.14.0-dev0" +astroid = ">=2.15.6,<=2.17.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = [ {version = ">=0.2", markers = "python_version < \"3.11\""}, @@ -797,95 +359,6 @@ tomlkit = ">=0.10.1" spelling = ["pyenchant (>=3.2,<4.0)"] testutils = ["gitpython (>3)"] -[[package]] -name = "pyyaml" -version = "6.0" -description = "YAML parser and emitter for Python" -category = "main" -optional = true -python-versions = ">=3.6" -files = [ - {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, - {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, - {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, - {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, - {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, - {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, - {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, - {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, - {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, - {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, - {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, - {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, - {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, - {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, - {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, - {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, - {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, - {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, -] - -[[package]] -name = "smmap" -version = "5.0.0" -description = "A pure Python implementation of a sliding window memory map manager" -category = "main" -optional = true -python-versions = ">=3.6" -files = [ - {file = "smmap-5.0.0-py3-none-any.whl", hash = "sha256:2aba19d6a040e78d8b09de5c57e96207b09ed71d8e55ce0959eeee6c8e190d94"}, - {file = "smmap-5.0.0.tar.gz", hash = "sha256:c840e62059cd3be204b0c9c9f74be2c09d5648eddd4580d9314c3ecde0b30936"}, -] - -[[package]] -name = "snowballstemmer" -version = "2.2.0" -description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." -category = "main" -optional = true -python-versions = "*" -files = [ - {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, - {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, -] - -[[package]] -name = "stevedore" -version = "4.1.1" -description = "Manage dynamic plugins for Python applications" -category = "main" -optional = true -python-versions = ">=3.8" -files = [ - {file = "stevedore-4.1.1-py3-none-any.whl", hash = "sha256:aa6436565c069b2946fe4ebff07f5041e0c8bf18c7376dd29edf80cf7d524e4e"}, - {file = "stevedore-4.1.1.tar.gz", hash = "sha256:7f8aeb6e3f90f96832c301bff21a7eb5eefbe894c88c506483d355565d88cc1a"}, -] - -[package.dependencies] -pbr = ">=2.0.0,<2.1.0 || >2.1.0" - [[package]] name = "tomli" version = "2.0.1" @@ -900,106 +373,151 @@ files = [ [[package]] name = "tomlkit" -version = "0.11.6" +version = "0.12.1" description = "Style preserving TOML library" category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "tomlkit-0.11.6-py3-none-any.whl", hash = "sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b"}, - {file = "tomlkit-0.11.6.tar.gz", hash = "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"}, + {file = "tomlkit-0.12.1-py3-none-any.whl", hash = "sha256:712cbd236609acc6a3e2e97253dfc52d4c2082982a88f61b640ecf0817eab899"}, + {file = "tomlkit-0.12.1.tar.gz", hash = "sha256:38e1ff8edb991273ec9f6181244a6a391ac30e9f5098e7535640ea6be97a7c86"}, ] [[package]] name = "typing-extensions" -version = "4.4.0" +version = "4.7.1" description = "Backported and Experimental Type Hints for Python 3.7+" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, - {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, ] [[package]] name = "wrapt" -version = "1.14.1" +version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ - {file = "wrapt-1.14.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3"}, - {file = "wrapt-1.14.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef"}, - {file = "wrapt-1.14.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28"}, - {file = "wrapt-1.14.1-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59"}, - {file = "wrapt-1.14.1-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87"}, - {file = "wrapt-1.14.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1"}, - {file = "wrapt-1.14.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b"}, - {file = "wrapt-1.14.1-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462"}, - {file = "wrapt-1.14.1-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1"}, - {file = "wrapt-1.14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320"}, - {file = "wrapt-1.14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2"}, - {file = "wrapt-1.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4"}, - {file = "wrapt-1.14.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069"}, - {file = "wrapt-1.14.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310"}, - {file = "wrapt-1.14.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f"}, - {file = "wrapt-1.14.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656"}, - {file = "wrapt-1.14.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c"}, - {file = "wrapt-1.14.1-cp310-cp310-win32.whl", hash = "sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8"}, - {file = "wrapt-1.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164"}, - {file = "wrapt-1.14.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907"}, - {file = "wrapt-1.14.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3"}, - {file = "wrapt-1.14.1-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3"}, - {file = "wrapt-1.14.1-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d"}, - {file = "wrapt-1.14.1-cp35-cp35m-win32.whl", hash = "sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7"}, - {file = "wrapt-1.14.1-cp35-cp35m-win_amd64.whl", hash = "sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00"}, - {file = "wrapt-1.14.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4"}, - {file = "wrapt-1.14.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1"}, - {file = "wrapt-1.14.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1"}, - {file = "wrapt-1.14.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff"}, - {file = "wrapt-1.14.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d"}, - {file = "wrapt-1.14.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1"}, - {file = "wrapt-1.14.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569"}, - {file = "wrapt-1.14.1-cp36-cp36m-win32.whl", hash = "sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed"}, - {file = "wrapt-1.14.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471"}, - {file = "wrapt-1.14.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248"}, - {file = "wrapt-1.14.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68"}, - {file = "wrapt-1.14.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d"}, - {file = "wrapt-1.14.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77"}, - {file = "wrapt-1.14.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7"}, - {file = "wrapt-1.14.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015"}, - {file = "wrapt-1.14.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a"}, - {file = "wrapt-1.14.1-cp37-cp37m-win32.whl", hash = "sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853"}, - {file = "wrapt-1.14.1-cp37-cp37m-win_amd64.whl", hash = "sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c"}, - {file = "wrapt-1.14.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456"}, - {file = "wrapt-1.14.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f"}, - {file = "wrapt-1.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc"}, - {file = "wrapt-1.14.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1"}, - {file = "wrapt-1.14.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af"}, - {file = "wrapt-1.14.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b"}, - {file = "wrapt-1.14.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0"}, - {file = "wrapt-1.14.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57"}, - {file = "wrapt-1.14.1-cp38-cp38-win32.whl", hash = "sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5"}, - {file = "wrapt-1.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d"}, - {file = "wrapt-1.14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383"}, - {file = "wrapt-1.14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7"}, - {file = "wrapt-1.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86"}, - {file = "wrapt-1.14.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735"}, - {file = "wrapt-1.14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b"}, - {file = "wrapt-1.14.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3"}, - {file = "wrapt-1.14.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3"}, - {file = "wrapt-1.14.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe"}, - {file = "wrapt-1.14.1-cp39-cp39-win32.whl", hash = "sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5"}, - {file = "wrapt-1.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb"}, - {file = "wrapt-1.14.1.tar.gz", hash = "sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d"}, + {file = "wrapt-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:ca1cccf838cd28d5a0883b342474c630ac48cac5df0ee6eacc9c7290f76b11c1"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e826aadda3cae59295b95343db8f3d965fb31059da7de01ee8d1c40a60398b29"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:5fc8e02f5984a55d2c653f5fea93531e9836abbd84342c1d1e17abc4a15084c2"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:96e25c8603a155559231c19c0349245eeb4ac0096fe3c1d0be5c47e075bd4f46"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:40737a081d7497efea35ab9304b829b857f21558acfc7b3272f908d33b0d9d4c"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:f87ec75864c37c4c6cb908d282e1969e79763e0d9becdfe9fe5473b7bb1e5f09"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:1286eb30261894e4c70d124d44b7fd07825340869945c79d05bda53a40caa079"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:493d389a2b63c88ad56cdc35d0fa5752daac56ca755805b1b0c530f785767d5e"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:58d7a75d731e8c63614222bcb21dd992b4ab01a399f1f09dd82af17bbfc2368a"}, + {file = "wrapt-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:21f6d9a0d5b3a207cdf7acf8e58d7d13d463e639f0c7e01d82cdb671e6cb7923"}, + {file = "wrapt-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ce42618f67741d4697684e501ef02f29e758a123aa2d669e2d964ff734ee00ee"}, + {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41d07d029dd4157ae27beab04d22b8e261eddfc6ecd64ff7000b10dc8b3a5727"}, + {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54accd4b8bc202966bafafd16e69da9d5640ff92389d33d28555c5fd4f25ccb7"}, + {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fbfbca668dd15b744418265a9607baa970c347eefd0db6a518aaf0cfbd153c0"}, + {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:76e9c727a874b4856d11a32fb0b389afc61ce8aaf281ada613713ddeadd1cfec"}, + {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e20076a211cd6f9b44a6be58f7eeafa7ab5720eb796975d0c03f05b47d89eb90"}, + {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a74d56552ddbde46c246b5b89199cb3fd182f9c346c784e1a93e4dc3f5ec9975"}, + {file = "wrapt-1.15.0-cp310-cp310-win32.whl", hash = "sha256:26458da5653aa5b3d8dc8b24192f574a58984c749401f98fff994d41d3f08da1"}, + {file = "wrapt-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:75760a47c06b5974aa5e01949bf7e66d2af4d08cb8c1d6516af5e39595397f5e"}, + {file = "wrapt-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ba1711cda2d30634a7e452fc79eabcadaffedf241ff206db2ee93dd2c89a60e7"}, + {file = "wrapt-1.15.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56374914b132c702aa9aa9959c550004b8847148f95e1b824772d453ac204a72"}, + {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a89ce3fd220ff144bd9d54da333ec0de0399b52c9ac3d2ce34b569cf1a5748fb"}, + {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3bbe623731d03b186b3d6b0d6f51865bf598587c38d6f7b0be2e27414f7f214e"}, + {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3abbe948c3cbde2689370a262a8d04e32ec2dd4f27103669a45c6929bcdbfe7c"}, + {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b67b819628e3b748fd3c2192c15fb951f549d0f47c0449af0764d7647302fda3"}, + {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:7eebcdbe3677e58dd4c0e03b4f2cfa346ed4049687d839adad68cc38bb559c92"}, + {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:74934ebd71950e3db69960a7da29204f89624dde411afbfb3b4858c1409b1e98"}, + {file = "wrapt-1.15.0-cp311-cp311-win32.whl", hash = "sha256:bd84395aab8e4d36263cd1b9308cd504f6cf713b7d6d3ce25ea55670baec5416"}, + {file = "wrapt-1.15.0-cp311-cp311-win_amd64.whl", hash = "sha256:a487f72a25904e2b4bbc0817ce7a8de94363bd7e79890510174da9d901c38705"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:4ff0d20f2e670800d3ed2b220d40984162089a6e2c9646fdb09b85e6f9a8fc29"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9ed6aa0726b9b60911f4aed8ec5b8dd7bf3491476015819f56473ffaef8959bd"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:896689fddba4f23ef7c718279e42f8834041a21342d95e56922e1c10c0cc7afb"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:75669d77bb2c071333417617a235324a1618dba66f82a750362eccbe5b61d248"}, + {file = "wrapt-1.15.0-cp35-cp35m-win32.whl", hash = "sha256:fbec11614dba0424ca72f4e8ba3c420dba07b4a7c206c8c8e4e73f2e98f4c559"}, + {file = "wrapt-1.15.0-cp35-cp35m-win_amd64.whl", hash = "sha256:fd69666217b62fa5d7c6aa88e507493a34dec4fa20c5bd925e4bc12fce586639"}, + {file = "wrapt-1.15.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b0724f05c396b0a4c36a3226c31648385deb6a65d8992644c12a4963c70326ba"}, + {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bbeccb1aa40ab88cd29e6c7d8585582c99548f55f9b2581dfc5ba68c59a85752"}, + {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:38adf7198f8f154502883242f9fe7333ab05a5b02de7d83aa2d88ea621f13364"}, + {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:578383d740457fa790fdf85e6d346fda1416a40549fe8db08e5e9bd281c6a475"}, + {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a4cbb9ff5795cd66f0066bdf5947f170f5d63a9274f99bdbca02fd973adcf2a8"}, + {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:af5bd9ccb188f6a5fdda9f1f09d9f4c86cc8a539bd48a0bfdc97723970348418"}, + {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:b56d5519e470d3f2fe4aa7585f0632b060d532d0696c5bdfb5e8319e1d0f69a2"}, + {file = "wrapt-1.15.0-cp36-cp36m-win32.whl", hash = "sha256:77d4c1b881076c3ba173484dfa53d3582c1c8ff1f914c6461ab70c8428b796c1"}, + {file = "wrapt-1.15.0-cp36-cp36m-win_amd64.whl", hash = "sha256:077ff0d1f9d9e4ce6476c1a924a3332452c1406e59d90a2cf24aeb29eeac9420"}, + {file = "wrapt-1.15.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5c5aa28df055697d7c37d2099a7bc09f559d5053c3349b1ad0c39000e611d317"}, + {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a8564f283394634a7a7054b7983e47dbf39c07712d7b177b37e03f2467a024e"}, + {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:780c82a41dc493b62fc5884fb1d3a3b81106642c5c5c78d6a0d4cbe96d62ba7e"}, + {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e169e957c33576f47e21864cf3fc9ff47c223a4ebca8960079b8bd36cb014fd0"}, + {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:b02f21c1e2074943312d03d243ac4388319f2456576b2c6023041c4d57cd7019"}, + {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f2e69b3ed24544b0d3dbe2c5c0ba5153ce50dcebb576fdc4696d52aa22db6034"}, + {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d787272ed958a05b2c86311d3a4135d3c2aeea4fc655705f074130aa57d71653"}, + {file = "wrapt-1.15.0-cp37-cp37m-win32.whl", hash = "sha256:02fce1852f755f44f95af51f69d22e45080102e9d00258053b79367d07af39c0"}, + {file = "wrapt-1.15.0-cp37-cp37m-win_amd64.whl", hash = "sha256:abd52a09d03adf9c763d706df707c343293d5d106aea53483e0ec8d9e310ad5e"}, + {file = "wrapt-1.15.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdb4f085756c96a3af04e6eca7f08b1345e94b53af8921b25c72f096e704e145"}, + {file = "wrapt-1.15.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:230ae493696a371f1dbffaad3dafbb742a4d27a0afd2b1aecebe52b740167e7f"}, + {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63424c681923b9f3bfbc5e3205aafe790904053d42ddcc08542181a30a7a51bd"}, + {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d6bcbfc99f55655c3d93feb7ef3800bd5bbe963a755687cbf1f490a71fb7794b"}, + {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c99f4309f5145b93eca6e35ac1a988f0dc0a7ccf9ccdcd78d3c0adf57224e62f"}, + {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b130fe77361d6771ecf5a219d8e0817d61b236b7d8b37cc045172e574ed219e6"}, + {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:96177eb5645b1c6985f5c11d03fc2dbda9ad24ec0f3a46dcce91445747e15094"}, + {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d5fe3e099cf07d0fb5a1e23d399e5d4d1ca3e6dfcbe5c8570ccff3e9208274f7"}, + {file = "wrapt-1.15.0-cp38-cp38-win32.whl", hash = "sha256:abd8f36c99512755b8456047b7be10372fca271bf1467a1caa88db991e7c421b"}, + {file = "wrapt-1.15.0-cp38-cp38-win_amd64.whl", hash = "sha256:b06fa97478a5f478fb05e1980980a7cdf2712015493b44d0c87606c1513ed5b1"}, + {file = "wrapt-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2e51de54d4fb8fb50d6ee8327f9828306a959ae394d3e01a1ba8b2f937747d86"}, + {file = "wrapt-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0970ddb69bba00670e58955f8019bec4a42d1785db3faa043c33d81de2bf843c"}, + {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76407ab327158c510f44ded207e2f76b657303e17cb7a572ffe2f5a8a48aa04d"}, + {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cd525e0e52a5ff16653a3fc9e3dd827981917d34996600bbc34c05d048ca35cc"}, + {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d37ac69edc5614b90516807de32d08cb8e7b12260a285ee330955604ed9dd29"}, + {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:078e2a1a86544e644a68422f881c48b84fef6d18f8c7a957ffd3f2e0a74a0d4a"}, + {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:2cf56d0e237280baed46f0b5316661da892565ff58309d4d2ed7dba763d984b8"}, + {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:7dc0713bf81287a00516ef43137273b23ee414fe41a3c14be10dd95ed98a2df9"}, + {file = "wrapt-1.15.0-cp39-cp39-win32.whl", hash = "sha256:46ed616d5fb42f98630ed70c3529541408166c22cdfd4540b88d5f21006b0eff"}, + {file = "wrapt-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:eef4d64c650f33347c1f9266fa5ae001440b232ad9b98f1f43dfe7a79435c0a6"}, + {file = "wrapt-1.15.0-py3-none-any.whl", hash = "sha256:64b1df0f83706b4ef4cfb4fb0e4c2669100fd7ecacfb59e091fad300d4e04640"}, + {file = "wrapt-1.15.0.tar.gz", hash = "sha256:d06730c6aed78cee4126234cf2d071e01b44b915e725a6cb439a879ec9754a3a"}, ] +[[package]] +name = "yapf" +version = "0.40.1" +description = "A formatter for Python code." +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "yapf-0.40.1-py3-none-any.whl", hash = "sha256:b8bfc1f280949153e795181768ca14ef43d7312629a06c43e7abd279323af313"}, + {file = "yapf-0.40.1.tar.gz", hash = "sha256:958587eb5c8ec6c860119a9c25d02addf30a44f75aa152a4220d30e56a98037c"}, +] + +[package.dependencies] +importlib-metadata = ">=6.6.0" +platformdirs = ">=3.5.1" +tomli = ">=2.0.1" + +[[package]] +name = "zipp" +version = "3.16.2" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "zipp-3.16.2-py3-none-any.whl", hash = "sha256:679e51dd4403591b2d6838a48de3d283f3d188412a9782faadf845f298736ba0"}, + {file = "zipp-3.16.2.tar.gz", hash = "sha256:ebc15946aa78bd63458992fc81ec3b6f7b1e92d51c35e6de1c3804e73b799147"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] + [extras] -plugins = ["flake8-2020", "flake8-annotations", "flake8-bandit", "flake8-blind-except", "flake8-bugbear", "flake8-builtins", "flake8-commas", "flake8-comprehensions", "flake8-datetimez", "flake8-debugger", "flake8-docstrings", "flake8-errmsg", "flake8-implicit-str-concat", "flake8-isort", "flake8-pie", "flake8-print", "flake8-quotes", "flake8-return", "flake8-simplify", "flake8-super", "flake8-tidy-imports", "pandas-vet", "pep8-naming"] +formatter = ["black", "yapf", "autopep8"] +linter = ["autoflake", "flake8", "pycodestyle", "pyflakes", "pylint", "isort"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.12" -content-hash = "33068d5ff7ce23950c15061750785124c432653887fa542b808ae0165234ccf7" +content-hash = "6d486d66e3a6567aea218bed65725bf557c28875bcc4e91c2e9810d367ea035e" diff --git a/scripts/benchmarks/pyproject.toml b/scripts/benchmarks/pyproject.toml index 278f7b0980..0018532fc4 100644 --- a/scripts/benchmarks/pyproject.toml +++ b/scripts/benchmarks/pyproject.toml @@ -6,70 +6,31 @@ authors = ["Charles Marsh "] [tool.poetry.dependencies] python = ">=3.10,<3.12" -autoflake = "^2.0.0" -flake8 = "^6.0.0" -pycodestyle = "^2.10.0" -pyflakes = "^3.0.1" -pylint = "^2.15.10" -black = "^22.12.0" -isort = "^5.11.4" -flake8-2020 = { version = "*", optional = true } -flake8-annotations = { version = "*", optional = true } -flake8-bandit = { version = "*", optional = true } -flake8-blind-except = { version = "*", optional = true } -# flake8-boolean-trap = { version = "*", optional = true } -flake8-bugbear = { version = "*", optional = true } -flake8-builtins = { version = "*", optional = true } -flake8-commas = { version = "*", optional = true } -flake8-comprehensions = { version = "*", optional = true } -flake8-datetimez = { version = "*", optional = true } -flake8-debugger = { version = "*", optional = true } -flake8-docstrings = { version = "*", optional = true } -# flake8-eradicate = { version = "*", optional = true } -flake8-errmsg = { version = "*", optional = true } -flake8-implicit-str-concat = { version = "*", optional = true } -# flake8-import-conventions = { version = "*", optional = true } -flake8-isort = { version = "*", optional = true } -flake8-pie = { version = "*", optional = true } -flake8-print = { version = "*", optional = true } -flake8-quotes = { version = "*", optional = true } -flake8-return = { version = "*", optional = true } -flake8-simplify = { version = "*", optional = true } -flake8-super = { version = "*", optional = true } -flake8-tidy-imports = { version = "*", optional = true } -pandas-vet = { version = "*", optional = true } -pep8-naming = { version = "*", optional = true } +autoflake = "*" +autopep8 = "*" +black = "*" +flake8 = "*" +isort = "*" +pycodestyle = "*" +pyflakes = "*" +pylint = "*" +yapf = "*" [tool.poetry.dev-dependencies] [tool.poetry.extras] -plugins = [ - "flake8-2020", - "flake8-annotations", - "flake8-bandit", - "flake8-blind-except", - # "flake8-boolean-trap", - "flake8-bugbear", - "flake8-builtins", - "flake8-commas", - "flake8-comprehensions", - "flake8-datetimez", - "flake8-debugger", - "flake8-docstrings", - # "flake8-eradicate", - "flake8-errmsg", - "flake8-implicit-str-concat", - # "flake8-import-conventions", - "flake8-isort", - "flake8-pie", - "flake8-print", - "flake8-quotes", - "flake8-return", - "flake8-simplify", - "flake8-super", - "flake8-tidy-imports", - "pandas-vet", - "pep8-naming", +formatter = [ + "black", + "yapf", + "autopep8", +] +linter = [ + "autoflake", + "flake8", + "pycodestyle", + "pyflakes", + "pylint", + "isort", ] [build-system] diff --git a/scripts/benchmarks/run_formatter.sh b/scripts/benchmarks/run_formatter.sh new file mode 100755 index 0000000000..f4acd73fcd --- /dev/null +++ b/scripts/benchmarks/run_formatter.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env sh + +### +# Benchmark the Ruff formatter's performance against a variety of similar tools. +# +# Expects to be run from the repo root after invoking `cargo build --release`, +# in an environment with access to `black`, `autopep8`, and `yapf` (most recently: +# `black` v23.9.1, `autopep8` v2.0.4, and `yapf` v0.40.1). +# +# Example usage: +# +# ./scripts/benchmarks/run_formatter.sh ~/workspace/zulip +### + +TARGET_DIR=${1} + +# In each case, ensure that we format the code in-place before invoking a given tool. This ensures +# a fair comparison across tools, since every tool is then running on a repository that already +# matches that tool's desired formatting. +# +# For example, if we're benchmarking Black's preview style, we first run `black --preview` over the +# target directory, thus ensuring that we're benchmarking preview style against a codebase that +# already conforms to it. The same goes for yapf, autoepp8, etc. + +# Benchmark 1: Write to disk. +hyperfine --ignore-failure \ + --prepare "./target/release/ruff format ${TARGET_DIR}" \ + "./target/release/ruff format ${TARGET_DIR}" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe --preview" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe --preview" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast --preview" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast --preview" \ + --prepare "autopep8 ${TARGET_DIR} --recursive --in-place" \ + "autopep8 ${TARGET_DIR} --recursive --in-place" \ + --prepare "yapf ${TARGET_DIR} --parallel --recursive --in-place" \ + "yapf ${TARGET_DIR} --parallel --recursive --in-place" + +# Benchmark 2: Write to disk, but only use one thread. +hyperfine --ignore-failure \ + --prepare "./target/release/ruff format ${TARGET_DIR}" \ + "RAYON_NUM_THREADS=1 ./target/release/ruff format ${TARGET_DIR}" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --workers=1 --safe" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --workers=1 --fast" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe --preview" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --workers=1 --safe --preview" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast --preview" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --workers=1 --fast --preview" \ + --prepare "autopep8 ${TARGET_DIR} --recursive --in-place" \ + "autopep8 ${TARGET_DIR} --in-place --recursive --jobs=1" \ + --prepare "yapf ${TARGET_DIR} --parallel --recursive --in-place" \ + "yapf ${TARGET_DIR} --recursive --in-place" + +# Benchmark 3: Check formatting, but don't write to disk. +hyperfine --ignore-failure \ + --prepare "./target/release/ruff format ${TARGET_DIR}" \ + "./target/release/ruff format ${TARGET_DIR} --check" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --check --safe" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --check --fast" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --safe --preview" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --check --safe --preview" \ + --prepare "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --fast --preview" \ + "BLACK_CACHE_DIR=/dev/null black ${TARGET_DIR} --check --fast --preview" \ + --prepare "autopep8 ${TARGET_DIR} --recursive --in-place" \ + "autopep8 ${TARGET_DIR} --recursive --diff" \ + --prepare "yapf ${TARGET_DIR} --parallel --recursive --in-place" \ + "yapf ${TARGET_DIR} --parallel --recursive --quiet" diff --git a/scripts/generate_mkdocs.py b/scripts/generate_mkdocs.py index f6954b153a..60ef1af94f 100644 --- a/scripts/generate_mkdocs.py +++ b/scripts/generate_mkdocs.py @@ -25,6 +25,7 @@ SECTIONS: list[Section] = [ Section("Installation", "installation.md", generated=False), Section("Usage", "usage.md", generated=False), Section("Configuration", "configuration.md", generated=False), + Section("Preview", "preview.md", generated=False), Section("Rules", "rules.md", generated=True), Section("Settings", "settings.md", generated=True), Section("Editor Integrations", "editor-integrations.md", generated=False),