polyglot-piranha 0.3.1__cp38-cp38-macosx_10_16_x86_64.whl → 0.3.4__cp38-cp38-macosx_10_16_x86_64.whl

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.
@@ -9,7 +9,7 @@
9
9
  # express or implied. See the License for the specific language governing permissions and
10
10
  # limitations under the License.
11
11
 
12
- from typing import Optional
12
+ from typing import List, Optional
13
13
 
14
14
 
15
15
  def execute_piranha(piranha_argument: PiranhaArguments) -> list[PiranhaOutputSummary]:
@@ -33,20 +33,22 @@ class PiranhaArguments:
33
33
  def __init__(
34
34
  self,
35
35
  language: str,
36
- substitutions: dict,
37
- path_to_configurations: Optional[str],
38
- rule_graph: Optional[RuleGraph]= None,
39
36
  path_to_codebase: Optional[str] = None,
37
+ include: Optional[List[str]] = None,
38
+ exclude: Optional[List[str]] = None,
39
+ substitutions: Optional[dict] = None,
40
+ path_to_configurations: Optional[str] = None,
41
+ rule_graph: Optional[RuleGraph]= None,
40
42
  code_snippet: Optional[str] = None,
41
43
  dry_run: Optional[bool] = None,
42
44
  cleanup_comments: Optional[bool] = None,
43
45
  cleanup_comments_buffer: Optional[int] = None,
44
46
  number_of_ancestors_in_parent_scope: Optional[int] = None,
45
- delete_consecutive_new_lines : Optional[bool] = None,
47
+ delete_consecutive_new_lines: Optional[bool] = None,
46
48
  global_tag_prefix: Optional[str] = 'GLOBAL_TAG',
47
- delete_file_if_empty : Optional[bool] = None,
49
+ delete_file_if_empty: Optional[bool] = None,
48
50
  path_to_output: Optional[str] = None,
49
- allow_dirty_ast : Optional[bool] = None
51
+ allow_dirty_ast: Optional[bool] = None
50
52
  ):
51
53
  """
52
54
  Constructs `PiranhaArguments`
@@ -55,22 +57,22 @@ class PiranhaArguments:
55
57
  ------------
56
58
  language: str
57
59
  the target language
58
- substitutions: dict
59
- Substitutions to instantiate the initial set of rules
60
+ path_to_codebase: str
61
+ Path to source code folder or file
60
62
  keyword arguments: _
61
- path_to_configurations (str) : Directory containing the configuration files - `piranha_arguments.toml`, `rules.toml`, and `edges.toml`
62
- rule_graph (RuleGraph) : The rule graph constructed via RuleGraph DSL
63
- path_to_codebase (str) : Path to source code folder or file
64
- code_snippet (str) : The input code snippet to transform
65
- dry_run (bool) : Disables in-place rewriting of code
66
- cleanup_comments (bool) : Enables deletion of associated comments
63
+ substitutions (dict): Substitutions to instantiate the initial set of rules
64
+ path_to_configurations (str): Directory containing the configuration files - `piranha_arguments.toml`, `rules.toml`, and `edges.toml`
65
+ rule_graph (RuleGraph): The rule graph constructed via RuleGraph DSL
66
+ code_snippet (str): The input code snippet to transform
67
+ dry_run (bool): Disables in-place rewriting of code
68
+ cleanup_comments (bool): Enables deletion of associated comments
67
69
  cleanup_comments_buffer (int): The number of lines to consider for cleaning up the comments
68
70
  number_of_ancestors_in_parent_scope (int): The number of ancestors considered when PARENT rules
69
- delete_consecutive_new_lines (bool) : Replaces consecutive \ns with a \n
71
+ delete_consecutive_new_lines (bool): Replaces consecutive \ns with a \n
70
72
  global_tag_prefix (str): the prefix for global tags
71
73
  delete_file_if_empty (bool): User option that determines whether an empty file will be deleted
72
74
  path_to_output (str): Path to the output json file
73
- allow_dirty_ast (bool) : Allows syntax errors in the input source code
75
+ allow_dirty_ast (bool): Allows syntax errors in the input source code
74
76
  """
