@willbooster/tree-sitter-python 3.0.0 → 4.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 CHANGED
@@ -63,7 +63,7 @@ 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.
66
+ Qualified generic bases use `member_type` inside `generic_type`. Plain qualified generic arguments also expose `member_type` inside their `type` operand, so queries can capture the terminal type name while excluding its module qualifiers. 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
67
 
68
68
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-python) and on
69
69
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
@@ -72,7 +72,7 @@ fuzzed with. The parser requires runtime 2.x:
72
72
  ```toml
73
73
  [dependencies]
74
74
  tree-sitter = { package = "willbooster-tree-sitter", version = "2" }
75
- tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "3" }
75
+ tree-sitter-python = { package = "willbooster-tree-sitter-python", version = "4" }
76
76
  ```
77
77
 
78
78
  ```rust
package/grammar.js CHANGED
@@ -46,6 +46,9 @@ module.exports = grammar({
46
46
  [$.default_type_parameter, $.primary_expression],
47
47
  [$.primary_expression, $._default_type_primary],
48
48
  [$.primary_expression, $._default_generic_type],
49
+ [$._default_generic_type, $.primary_expression, $.generic_type],
50
+ [$._default_type_arguments, $.expression],
51
+ [$._default_type_arguments, $._generic_type_arguments],
49
52
  [$.primary_expression, $._default_member_type],
50
53
  [$.list, $._default_type_list],
51
54
  [$._type_parameter_expression, $.expression],
@@ -494,7 +497,14 @@ module.exports = grammar({
494
497
  _default_splat_type: ($) => seq('*', choice($.primary_expression, prec.dynamic(1, alias($._default_type, $.type)))),
495
498
 
496
499
  _generic_type_arguments: ($) =>
497
- seq('[', commaSep1(choice($.type, alias($._default_splat_argument, $.splat_type))), optional(','), ']'),
500
+ seq(
501
+ '[',
502
+ commaSep1(
503
+ choice($.type, alias($._type_parameter_expression, $.type), alias($._default_splat_argument, $.splat_type))
504
+ ),
505
+ optional(','),
506
+ ']'
507
+ ),
498
508
 
499
509
  argument_list: ($) =>
500
510
  seq(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-python",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Python grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "3.0.0",
22
+ "version": "4.0.0",
23
23
  "license": "MIT",
24
24
  "description": "Python grammar for tree-sitter",
25
25
  "authors": [