Skip to content

fix(py): switch to tree-sitter-python-orchard for PEP 798 support - #194

Merged
moznion merged 1 commit into
mainfrom
fix/py-pep798-orchard
Nov 3, 2026
Merged

moznion merged 1 commit into
mainfrom
fix/py-pep798-orchard

Conversation

@moznion

@moznion moznion commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Fixes #193

Summary

The official tree-sitter-python 0.25 grammar does not support PEP 798 (Python 3.15) unpacking in comprehensions, so code like {**d for d in ds} produced a parse error and the comprehension's complexity could be miscounted. Upstream has been inactive since 2025-09; the fix (tree-sitter/tree-sitter-python#353) is merged only in the community fork tree-sitter-python-orchard.

Changes

  • cccc-py: replace tree-sitter-python = "0.25" with tree-sitter-python-orchard = "0.6" (ABI 14 via tree-sitter-language 0.1, works with tree-sitter 0.27; no adapter logic changes beyond the import).
  • Add a regression test covering {**d for …}, {**d async for …}, [*xs for …], {*xs for …}, and (*xs for …); each parses cleanly and scores like the written-out loop.
  • Update README, docs/ADDING_A_LANGUAGE.md, a comment in deep_nesting.rs, and both lockfiles (workspace + cccc-py/fuzz).

Verification

  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, and cargo test --workspace all pass (including existing Python fixtures and deep_nesting).
  • The issue's repro now reports parse_error_count: 0, cognitive 1, cyclomatic 2.

🤖 Generated with Claude Code

The official tree-sitter-python 0.25 grammar fails to parse PEP 798
unpacking in comprehensions (e.g. `{**d for d in ds}`), reporting a
syntax error and potentially miscounting the comprehension's
complexity. Upstream is unmaintained; the fix lives in the community
fork tree-sitter-python-orchard, which is ABI-compatible with
tree-sitter 0.27.

Fixes #193

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Code Complexity (src)

main (af2abb8) #194 (c4ed35d) +/-
Function count 2980 2981 +1
Cognitive: total 3485 3486 +1
Cognitive: max 63 63 0
Cognitive: median 0 0 0
Cognitive: p90 3 3 0
Cyclomatic: total 6034 6036 +2
Cyclomatic: max 52 52 0
Cyclomatic: median 1 1 0
Cyclomatic: p90 4 4 0

Reported by octocov

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (af2abb8) #194 (c4ed35d) +/-
Coverage 95.0% 95.0% +0.0%
Test Execution Time 4m34s 15s -4m19s
Details
  |                     | main (af2abb8) | #194 (c4ed35d) |  +/-   |
  |---------------------|----------------|----------------|--------|
+ | Coverage            |          95.0% |          95.0% |  +0.0% |
  |   Files             |             36 |             36 |      0 |
  |   Lines             |          16835 |          16849 |    +14 |
+ |   Covered           |          16002 |          16016 |    +14 |
+ | Test Execution Time |          4m34s |            15s | -4m19s |

Code coverage of files in pull request scope (96.9% → 96.9%, patch 100.0%)

Files Coverage +/- Patch Coverage Status
crates/cccc-py/src/lib.rs 96.9% +0.0% 100.0% modified

Reported by octocov

@moznion
moznion merged commit 4f84494 into main Nov 3, 2026
33 checks passed
@moznion
moznion deleted the fix/py-pep798-orchard branch November 3, 2026 13:04
@github-actions github-actions Bot mentioned this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: parse error on PEP 798 unpacking in comprehensions (e.g. {**d for d in ds})

1 participant