ry-cli 0.2.0__tar.gz → 0.4.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.4.0/CHANGELOG.md +34 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/Cargo.lock +8 -1
- {ry_cli-0.2.0 → ry_cli-0.4.0}/Cargo.toml +2 -1
- {ry_cli-0.2.0 → ry_cli-0.4.0}/PKG-INFO +7 -1
- {ry_cli-0.2.0 → ry_cli-0.4.0}/README.md +6 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/config.rs +19 -18
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/diagnostics.rs +1 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/inline.rs +1 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/lib.rs +2 -1
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/main.rs +38 -2
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/packages.rs +23 -23
- ry_cli-0.4.0/tests/fixtures/basic_async_to_sync/output.txt +2 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/expected.py +7 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/input.py +7 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/output.txt +8 -0
- ry_cli-0.4.0/tests/fixtures/outdated_generated_code/ry.yml +8 -0
- ry_cli-0.4.0/tests/fixtures/tag_rules/output.txt +2 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures.rs +37 -0
- ry_cli-0.4.0/uv.lock +7 -0
- ry_cli-0.2.0/CHANGELOG.md +0 -20
- {ry_cli-0.2.0 → ry_cli-0.4.0}/.github/logo.png +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/.github/workflows/publish-python.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/.github/workflows/release-please.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/.gitignore +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/LICENSE +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/pyproject.toml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/generation.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/module.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/src/treesitter.rs +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/expected.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/input.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/ry.yml +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/expected.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/input.py +0 -0
- {ry_cli-0.2.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/ry.yml +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.4.0](https://github.com/karpetrosyan/ry/compare/v0.2.0...v0.4.0) (2026-04-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* make rule's id optional ([7c2d7a5](https://github.com/karpetrosyan/ry/commit/7c2d7a54cae7dbf810383127c0262e08bc648b0f))
|
|
9
|
+
* make rule's kind optional, default to regex ([920565f](https://github.com/karpetrosyan/ry/commit/920565feef93590c4dc7a9154172ae69d39a4876))
|
|
10
|
+
* show diff with expected sync code in verbose mode ([622e95d](https://github.com/karpetrosyan/ry/commit/622e95d94e4822a9f40cf467bb40e371d8513b3e))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Miscellaneous Chores
|
|
14
|
+
|
|
15
|
+
* release 0.4.0 ([35887e3](https://github.com/karpetrosyan/ry/commit/35887e3442e9040275a9c976e16a5228dacf4482))
|
|
16
|
+
|
|
17
|
+
## [0.2.0](https://github.com/karpetrosyan/ry/compare/v0.1.0...v0.2.0) (2026-04-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add support for passing multiple PATHs ([27f91f7](https://github.com/karpetrosyan/ry/commit/27f91f7a5b5db7b6bb803a6e896fe09c96456f36))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* remove redundant generation file ([fe9dbc4](https://github.com/karpetrosyan/ry/commit/fe9dbc4a66392c96019799746c09bd0992dd4d53))
|
|
28
|
+
|
|
29
|
+
## 0.1.0 (2026-04-08)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* first release ([e1aed91](https://github.com/karpetrosyan/ry/commit/e1aed91f6370bb3832b72be8164c4591e456d0da))
|
|
@@ -375,7 +375,7 @@ dependencies = [
|
|
|
375
375
|
|
|
376
376
|
[[package]]
|
|
377
377
|
name = "ry"
|
|
378
|
-
version = "0.
|
|
378
|
+
version = "0.4.0"
|
|
379
379
|
dependencies = [
|
|
380
380
|
"clap",
|
|
381
381
|
"glob",
|
|
@@ -383,6 +383,7 @@ dependencies = [
|
|
|
383
383
|
"regex",
|
|
384
384
|
"serde",
|
|
385
385
|
"serde_yaml",
|
|
386
|
+
"similar",
|
|
386
387
|
"tempfile",
|
|
387
388
|
"tree-sitter",
|
|
388
389
|
"tree-sitter-python",
|
|
@@ -462,6 +463,12 @@ version = "1.3.0"
|
|
|
462
463
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
463
464
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
464
465
|
|
|
466
|
+
[[package]]
|
|
467
|
+
name = "similar"
|
|
468
|
+
version = "2.7.0"
|
|
469
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
470
|
+
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
|
|
471
|
+
|
|
465
472
|
[[package]]
|
|
466
473
|
name = "streaming-iterator"
|
|
467
474
|
version = "0.1.9"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ry"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
|
|
@@ -16,6 +16,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|
|
16
16
|
serde_yaml = "0.9"
|
|
17
17
|
regex = "1.10"
|
|
18
18
|
glob = "0.3"
|
|
19
|
+
similar = "2"
|
|
19
20
|
|
|
20
21
|
[dev-dependencies]
|
|
21
22
|
tempfile = "3.8"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ry-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.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,9 @@ 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>,
|
|
39
|
+
#[serde(default)]
|
|
38
40
|
pub kind: RuleKind,
|
|
39
41
|
#[serde(rename = "match")]
|
|
40
42
|
pub match_pattern: String,
|
|
@@ -47,6 +49,12 @@ pub enum RuleKind {
|
|
|
47
49
|
Regex,
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
impl Default for RuleKind {
|
|
53
|
+
fn default() -> Self {
|
|
54
|
+
RuleKind::Regex
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
#[derive(Debug, Serialize, Deserialize)]
|
|
51
59
|
#[serde(untagged)]
|
|
52
60
|
pub enum TargetVariant {
|
|
@@ -88,10 +96,9 @@ impl Config {
|
|
|
88
96
|
|
|
89
97
|
pub fn get_effective_rules_from_defaults(&self) -> Vec<Rule> {
|
|
90
98
|
let mut rules = Vec::new();
|
|
91
|
-
let mut seen_ids = HashMap::new();
|
|
92
99
|
|
|
93
100
|
for package_ref in &self.defaults.include {
|
|
94
|
-
self.add_package_rules(&mut rules,
|
|
101
|
+
self.add_package_rules(&mut rules, package_ref);
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
rules
|
|
@@ -99,40 +106,34 @@ impl Config {
|
|
|
99
106
|
|
|
100
107
|
pub fn get_effective_rules(&self, target: &Target) -> Vec<Rule> {
|
|
101
108
|
let mut rules = Vec::new();
|
|
102
|
-
let mut seen_ids = HashMap::new();
|
|
103
109
|
|
|
104
110
|
if target.inherit_defaults {
|
|
105
111
|
for package_ref in &self.defaults.include {
|
|
106
|
-
self.add_package_rules(&mut rules,
|
|
112
|
+
self.add_package_rules(&mut rules, package_ref);
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
for package_ref in &target.include {
|
|
111
|
-
self.add_package_rules(&mut rules,
|
|
117
|
+
self.add_package_rules(&mut rules, package_ref);
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
for rule in &target.rules {
|
|
115
|
-
|
|
116
|
-
seen_ids.insert(rule.id.clone(), rules.len());
|
|
117
|
-
rules.push(rule.clone());
|
|
118
|
-
}
|
|
121
|
+
rules.push(rule.clone());
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
rules
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
fn add_package_rules(
|
|
125
|
-
&self,
|
|
126
|
-
rules: &mut Vec<Rule>,
|
|
127
|
-
seen_ids: &mut HashMap<String, usize>,
|
|
128
|
-
package_ref: &PackageRef,
|
|
129
|
-
) {
|
|
127
|
+
fn add_package_rules(&self, rules: &mut Vec<Rule>, package_ref: &PackageRef) {
|
|
130
128
|
let package = crate::packages::get_package(&package_ref.package, &self.packages);
|
|
131
129
|
|
|
132
130
|
if let Some(pkg) = package {
|
|
133
131
|
for rule in &pkg.rules {
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
let should_exclude = rule
|
|
133
|
+
.id
|
|
134
|
+
.as_ref()
|
|
135
|
+
.map_or(false, |id| package_ref.exclude.contains(id));
|
|
136
|
+
if !should_exclude {
|
|
136
137
|
rules.push(rule.clone());
|
|
137
138
|
}
|
|
138
139
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use clap::Parser;
|
|
2
2
|
use glob::glob;
|
|
3
3
|
use ry::config::Config;
|
|
4
|
-
use ry::diagnostics::{Diagnostic, Severity};
|
|
4
|
+
use ry::diagnostics::{Diagnostic, DiagnosticKind, Severity};
|
|
5
5
|
use ry::inline::process_file_inline;
|
|
6
6
|
use ry::module::process_all_file_targets;
|
|
7
7
|
use std::path::{Path, PathBuf};
|
|
@@ -105,13 +105,40 @@ fn main() {
|
|
|
105
105
|
diagnostics.extend(files_diagnostics);
|
|
106
106
|
fixed_diagnostics.extend(files_fixed);
|
|
107
107
|
|
|
108
|
-
print_summary(&paths_to_process, &diagnostics, &fixed_diagnostics);
|
|
108
|
+
print_summary(&paths_to_process, &diagnostics, &fixed_diagnostics, cli.verbose);
|
|
109
|
+
|
|
110
|
+
if diagnostics
|
|
111
|
+
.iter()
|
|
112
|
+
.any(|d| matches!(d.severity, Severity::Error))
|
|
113
|
+
{
|
|
114
|
+
std::process::exit(1)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn print_diff(actual: &str, expected: &str) {
|
|
119
|
+
use similar::{ChangeTag, TextDiff};
|
|
120
|
+
use std::io::IsTerminal;
|
|
121
|
+
let colors = std::io::stderr().is_terminal();
|
|
122
|
+
let diff = TextDiff::from_lines(actual, expected);
|
|
123
|
+
for change in diff.iter_all_changes() {
|
|
124
|
+
let (sign, color, reset) = match change.tag() {
|
|
125
|
+
ChangeTag::Delete => ("-", "\x1b[31m", "\x1b[0m"),
|
|
126
|
+
ChangeTag::Insert => ("+", "\x1b[32m", "\x1b[0m"),
|
|
127
|
+
ChangeTag::Equal => (" ", "", ""),
|
|
128
|
+
};
|
|
129
|
+
if colors {
|
|
130
|
+
eprint!("{}{}{}{}", color, sign, change, reset);
|
|
131
|
+
} else {
|
|
132
|
+
eprint!("{}{}", sign, change);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
109
135
|
}
|
|
110
136
|
|
|
111
137
|
fn print_summary(
|
|
112
138
|
paths_to_process: &[PathBuf],
|
|
113
139
|
diagnostics: &[Diagnostic],
|
|
114
140
|
fixed_diagnostics: &[Diagnostic],
|
|
141
|
+
verbose: bool,
|
|
115
142
|
) {
|
|
116
143
|
let error_count = diagnostics
|
|
117
144
|
.iter()
|
|
@@ -123,6 +150,15 @@ fn print_summary(
|
|
|
123
150
|
.count();
|
|
124
151
|
let fixed_count = fixed_diagnostics.len();
|
|
125
152
|
|
|
153
|
+
if verbose {
|
|
154
|
+
for diagnostic in diagnostics {
|
|
155
|
+
if let DiagnosticKind::OutDatedGeneratedCode { actual_code, transformed_code, .. } = &diagnostic.kind {
|
|
156
|
+
eprintln!("diff for {}:{}:", diagnostic.location.file, diagnostic.location.line);
|
|
157
|
+
print_diff(actual_code, transformed_code);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
126
162
|
if fixed_count > 0 {
|
|
127
163
|
println!(
|
|
128
164
|
"Processed {} file(s) with {} error(s), {} warning(s), and fixed {} diagnostic(s)",
|
|
@@ -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(),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
input.py:1:0: error: Generated code @sync is out of sync with generate marker
|
|
2
|
+
diff for input.py:1:
|
|
3
|
+
-async def fetch_data(): # unasync: generated @sync
|
|
4
|
+
- result = await get_data()
|
|
5
|
+
+def fetch_data(): # unasync: generated @sync
|
|
6
|
+
+ result = get_data()
|
|
7
|
+
return result
|
|
8
|
+
Processed 1 file(s) with 1 error(s) and 0 warning(s)
|
|
@@ -3,6 +3,7 @@ use ry::config::Config;
|
|
|
3
3
|
use ry::inline::process_file_inline;
|
|
4
4
|
use std::fs;
|
|
5
5
|
use std::path::{Path, PathBuf};
|
|
6
|
+
use std::process::Command;
|
|
6
7
|
use tempfile::TempDir;
|
|
7
8
|
|
|
8
9
|
fn get_fixture_dirs() -> Vec<PathBuf> {
|
|
@@ -77,6 +78,42 @@ fn run_fixture_test(fixture_dir: &Path) {
|
|
|
77
78
|
fixture_name
|
|
78
79
|
);
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
let output_path = fixture_dir.join("output.txt");
|
|
83
|
+
|
|
84
|
+
let temp_check = temp_dir.path().join("check_input.py");
|
|
85
|
+
fs::copy(&input_path, &temp_check).unwrap();
|
|
86
|
+
|
|
87
|
+
let bin = env!("CARGO_BIN_EXE_ry");
|
|
88
|
+
let output = Command::new(bin)
|
|
89
|
+
.args([
|
|
90
|
+
"--config",
|
|
91
|
+
config_path.to_str().unwrap(),
|
|
92
|
+
"--verbose",
|
|
93
|
+
temp_check.to_str().unwrap(),
|
|
94
|
+
])
|
|
95
|
+
.output()
|
|
96
|
+
.expect("failed to run ry binary");
|
|
97
|
+
|
|
98
|
+
let temp_str = temp_check.to_str().unwrap();
|
|
99
|
+
let combined = format!(
|
|
100
|
+
"{}{}",
|
|
101
|
+
String::from_utf8_lossy(&output.stderr),
|
|
102
|
+
String::from_utf8_lossy(&output.stdout),
|
|
103
|
+
)
|
|
104
|
+
.replace(temp_str, "input.py");
|
|
105
|
+
|
|
106
|
+
if update_fixtures || !output_path.exists() {
|
|
107
|
+
fs::write(&output_path, &combined).unwrap();
|
|
108
|
+
println!("Fixture '{}': Generated output.txt", fixture_name);
|
|
109
|
+
} else {
|
|
110
|
+
let expected_output = fs::read_to_string(&output_path).unwrap();
|
|
111
|
+
assert_eq!(
|
|
112
|
+
combined, expected_output,
|
|
113
|
+
"Fixture '{}': Output does not match output.txt",
|
|
114
|
+
fixture_name
|
|
115
|
+
);
|
|
116
|
+
}
|
|
80
117
|
}
|
|
81
118
|
|
|
82
119
|
#[test]
|
ry_cli-0.4.0/uv.lock
ADDED
ry_cli-0.2.0/CHANGELOG.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [0.2.0](https://github.com/karpetrosyan/ry/compare/v0.1.0...v0.2.0) (2026-04-09)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Features
|
|
7
|
-
|
|
8
|
-
* add support for passing multiple PATHs ([27f91f7](https://github.com/karpetrosyan/ry/commit/27f91f7a5b5db7b6bb803a6e896fe09c96456f36))
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* remove redundant generation file ([fe9dbc4](https://github.com/karpetrosyan/ry/commit/fe9dbc4a66392c96019799746c09bd0992dd4d53))
|
|
14
|
-
|
|
15
|
-
## 0.1.0 (2026-04-08)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Features
|
|
19
|
-
|
|
20
|
-
* first release ([e1aed91](https://github.com/karpetrosyan/ry/commit/e1aed91f6370bb3832b72be8164c4591e456d0da))
|
|
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
|