@willbooster/tree-sitter-python 2.3.1 → 3.0.0
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 +6 -4
- package/grammar.js +6 -3
- package/package.json +1 -1
- package/queries/highlights.scm +6 -1
- package/src/node-types.json +0 -20
- package/tree-sitter-python.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -15,14 +15,14 @@ to its authors and contributors. This is not an official release of that project
|
|
|
15
15
|
This fork builds on upstream v0.25.0 with grammar, scanner, and highlighting fixes, including Python 3.15
|
|
16
16
|
unpacking comprehensions. It ships a compact parser generated by the parser generator of
|
|
17
17
|
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter). The parser carries that fork's own ABI number, so
|
|
18
|
-
it loads only with the WillBooster runtime (`willbooster-tree-sitter` or `@willbooster/web-tree-sitter`) 2.
|
|
18
|
+
it loads only with the WillBooster runtime (`willbooster-tree-sitter` or `@willbooster/web-tree-sitter`) 2.x,
|
|
19
19
|
not with upstream's tree-sitter.
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
23
|
The npm package ships `tree-sitter-python.wasm` for
|
|
24
24
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
25
|
-
browsers, and Cloudflare Workers. The parser requires runtime 2.
|
|
25
|
+
browsers, and Cloudflare Workers. The parser requires runtime 2.x.
|
|
26
26
|
|
|
27
27
|
In Node.js and Bun, load the grammar from its path:
|
|
28
28
|
|
|
@@ -63,14 +63,16 @@ parser.setLanguage(await Language.load(python));
|
|
|
63
63
|
|
|
64
64
|
The package also ships the queries in `queries/` and the node types in `src/node-types.json`.
|
|
65
65
|
|
|
66
|
+
Qualified generic bases use `member_type` inside `generic_type`. Structured unpacked annotations and unpacked generic arguments use a `type` child inside `splat_type`. Expression-valued starred parameter annotations, such as `*args: *factory()`, keep a direct expression child instead. Ordinary value unpacks keep their expression tree.
|
|
67
|
+
|
|
66
68
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-python) and on
|
|
67
69
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
68
|
-
fuzzed with. The parser requires runtime 2.
|
|
70
|
+
fuzzed with. The parser requires runtime 2.x:
|
|
69
71
|
|
|
70
72
|
```toml
|
|
71
73
|
[dependencies]
|
|
72
74
|
tree-sitter = { package = "willbooster-tree-sitter", version = "2" }
|
|
73
|
-
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "
|
|
75
|
+
tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "3" }
|
|
74
76
|
```
|
|
75
77
|
|
|
76
78
|
```rust
|
package/grammar.js
CHANGED
|
@@ -494,7 +494,7 @@ module.exports = grammar({
|
|
|
494
494
|
_default_splat_type: ($) => seq('*', choice($.primary_expression, prec.dynamic(1, alias($._default_type, $.type)))),
|
|
495
495
|
|
|
496
496
|
_generic_type_arguments: ($) =>
|
|
497
|
-
seq('[', commaSep1(choice($.type, alias($.
|
|
497
|
+
seq('[', commaSep1(choice($.type, alias($._default_splat_argument, $.splat_type))), optional(','), ']'),
|
|
498
498
|
|
|
499
499
|
argument_list: ($) =>
|
|
500
500
|
seq(
|
|
@@ -832,7 +832,7 @@ module.exports = grammar({
|
|
|
832
832
|
PREC.typed_parameter,
|
|
833
833
|
choice(
|
|
834
834
|
seq(choice($.identifier, $.dictionary_splat_pattern), ':', field('type', $.type)),
|
|
835
|
-
seq($.list_splat_pattern, ':', field('type', choice($.type, alias($.
|
|
835
|
+
seq($.list_splat_pattern, ':', field('type', choice($.type, alias($._default_splat_type, $.splat_type))))
|
|
836
836
|
)
|
|
837
837
|
),
|
|
838
838
|
|
|
@@ -841,7 +841,10 @@ module.exports = grammar({
|
|
|
841
841
|
generic_type: ($) =>
|
|
842
842
|
prec.dynamic(
|
|
843
843
|
1,
|
|
844
|
-
seq(
|
|
844
|
+
seq(
|
|
845
|
+
choice($.identifier, alias('type', $.identifier), alias($._default_member_type, $.member_type)),
|
|
846
|
+
alias($._generic_type_arguments, $.type_parameter)
|
|
847
|
+
)
|
|
845
848
|
),
|
|
846
849
|
union_type: ($) => prec.left(seq($.type, '|', $.type)),
|
|
847
850
|
constrained_type: ($) => prec.right(seq($.type, ':', $.type)),
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
|
@@ -63,7 +63,12 @@
|
|
|
63
63
|
|
|
64
64
|
(attribute attribute: (identifier) @property)
|
|
65
65
|
(type (identifier) @type)
|
|
66
|
-
(
|
|
66
|
+
(splat_type (identifier) @type)
|
|
67
|
+
(class_definition
|
|
68
|
+
superclasses: (argument_list
|
|
69
|
+
(subscript subscript: (list_splat (identifier) @type))))
|
|
70
|
+
(type (member_type (identifier) @type .))
|
|
71
|
+
(generic_type (member_type (identifier) @type .))
|
|
67
72
|
(generic_type (identifier) @type)
|
|
68
73
|
(default_type_parameter name: (identifier) @type)
|
|
69
74
|
|
package/src/node-types.json
CHANGED
|
@@ -3066,26 +3066,6 @@
|
|
|
3066
3066
|
"multiple": false,
|
|
3067
3067
|
"required": true,
|
|
3068
3068
|
"types": [
|
|
3069
|
-
{
|
|
3070
|
-
"type": "boolean_operator",
|
|
3071
|
-
"named": true
|
|
3072
|
-
},
|
|
3073
|
-
{
|
|
3074
|
-
"type": "comparison_operator",
|
|
3075
|
-
"named": true
|
|
3076
|
-
},
|
|
3077
|
-
{
|
|
3078
|
-
"type": "conditional_expression",
|
|
3079
|
-
"named": true
|
|
3080
|
-
},
|
|
3081
|
-
{
|
|
3082
|
-
"type": "lambda",
|
|
3083
|
-
"named": true
|
|
3084
|
-
},
|
|
3085
|
-
{
|
|
3086
|
-
"type": "not_operator",
|
|
3087
|
-
"named": true
|
|
3088
|
-
},
|
|
3089
3069
|
{
|
|
3090
3070
|
"type": "primary_expression",
|
|
3091
3071
|
"named": true
|
package/tree-sitter-python.wasm
CHANGED
|
Binary file
|