polyglot-piranha 0.3.25__cp310-cp310-manylinux_2_28_x86_64.whl → 0.3.27__cp310-cp310-manylinux_2_28_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.
- polyglot_piranha/__init__.pyi +1 -1
- polyglot_piranha/polyglot_piranha.cpython-310-x86_64-linux-gnu.so +0 -0
- polyglot_piranha-0.3.27.dist-info/METADATA +124 -0
- polyglot_piranha-0.3.27.dist-info/RECORD +9 -0
- {polyglot_piranha-0.3.25.dist-info → polyglot_piranha-0.3.27.dist-info}/WHEEL +1 -1
- polyglot_piranha-0.3.25.dist-info/METADATA +0 -57
- polyglot_piranha-0.3.25.dist-info/RECORD +0 -9
- {polyglot_piranha-0.3.25.dist-info/license_files → polyglot_piranha-0.3.27.dist-info/licenses}/LICENSE +0 -0
- {polyglot_piranha-0.3.25.dist-info/license_files → polyglot_piranha-0.3.27.dist-info/licenses}/NOTICE +0 -0
polyglot_piranha/__init__.pyi
CHANGED
@@ -13,7 +13,7 @@ from __future__ import annotations
|
|
13
13
|
from typing import List, Optional, Literal
|
14
14
|
|
15
15
|
# Languages that Piranha supports (see ./src/models/language.rs)
|
16
|
-
PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "
|
16
|
+
PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "python", "swift", "typescript", "tsx", "thrift", "strings", "scm", "scala", "ruby", "yaml", "yml"]
|
17
17
|
|
18
18
|
|
19
19
|
def execute_piranha(piranha_argument: PiranhaArguments) -> list[PiranhaOutputSummary]:
|
Binary file
|
@@ -0,0 +1,124 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: polyglot_piranha
|
3
|
+
Version: 0.3.27
|
4
|
+
License-File: LICENSE
|
5
|
+
License-File: NOTICE
|
6
|
+
Summary: Polyglot Piranha is a library for performing structural find and replace with deep cleanup.
|
7
|
+
Keywords: refactoring,code update,structural find-replace,structural search and replace,structural search
|
8
|
+
Author: Uber Technologies Inc.
|
9
|
+
License: Apache-2.0
|
10
|
+
Requires-Python: >=3.8
|
11
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
12
|
+
Project-URL: homepage, https://github.com/uber/piranha
|
13
|
+
Project-URL: documentation, https://github.com/uber/piranha
|
14
|
+
Project-URL: repository, https://github.com/uber/piranha
|
15
|
+
|
16
|
+
# PolyglotPiranha
|
17
|
+
|
18
|
+
PolyglotPiranha is a lightweight code transformation toolset for automating large scale changes. At Uber, it is mostly used to clean up stale feature flags.
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
To install Polyglot Piranha, you can use it as a Python library or as a command-line tool.
|
24
|
+
|
25
|
+
### Python API
|
26
|
+
|
27
|
+
To install the Python API, run the following command:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
pip install polyglot-piranha
|
31
|
+
```
|
32
|
+
|
33
|
+
### Command-line Interface
|
34
|
+
|
35
|
+
To install the command-line interface, follow these steps:
|
36
|
+
|
37
|
+
1. Install [Rust](https://www.rust-lang.org/tools/install)
|
38
|
+
2. Clone the repository: `git clone https://github.com/uber/piranha.git`
|
39
|
+
3. Navigate to the cloned directory: `cd piranha`
|
40
|
+
4. Build the project: `cargo build --release` (or `cargo build --release --no-default-features` for macOS)
|
41
|
+
5. The binary will be generated under `target/release`
|
42
|
+
|
43
|
+
## Example Usage
|
44
|
+
|
45
|
+
```python
|
46
|
+
from polyglot_piranha import execute_piranha, PiranhaArguments, Rule, RuleGraph, OutgoingEdges
|
47
|
+
|
48
|
+
# Original code snippet
|
49
|
+
code = """
|
50
|
+
if (obj.isLocEnabled() || x > 0) {
|
51
|
+
// do something
|
52
|
+
} else {
|
53
|
+
// do something else!
|
54
|
+
}
|
55
|
+
"""
|
56
|
+
|
57
|
+
# Define the rule to replace the method call
|
58
|
+
r1 = Rule(
|
59
|
+
name="replace_method",
|
60
|
+
query="cs :[x].isLocEnabled()", # cs indicates we are using concrete syntax
|
61
|
+
replace_node="*",
|
62
|
+
replace="true",
|
63
|
+
is_seed_rule=True
|
64
|
+
)
|
65
|
+
|
66
|
+
# Define the edges for the rule graph.
|
67
|
+
# In this case, boolean_literal_cleanup is already defined for java [see src/cleanup_rules]
|
68
|
+
edge = OutgoingEdges("replace_method", to=["boolean_literal_cleanup"], scope="parent")
|
69
|
+
|
70
|
+
# Create Piranha arguments
|
71
|
+
piranha_arguments = PiranhaArguments(
|
72
|
+
code_snippet=code,
|
73
|
+
language="java",
|
74
|
+
rule_graph=RuleGraph(rules=[r1], edges=[edge])
|
75
|
+
)
|
76
|
+
|
77
|
+
# Execute Piranha and print the transformed code
|
78
|
+
piranha_summary = execute_piranha(piranha_arguments)
|
79
|
+
print(piranha_summary[0].content)
|
80
|
+
```
|
81
|
+
|
82
|
+
|
83
|
+
## Documentation
|
84
|
+
|
85
|
+
For more examples and explanations of the toolset, please check our demos and extended [POLYGLOT_README.md](POLYGLOT_README.md) file.
|
86
|
+
|
87
|
+
|
88
|
+
## Feature Flags
|
89
|
+
|
90
|
+
|
91
|
+
Feature flags are commonly used to enable gradual rollout or experiment with new features. In a few cases, even after the purpose of the flag is accomplished, the code pertaining to the feature flag is not removed. We refer to such flags as stale flags. The presence of code pertaining to stale flags can have the following drawbacks:
|
92
|
+
- Unnecessary code clutter increases the overall complexity w.r.t maintenance resulting in reduced developer productivity
|
93
|
+
- The flags can interfere with other experimental flags (e.g., due to nesting under a flag that is always false)
|
94
|
+
- Presence of unused code in the source as well as the binary
|
95
|
+
- Stale flags can also cause bugs
|
96
|
+
|
97
|
+
PolyglotPiranha is a tool that can automatically refactor code related to stale flags. At a higher level, the input to the tool is the name of the flag and the expected behavior, after specifying a list of APIs related to flags in a properties file. Piranha will use these inputs to automatically refactor the code according to the expected behavior.
|
98
|
+
|
99
|
+
PolyglotPiranha (as of May 2022) is a common refactoring tool to support multiple languages and feature flag APIs.
|
100
|
+
For legacy language-specific implementations please check following [tag](https://github.com/uber/piranha/releases/tag/last-version-having-legacy-piranha).
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
A few additional links on Piranha:
|
105
|
+
|
106
|
+
- Research paper published at [PLDI 2024](https://dl.acm.org/doi/10.1145/3656429) on PolyglotPiranha.
|
107
|
+
- A technical [report](report.pdf) detailing our experiences with using Piranha at Uber.
|
108
|
+
- A [blogpost](https://eng.uber.com/piranha/) presenting more information on Piranha.
|
109
|
+
- 6 minute [video](https://www.youtube.com/watch?v=V5XirDs6LX8&feature=emb_logo) overview of Piranha.
|
110
|
+
|
111
|
+
## Support
|
112
|
+
|
113
|
+
If you have any questions on how to use Piranha or find any bugs, please [open a GitHub issue](https://github.com/uber/piranha/issues).
|
114
|
+
|
115
|
+
## Contributors
|
116
|
+
|
117
|
+
We'd love for you to contribute to Piranha! Please note that once
|
118
|
+
you create a pull request, you will be asked to sign our [Uber Contributor License Agreement](https://cla-assistant.io/uber/piranha).
|
119
|
+
|
120
|
+
We are also looking for contributions to extend Piranha to other languages (C++, C#, Kotlin).
|
121
|
+
|
122
|
+
## License
|
123
|
+
Piranha is licensed under the Apache 2.0 license. See the LICENSE file for more information.
|
124
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
polyglot_piranha-0.3.27.dist-info/METADATA,sha256=xaMhc9-KuRghoxYZ5QXExwaOpFjxi6uYDQ64gdPStrc,4928
|
2
|
+
polyglot_piranha-0.3.27.dist-info/WHEEL,sha256=frJ0jFhrxtt2pGDBONvx9540ZW9xkmTZYKaVKqF4ZeY,108
|
3
|
+
polyglot_piranha-0.3.27.dist-info/licenses/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
4
|
+
polyglot_piranha-0.3.27.dist-info/licenses/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
|
5
|
+
polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
|
6
|
+
polyglot_piranha/__init__.pyi,sha256=RLo1rlEFdaCy_gX_xY59KSLp-WiZ4Ddyg731pimUc2M,10504
|
7
|
+
polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
polyglot_piranha/polyglot_piranha.cpython-310-x86_64-linux-gnu.so,sha256=2w0Ks7UJYWZHDq54NXqhrRvTEW4vUJFKdJO2nnXz2lk,80842512
|
9
|
+
polyglot_piranha-0.3.27.dist-info/RECORD,,
|
@@ -1,57 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.3
|
2
|
-
Name: polyglot_piranha
|
3
|
-
Version: 0.3.25
|
4
|
-
License-File: LICENSE
|
5
|
-
License-File: NOTICE
|
6
|
-
Summary: Polyglot Piranha is a library for performing structural find and replace with deep cleanup.
|
7
|
-
Keywords: refactoring,code update,structural find-replace,structural search and replace,structural search
|
8
|
-
Author: Uber Technologies Inc.
|
9
|
-
License: Apache-2.0
|
10
|
-
Requires-Python: >=3.8
|
11
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
12
|
-
Project-URL: homepage, https://github.com/uber/piranha
|
13
|
-
Project-URL: documentation, https://github.com/uber/piranha
|
14
|
-
Project-URL: repository, https://github.com/uber/piranha
|
15
|
-
|
16
|
-
# Piranha
|
17
|
-
|
18
|
-
[](https://gitter.im/uber/piranha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
19
|
-
|
20
|
-
Feature flags are commonly used to enable gradual rollout or experiment with new features. In a few cases, even after the purpose of the flag is accomplished, the code pertaining to the feature flag is not removed. We refer to such flags as stale flags. The presence of code pertaining to stale flags can have the following drawbacks:
|
21
|
-
- Unnecessary code clutter increases the overall complexity w.r.t maintenance resulting in reduced developer productivity
|
22
|
-
- The flags can interfere with other experimental flags (e.g., due to nesting under a flag that is always false)
|
23
|
-
- Presence of unused code in the source as well as the binary
|
24
|
-
- Stale flags can also cause bugs
|
25
|
-
|
26
|
-
Piranha is a tool to automatically refactor code related to stale flags. At a higher level, the input to the tool is the name of the flag and the expected behavior, after specifying a list of APIs related to flags in a properties file. Piranha will use these inputs to automatically refactor the code according to the expected behavior.
|
27
|
-
|
28
|
-
This repository contains four independent versions of Piranha, one for each of the four supported languages: Java, JavaScript, Objective-C and Swift. **It also contains a redesigned variant of Piranha (as of May 2022) that is a common refactoring tool to support multiple languages and feature flag APIs. If interested in this polyglot variant, goto [Polyglot Piranha](POLYGLOT_README.md)**.
|
29
|
-
|
30
|
-
To use/build each version, look under the corresponding [lang]/ directory and follow instructions in the corresponding [lang]/README.md file. Make sure to cd into that directory to build any related code following the instructions in the README.
|
31
|
-
|
32
|
-
- [PiranhaJava](legacy/java/README.md)
|
33
|
-
- [PiranhaJS](legacy/javascript/README.md)
|
34
|
-
- [PiranhaObjC](legacy/objc/README.md)
|
35
|
-
- [PiranhaSwift](legacy/swift/README.md)
|
36
|
-
|
37
|
-
A few additional links on Piranha:
|
38
|
-
|
39
|
-
- Research paper published at [PLDI 2024](https://dl.acm.org/doi/10.1145/3656429) on PolyglotPiranha.
|
40
|
-
- A technical [report](report.pdf) detailing our experiences with using Piranha at Uber.
|
41
|
-
- A [blogpost](https://eng.uber.com/piranha/) presenting more information on Piranha.
|
42
|
-
- 6 minute [video](https://www.youtube.com/watch?v=V5XirDs6LX8&feature=emb_logo) overview of Piranha.
|
43
|
-
|
44
|
-
## Support
|
45
|
-
|
46
|
-
If you have any questions on how to use Piranha, please feel free to reach out to us on the [gitter channel](https://gitter.im/uber/piranha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge). For bugs and enhancement requests, [open a GitHub issue](https://github.com/uber/piranha/issues).
|
47
|
-
|
48
|
-
## Contributors
|
49
|
-
|
50
|
-
We'd love for you to contribute to Piranha! Please note that once
|
51
|
-
you create a pull request, you will be asked to sign our [Uber Contributor License Agreement](https://cla-assistant.io/uber/piranha).
|
52
|
-
|
53
|
-
We are also looking for contributions to extend Piranha to other languages (C++, C#, Kotlin).
|
54
|
-
|
55
|
-
## License
|
56
|
-
Piranha is licensed under the Apache 2.0 license. See the LICENSE file for more information.
|
57
|
-
|
@@ -1,9 +0,0 @@
|
|
1
|
-
polyglot_piranha-0.3.25.dist-info/METADATA,sha256=sPaY71g745SmD4LbGrHOlb1ngGLtpjN7LfsrQtBYcIc,3820
|
2
|
-
polyglot_piranha-0.3.25.dist-info/WHEEL,sha256=o2a7w7pwJaHwz9eJC7NBuokOzmoVNgOcn76t9UzkJbA,108
|
3
|
-
polyglot_piranha-0.3.25.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
4
|
-
polyglot_piranha-0.3.25.dist-info/license_files/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
|
5
|
-
polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
|
6
|
-
polyglot_piranha/__init__.pyi,sha256=NCT9ACz8M9CJqQGEisGT5AybulsHfl-_z_I-QQ6iMQw,10475
|
7
|
-
polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
polyglot_piranha/polyglot_piranha.cpython-310-x86_64-linux-gnu.so,sha256=I6ykl2-eSXIN_-gAPctPjSDlBBsqft-C_JMjDdnK-jg,80646024
|
9
|
-
polyglot_piranha-0.3.25.dist-info/RECORD,,
|
File without changes
|
File without changes
|