@willbooster/tree-sitter-python 3.0.0 → 4.1.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(
@@ -730,7 +740,7 @@ module.exports = grammar({
730
740
  prec.left(
731
741
  PREC.compare,
732
742
  seq(
733
- $.primary_expression,
743
+ field('operands', $.primary_expression),
734
744
  repeat1(
735
745
  seq(
736
746
  field(
@@ -749,7 +759,7 @@ module.exports = grammar({
749
759
  alias($._is_not, 'is not')
750
760
  )
751
761
  ),
752
- $.primary_expression
762
+ field('operands', $.primary_expression)
753
763
  )
754
764
  )
755
765
  )
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.1.0",
4
4
  "description": "Python grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -1081,6 +1081,16 @@
1081
1081
  "type": "comparison_operator",
1082
1082
  "named": true,
1083
1083
  "fields": {
1084
+ "operands": {
1085
+ "multiple": true,
1086
+ "required": true,
1087
+ "types": [
1088
+ {
1089
+ "type": "primary_expression",
1090
+ "named": true
1091
+ }
1092
+ ]
1093
+ },
1084
1094
  "operators": {
1085
1095
  "multiple": true,
1086
1096
  "required": true,
@@ -1131,16 +1141,6 @@
1131
1141
  }
1132
1142
  ]
1133
1143
  }
1134
- },
1135
- "children": {
1136
- "multiple": true,
1137
- "required": true,
1138
- "types": [
1139
- {
1140
- "type": "primary_expression",
1141
- "named": true
1142
- }
1143
- ]
1144
1144
  }
1145
1145
  },
1146
1146
  {
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.1.0",
23
23
  "license": "MIT",
24
24
  "description": "Python grammar for tree-sitter",
25
25
  "authors": [