@willbooster/tree-sitter-python 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -10
- package/package.json +3 -3
- package/tree-sitter-python.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
# @willbooster/tree-sitter-python
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@willbooster/tree-sitter-python)
|
|
4
|
+
[](https://www.npmjs.com/package/@willbooster/tree-sitter-python)
|
|
3
5
|
[](https://github.com/WillBooster/tree-sitter-python/actions/workflows/test.yml)
|
|
4
6
|
[](https://github.com/WillBooster/tree-sitter-python/actions/workflows/test-rust.yml)
|
|
5
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
6
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
7
9
|
[](https://crates.io/crates/willbooster-tree-sitter-python)
|
|
8
10
|
|
|
9
11
|
Python grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
10
12
|
[tree-sitter/tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python). We are grateful
|
|
11
13
|
to its authors and contributors. This is not an official release of that project.
|
|
12
14
|
|
|
13
|
-
This fork ships the unmodified grammar of upstream v0.25.0 as a compact
|
|
14
|
-
|
|
15
|
+
This fork ships the unmodified grammar of upstream v0.25.0 as a compact parser, generated by the parser generator of
|
|
16
|
+
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter). The parser carries that fork's own ABI number, so
|
|
17
|
+
it loads only with the WillBooster runtime (`willbooster-tree-sitter` or `@willbooster/web-tree-sitter`) 2.0.0 or later,
|
|
18
|
+
not with upstream's tree-sitter.
|
|
15
19
|
|
|
16
20
|
## Usage
|
|
17
21
|
|
|
18
22
|
The npm package ships `tree-sitter-python.wasm` for
|
|
19
23
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
20
|
-
browsers, and Cloudflare Workers. The
|
|
24
|
+
browsers, and Cloudflare Workers. The parser requires runtime 2.0.0 or later.
|
|
21
25
|
|
|
22
26
|
In Node.js and Bun, load the grammar from its path:
|
|
23
27
|
|
|
@@ -60,12 +64,12 @@ The package also ships the queries in `queries/` and the node types in `src/node
|
|
|
60
64
|
|
|
61
65
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-python) and on
|
|
62
66
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
63
|
-
fuzzed with. The
|
|
67
|
+
fuzzed with. The parser requires runtime 2.0.0 or later:
|
|
64
68
|
|
|
65
69
|
```toml
|
|
66
70
|
[dependencies]
|
|
67
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
68
|
-
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "
|
|
71
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "2" }
|
|
72
|
+
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "2" }
|
|
69
73
|
```
|
|
70
74
|
|
|
71
75
|
```rust
|
|
@@ -90,7 +94,7 @@ not the ones this package ships with. Its first run downloads that CLI from the
|
|
|
90
94
|
with `cargo` (whose build runs the CMake that `mise.toml` pins) when the download fails or the release has no binary that runs here. Run other CLI
|
|
91
95
|
commands through it as well (e.g. `script/tree-sitter parse file.py`).
|
|
92
96
|
|
|
93
|
-
`bun run generate` records a fresh
|
|
97
|
+
`bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and Git-tracked
|
|
94
98
|
Python files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
|
|
95
99
|
`tree-sitter.json`, a corpus case, or a tracked example,
|
|
96
100
|
regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
|
|
@@ -111,12 +115,14 @@ and the release build regenerate the parsers before compiling them.
|
|
|
111
115
|
(ten times the lines take about ten times the CPU time, under a ceiling), since consumers parse files while they are
|
|
112
116
|
being edited. It loads the Wasm build through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after
|
|
113
117
|
regenerating the parser;
|
|
118
|
+
- a native CLI crash regression for deeply indented strings (`test/unit/deepIndentation.test.ts`);
|
|
114
119
|
- a check that `package.json` and `Cargo.lock` test the same runtime version (`test/unit/runtimeVersion.test.ts`);
|
|
115
120
|
- checks that the Wasm build parses in Chromium (`test/unit/browser/`) and in Cloudflare Workers with and without
|
|
116
121
|
Node.js compatibility (`test/unit/workerd.test.ts`). Run `bun run test/ci-setup` once to install Chromium.
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
Tests and `script/parse-examples` keep native parser builds under this checkout's `.tmp/` instead of the CLI cache shared by every checkout.
|
|
124
|
+
See `test/unit/run.ts`, `test/unit/deepIndentation.test.ts`, `script/fuzz-corpus`, and `script/parse-examples`
|
|
125
|
+
for their build locations and cleanup.
|
|
120
126
|
|
|
121
127
|
CI also runs these tests on Linux arm64 and macOS, where the CLI compiles the parser and the scanner with the platform's
|
|
122
128
|
C compiler as the crate does for its users, and fuzzes the parser with libFuzzer and sanitizers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-python",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Python grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
49
|
"@willbooster/wb": "22.24.0",
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
50
|
+
"@willbooster/web-tree-sitter": "2.0.1",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
52
|
"lefthook": "2.1.16",
|
|
53
53
|
"oxfmt": "0.71.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"wrangler": "4.147.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@willbooster/web-tree-sitter": "^
|
|
66
|
+
"@willbooster/web-tree-sitter": "^2.0.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|