75
77
  ...
76
78
 
@@ -80,9 +82,9 @@ class PiranhaOutputSummary:
80
82
 
81
83
  Attributes
82
84
  ----------
83
- path : path to the file
84
- content : content of the file after all the rewrites
85
- matches : All the occurrences of "match-only" rules
85
+ path: path to the file
86
+ content: content of the file after all the rewrites
87
+ matches: All the occurrences of "match-only" rules
86
88
  rewrites: All the applied edits
87
89
  """
88
90
 
@@ -107,9 +109,9 @@ class Edit:
107
109
 
108
110
  Attributes
109
111
  ----------
110
- p_match : The match representing the target site of the edit
111
- replacement_string : The string to replace the substring encompassed by the match
112
- matched_rule : The rule used for creating this match-replace
112
+ p_match: The match representing the target site of the edit
113
+ replacement_string: The string to replace the substring encompassed by the match
114
+ matched_rule: The rule used for creating this match-replace
113
115
  """
114
116
 
115
117
  p_match: Match
@@ -127,9 +129,9 @@ class Match:
127
129
 
128
130
  Attributes
129
131
  ----------
130
- matched_sting : Code snippet that matched
131
- range : Range of the entire AST node captured by the match
132
- matches : The mapping between tags and string representation of the AST captured
132
+ matched_sting: Code snippet that matched
133
+ range: Range of the entire AST node captured by the match
134
+ matches: The mapping between tags and string representation of the AST captured
133
135
  """
134
136
 
135
137
  matched_string: str
@@ -156,28 +158,37 @@ class Point:
156
158
  row: int
157
159
  column: int
158
160
 
159
- class Constraint:
160
- """ A class to capture Constraints of a Piranha Rule
161
+ class Filter:
162
+ """ A class to capture filters of a Piranha Rule
161
163
  """
162
- matcher: TSQuery
163
- "Scope in which the constraint query has to be applied"
164
- queries: list[TSQuery]
165
- "The Tree-sitter queries that need to be applied in the `matcher` scope"
166
-
164
+ enclosing_node: TSQuery
165
+ "AST patterns that some ancestor node of the primary match should comply"
166
+ not_contains: list[TSQuery]
167
+ "AST patterns that SHOULD NOT match any subtree of node matching `enclosing_node` pattern"
168
+ contains: TSQuery
169
+ "AST pattern that SHOULD match subtrees of `enclosing_node`. " \
170
+ "Number of matches should be within the range of `at_least` and `at_most`."
171
+ at_least: int
172
+ "The minimum number of times the contains query should match in the enclosing node"
173
+ at_most: int
174
+ "The maximum number of times the contains query should match in the enclosing node"
167
175
  def __init__(
168
176
  self,
169
- matcher: str,
170
- queries: list[str] = []
177
+ enclosing_node: str = '',
178
+ not_contains: list[str] = [],
179
+ contains: str = '',
180
+ at_least: int = 1,
181
+ at_most: int = 4294967295 # u32::MAX
171
182
  ):
172
183
  """
173
- Constructs `Constraint`
184
+ Constructs `Filter`
174
185
 
175
186
  Parameters
176
187
  ------------
177
- matcher: str
178
- Scope in which the constraint query has to be applied
179
- queries: list[str]
180
- The Tree-sitter queries that need to be applied in the `matcher` scope
188
+ enclosing_node: str
189
+ AST patterns that some ancestor node of the primary match should comply
190
+ not_contains: list[str]
191
+ AST patterns that should not match any subtree of node matching `enclosing_node` pattern
181
192
  """
182
193
  ...
183
194
 
@@ -196,8 +207,8 @@ class Rule:
196
207
  "Group(s) to which the rule belongs"
197
208
  holes: set[str]
198
209
  "Holes that need to be filled, in order to instantiate a rule"
