ry-cli 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {ry_cli-0.2.0 → ry_cli-0.3.0}/CHANGELOG.md +7 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/Cargo.lock +1 -1
- {ry_cli-0.2.0 → ry_cli-0.3.0}/Cargo.toml +1 -1
- {ry_cli-0.2.0 → ry_cli-0.3.0}/PKG-INFO +7 -1
- {ry_cli-0.2.0 → ry_cli-0.3.0}/README.md +6 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/config.rs +12 -18
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/lib.rs +2 -1
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/packages.rs +23 -23
- {ry_cli-0.2.0 → ry_cli-0.3.0}/.github/logo.png +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/.github/workflows/publish-python.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/.github/workflows/release-please.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/.gitignore +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/LICENSE +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/pyproject.toml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/diagnostics.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/generation.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/inline.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/main.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/module.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/src/treesitter.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures/basic_async_to_sync/expected.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures/basic_async_to_sync/input.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures/basic_async_to_sync/ry.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures/tag_rules/expected.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures/tag_rules/input.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures/tag_rules/ry.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.3.0}/tests/fixtures.rs +0 -0
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/karpetrosyan/ry/compare/v0.2.0...v0.3.0) (2026-04-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* make rule's id optional ([7c2d7a5](https://github.com/karpetrosyan/ry/commit/7c2d7a54cae7dbf810383127c0262e08bc648b0f))
|
|
9
|
+
|
|
3
10
|
## [0.2.0](https://github.com/karpetrosyan/ry/compare/v0.1.0...v0.2.0) (2026-04-09)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ry-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Classifier: Development Status :: 4 - Beta
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -30,6 +30,12 @@ Ry transforms the Python code using regex rules. Originally built to simplify ma
|
|
|
30
30
|
|
|
31
31
|
Comes with a package system where you can define reusable sets of rules. Have a built-in `std` package with all standard rules (like `async def` to `def`, etc), and you can create your own packages for your specific transformations.
|
|
32
32
|
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install ry-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
33
39
|
## Inline Transformations
|
|
34
40
|
|
|
35
41
|
Ry can transform not only whole files, but also specific lines or blocks of code based on inline comments.
|
|
@@ -10,6 +10,12 @@ Ry transforms the Python code using regex rules. Originally built to simplify ma
|
|
|
10
10
|
|
|
11
11
|
Comes with a package system where you can define reusable sets of rules. Have a built-in `std` package with all standard rules (like `async def` to `def`, etc), and you can create your own packages for your specific transformations.
|
|
12
12
|
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install ry-cli
|
|
17
|
+
```
|
|
18
|
+
|
|
13
19
|
## Inline Transformations
|
|
14
20
|
|
|
15
21
|
Ry can transform not only whole files, but also specific lines or blocks of code based on inline comments.
|
|
@@ -34,7 +34,8 @@ pub struct Package {
|
|
|
34
34
|
|
|
35
35
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
36
36
|
pub struct Rule {
|
|
37
|
-
|
|
37
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
38
|
+
pub id: Option<String>,
|
|
38
39
|
pub kind: RuleKind,
|
|
39
40
|
#[serde(rename = "match")]
|
|
40
41
|
pub match_pattern: String,
|
|
@@ -88,10 +89,9 @@ impl Config {
|
|
|
88
89
|
|
|
89
90
|
pub fn get_effective_rules_from_defaults(&self) -> Vec<Rule> {
|
|
90
91
|
let mut rules = Vec::new();
|
|
91
|
-
let mut seen_ids = HashMap::new();
|
|
92
92
|
|
|
93
93
|
for package_ref in &self.defaults.include {
|
|
94
|
-
self.add_package_rules(&mut rules,
|
|
94
|
+
self.add_package_rules(&mut rules, package_ref);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
rules
|
|
@@ -99,40 +99,34 @@ impl Config {
|
|
|
99
99
|
|
|
100
100
|
pub fn get_effective_rules(&self, target: &Target) -> Vec<Rule> {
|
|
101
101
|
let mut rules = Vec::new();
|
|
102
|
-
let mut seen_ids = HashMap::new();
|
|
103
102
|
|
|
104
103
|
if target.inherit_defaults {
|
|
105
104
|
for package_ref in &self.defaults.include {
|
|
106
|
-
self.add_package_rules(&mut rules,
|
|
105
|
+
self.add_package_rules(&mut rules, package_ref);
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
for package_ref in &target.include {
|
|
111
|
-
self.add_package_rules(&mut rules,
|
|
110
|
+
self.add_package_rules(&mut rules, package_ref);
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
for rule in &target.rules {
|
|
115
|
-
|
|
116
|
-
seen_ids.insert(rule.id.clone(), rules.len());
|
|
117
|
-
rules.push(rule.clone());
|
|
118
|
-
}
|
|
114
|
+
rules.push(rule.clone());
|
|
119
115
|
}
|
|
120
116
|
|
|
121
117
|
rules
|
|
122
118
|
}
|
|
123
119
|
|
|
124
|
-
fn add_package_rules(
|
|
125
|
-
&self,
|
|
126
|
-
rules: &mut Vec<Rule>,
|
|
127
|
-
seen_ids: &mut HashMap<String, usize>,
|
|
128
|
-
package_ref: &PackageRef,
|
|
129
|
-
) {
|
|
120
|
+
fn add_package_rules(&self, rules: &mut Vec<Rule>, package_ref: &PackageRef) {
|
|
130
121
|
let package = crate::packages::get_package(&package_ref.package, &self.packages);
|
|
131
122
|
|
|
132
123
|
if let Some(pkg) = package {
|
|
133
124
|
for rule in &pkg.rules {
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
let should_exclude = rule
|
|
126
|
+
.id
|
|
127
|
+
.as_ref()
|
|
128
|
+
.map_or(false, |id| package_ref.exclude.contains(id));
|
|
129
|
+
if !should_exclude {
|
|
136
130
|
rules.push(rule.clone());
|
|
137
131
|
}
|
|
138
132
|
}
|
|
@@ -13,139 +13,139 @@ fn create_std_package() -> Package {
|
|
|
13
13
|
Package {
|
|
14
14
|
rules: vec![
|
|
15
15
|
Rule {
|
|
16
|
-
id: "async-def".to_string(),
|
|
16
|
+
id: Some("async-def".to_string()),
|
|
17
17
|
kind: RuleKind::Regex,
|
|
18
18
|
match_pattern: r"\basync\s+def\b".to_string(),
|
|
19
19
|
replace: "def".to_string(),
|
|
20
20
|
},
|
|
21
21
|
Rule {
|
|
22
|
-
id: "async-with".to_string(),
|
|
22
|
+
id: Some("async-with".to_string()),
|
|
23
23
|
kind: RuleKind::Regex,
|
|
24
24
|
match_pattern: r"\basync\s+with\b".to_string(),
|
|
25
25
|
replace: "with".to_string(),
|
|
26
26
|
},
|
|
27
27
|
Rule {
|
|
28
|
-
id: "async-for".to_string(),
|
|
28
|
+
id: Some("async-for".to_string()),
|
|
29
29
|
kind: RuleKind::Regex,
|
|
30
30
|
match_pattern: r"\basync\s+for\b".to_string(),
|
|
31
31
|
replace: "for".to_string(),
|
|
32
32
|
},
|
|
33
33
|
Rule {
|
|
34
|
-
id: "strip-await".to_string(),
|
|
34
|
+
id: Some("strip-await".to_string()),
|
|
35
35
|
kind: RuleKind::Regex,
|
|
36
36
|
match_pattern: r"\bawait\s+".to_string(),
|
|
37
37
|
replace: "".to_string(),
|
|
38
38
|
},
|
|
39
39
|
Rule {
|
|
40
|
-
id: "dunder-anext".to_string(),
|
|
40
|
+
id: Some("dunder-anext".to_string()),
|
|
41
41
|
kind: RuleKind::Regex,
|
|
42
42
|
match_pattern: r"\b__anext__\b".to_string(),
|
|
43
43
|
replace: "__next__".to_string(),
|
|
44
44
|
},
|
|
45
45
|
Rule {
|
|
46
|
-
id: "dunder-aenter".to_string(),
|
|
46
|
+
id: Some("dunder-aenter".to_string()),
|
|
47
47
|
kind: RuleKind::Regex,
|
|
48
48
|
match_pattern: r"\b__aenter__\b".to_string(),
|
|
49
49
|
replace: "__enter__".to_string(),
|
|
50
50
|
},
|
|
51
51
|
Rule {
|
|
52
|
-
id: "dunder-aexit".to_string(),
|
|
52
|
+
id: Some("dunder-aexit".to_string()),
|
|
53
53
|
kind: RuleKind::Regex,
|
|
54
54
|
match_pattern: r"\b__aexit__\b".to_string(),
|
|
55
55
|
replace: "__exit__".to_string(),
|
|
56
56
|
},
|
|
57
57
|
Rule {
|
|
58
|
-
id: "dunder-aiter".to_string(),
|
|
58
|
+
id: Some("dunder-aiter".to_string()),
|
|
59
59
|
kind: RuleKind::Regex,
|
|
60
60
|
match_pattern: r"\b__aiter__\b".to_string(),
|
|
61
61
|
replace: "__iter__".to_string(),
|
|
62
62
|
},
|
|
63
63
|
Rule {
|
|
64
|
-
id: "aiter".to_string(),
|
|
64
|
+
id: Some("aiter".to_string()),
|
|
65
65
|
kind: RuleKind::Regex,
|
|
66
66
|
match_pattern: r"\baiter\b".to_string(),
|
|
67
67
|
replace: "iter".to_string(),
|
|
68
68
|
},
|
|
69
69
|
Rule {
|
|
70
|
-
id: "async-iterator".to_string(),
|
|
70
|
+
id: Some("async-iterator".to_string()),
|
|
71
71
|
kind: RuleKind::Regex,
|
|
72
72
|
match_pattern: r"\bAsyncIterator\b".to_string(),
|
|
73
73
|
replace: "Iterator".to_string(),
|
|
74
74
|
},
|
|
75
75
|
Rule {
|
|
76
|
-
id: "asynccontextmanager".to_string(),
|
|
76
|
+
id: Some("asynccontextmanager".to_string()),
|
|
77
77
|
kind: RuleKind::Regex,
|
|
78
78
|
match_pattern: r"\basynccontextmanager\b".to_string(),
|
|
79
79
|
replace: "contextmanager".to_string(),
|
|
80
80
|
},
|
|
81
81
|
Rule {
|
|
82
|
-
id: "abstract-async-context-manager".to_string(),
|
|
82
|
+
id: Some("abstract-async-context-manager".to_string()),
|
|
83
83
|
kind: RuleKind::Regex,
|
|
84
84
|
match_pattern: r"\bAbstractAsyncContextManager\b".to_string(),
|
|
85
85
|
replace: "AbstractContextManager".to_string(),
|
|
86
86
|
},
|
|
87
87
|
Rule {
|
|
88
|
-
id: "from-asyncio-sleep".to_string(),
|
|
88
|
+
id: Some("from-asyncio-sleep".to_string()),
|
|
89
89
|
kind: RuleKind::Regex,
|
|
90
90
|
match_pattern: r"from asyncio import sleep".to_string(),
|
|
91
91
|
replace: "from time import sleep".to_string(),
|
|
92
92
|
},
|
|
93
93
|
Rule {
|
|
94
|
-
id: "from-asyncio-condition".to_string(),
|
|
94
|
+
id: Some("from-asyncio-condition".to_string()),
|
|
95
95
|
kind: RuleKind::Regex,
|
|
96
96
|
match_pattern: r"from asyncio import Condition".to_string(),
|
|
97
97
|
replace: "from threading import Condition".to_string(),
|
|
98
98
|
},
|
|
99
99
|
Rule {
|
|
100
|
-
id: "from-asyncio-semaphore".to_string(),
|
|
100
|
+
id: Some("from-asyncio-semaphore".to_string()),
|
|
101
101
|
kind: RuleKind::Regex,
|
|
102
102
|
match_pattern: r"from asyncio import Semaphore".to_string(),
|
|
103
103
|
replace: "from threading import Semaphore".to_string(),
|
|
104
104
|
},
|
|
105
105
|
Rule {
|
|
106
|
-
id: "from-asyncio-lock".to_string(),
|
|
106
|
+
id: Some("from-asyncio-lock".to_string()),
|
|
107
107
|
kind: RuleKind::Regex,
|
|
108
108
|
match_pattern: r"from asyncio import Lock".to_string(),
|
|
109
109
|
replace: "from threading import Lock".to_string(),
|
|
110
110
|
},
|
|
111
111
|
Rule {
|
|
112
|
-
id: "import-asyncio-to-threading".to_string(),
|
|
112
|
+
id: Some("import-asyncio-to-threading".to_string()),
|
|
113
113
|
kind: RuleKind::Regex,
|
|
114
114
|
match_pattern: r"import asyncio".to_string(),
|
|
115
115
|
replace: "import threading".to_string(),
|
|
116
116
|
},
|
|
117
117
|
Rule {
|
|
118
|
-
id: "asyncio-condition".to_string(),
|
|
118
|
+
id: Some("asyncio-condition".to_string()),
|
|
119
119
|
kind: RuleKind::Regex,
|
|
120
120
|
match_pattern: r"asyncio\.Condition".to_string(),
|
|
121
121
|
replace: "threading.Condition".to_string(),
|
|
122
122
|
},
|
|
123
123
|
Rule {
|
|
124
|
-
id: "asyncio-lock".to_string(),
|
|
124
|
+
id: Some("asyncio-lock".to_string()),
|
|
125
125
|
kind: RuleKind::Regex,
|
|
126
126
|
match_pattern: r"asyncio\.Lock".to_string(),
|
|
127
127
|
replace: "threading.Lock".to_string(),
|
|
128
128
|
},
|
|
129
129
|
Rule {
|
|
130
|
-
id: "asyncio-semaphore".to_string(),
|
|
130
|
+
id: Some("asyncio-semaphore".to_string()),
|
|
131
131
|
kind: RuleKind::Regex,
|
|
132
132
|
match_pattern: r"asyncio\.Semaphore".to_string(),
|
|
133
133
|
replace: "threading.Semaphore".to_string(),
|
|
134
134
|
},
|
|
135
135
|
Rule {
|
|
136
|
-
id: "asyncio-timeout-error".to_string(),
|
|
136
|
+
id: Some("asyncio-timeout-error".to_string()),
|
|
137
137
|
kind: RuleKind::Regex,
|
|
138
138
|
match_pattern: r"asyncio\.TimeoutError".to_string(),
|
|
139
139
|
replace: "TimeoutError".to_string(),
|
|
140
140
|
},
|
|
141
141
|
Rule {
|
|
142
|
-
id: "pytest-mark-asyncio".to_string(),
|
|
142
|
+
id: Some("pytest-mark-asyncio".to_string()),
|
|
143
143
|
kind: RuleKind::Regex,
|
|
144
144
|
match_pattern: r"@pytest\.mark\.asyncio".to_string(),
|
|
145
145
|
replace: "".to_string(),
|
|
146
146
|
},
|
|
147
147
|
Rule {
|
|
148
|
-
id: "stop-async-iteration".to_string(),
|
|
148
|
+
id: Some("stop-async-iteration".to_string()),
|
|
149
149
|
kind: RuleKind::Regex,
|
|
150
150
|
match_pattern: r"\bStopAsyncIteration\b".to_string(),
|
|
151
151
|
replace: "StopIteration".to_string(),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|