199
- constraints: set[Constraint]
200
- "Additional constraints for matching the rule"
210
+ filters: set[Filter]
211
+ "Filters to test before applying a rule"
201
212
 
202
213
  def __init__(
203
214
  self,
@@ -207,7 +218,7 @@ class Rule:
207
218
  replace: Optional[str] = None,
208
219
  groups: set[str] = set(),
209
220
  holes: set[str] = set(),
210
- constraints: set[Constraint] = set(),
221
+ filters: set[Filter] = set(),
211
222
  is_seed_rule: bool = True,
212
223
  ):
213
224
  """
@@ -227,8 +238,8 @@ class Rule:
227
238
  Group(s) to which the rule belongs
228
239
  holes: set[str]
229
240
  Holes that need to be filled, in order to instantiate a rule
230
- constraints: set[Constraint]
231
- Additional constraints for matching the rule
241
+ filters: set[Filter]
242
+ Filters to test before applying a rule
232
243
  """
233
244
  ...
234
245
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyglot_piranha
3
- Version: 0.3.1
3
+ Version: 0.3.4
4
4
  License-File: LICENSE
5
5
  License-File: LICENSE
6
6
  License-File: NOTICE
@@ -10,8 +10,8 @@ Author: Uber Technologies Inc.
10
10
  Author-email: Ameya Ketkar <ketkara@uber.com>, Lazaro Clapp <lazaro@uber.com>
11
11
  Requires-Python: >=3.7
12
12
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
13
- Project-URL: documentation, https://github.com/uber/piranha
14
13
  Project-URL: homepage, https://github.com/uber/piranha
14
+ Project-URL: documentation, https://github.com/uber/piranha
15
15
  Project-URL: repository, https://github.com/uber/piranha
16
16
 
17
17
  # Piranha
@@ -0,0 +1,10 @@
1
+ polyglot_piranha-0.3.4.dist-info/METADATA,sha256=0ibaLIqcy7Fg1mUV_0ZWFWjxyo7RlwQlizMsNYbVuWQ,3797
2
+ polyglot_piranha-0.3.4.dist-info/WHEEL,sha256=nqll5ynhXCwomcBqYs3lJrWlr8aFscLjrHGA10xvryk,104
3
+ polyglot_piranha-0.3.4.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
4
+ polyglot_piranha-0.3.4.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
5
+ polyglot_piranha-0.3.4.dist-info/license_files/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
6
+ polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
7
+ polyglot_piranha/__init__.pyi,sha256=sDMJC2xnL0QPNkBARAljzgwu7D-hbccyC-79r9p0djw,9476
8
+ polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ polyglot_piranha/polyglot_piranha.cpython-38-darwin.so,sha256=g3_ubd4UZmfKn-KhCHag4BEj2_bLifMXzQUF7eHnPSA,13625120
10
+ polyglot_piranha-0.3.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (0.14.17)
2
+ Generator: maturin (1.0.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp38-cp38-macosx_10_16_x86_64
@@ -1,10 +0,0 @@
1
- polyglot_piranha-0.3.1.dist-info/METADATA,sha256=4XSMvtH-SWVKfukRmCpRc0e-K1byMmtvkBLNunuJAfo,3797
2
- polyglot_piranha-0.3.1.dist-info/WHEEL,sha256=gK6oiPSZu9RysAhjHNGqeWIPqzTu4cdcD8ShqLYXjts,106
3
- polyglot_piranha-0.3.1.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
4
- polyglot_piranha-0.3.1.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
5
- polyglot_piranha-0.3.1.dist-info/license_files/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
6
- polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
7
- polyglot_piranha/__init__.pyi,sha256=rPD4hqxQP6gIRn0iQz-UJfftbZYrRiyXvxHSHktWc2s,8830
8
- polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- polyglot_piranha/polyglot_piranha.cpython-38-darwin.so,sha256=NrmjqX6MzgidWPl-44hvKpe35L_V-e3m31pqYaAFbC4,13228728
10
- polyglot_piranha-0.3.1.dist-info/RECORD,,