ry-cli 0.3.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.
Files changed (34) hide show
  1. {ry_cli-0.3.0 → ry_cli-0.4.0}/CHANGELOG.md +8 -1
  2. {ry_cli-0.3.0 → ry_cli-0.4.0}/Cargo.lock +8 -1
  3. {ry_cli-0.3.0 → ry_cli-0.4.0}/Cargo.toml +2 -1
  4. {ry_cli-0.3.0 → ry_cli-0.4.0}/PKG-INFO +1 -1
  5. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/config.rs +7 -0
  6. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/diagnostics.rs +1 -0
  7. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/inline.rs +1 -0
  8. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/main.rs +38 -2
  9. ry_cli-0.4.0/tests/fixtures/basic_async_to_sync/output.txt +2 -0
  10. ry_cli-0.4.0/tests/fixtures/outdated_generated_code/expected.py +7 -0
  11. ry_cli-0.4.0/tests/fixtures/outdated_generated_code/input.py +7 -0
  12. ry_cli-0.4.0/tests/fixtures/outdated_generated_code/output.txt +8 -0
  13. ry_cli-0.4.0/tests/fixtures/outdated_generated_code/ry.yml +8 -0
  14. ry_cli-0.4.0/tests/fixtures/tag_rules/output.txt +2 -0
  15. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures.rs +37 -0
  16. ry_cli-0.4.0/uv.lock +7 -0
  17. {ry_cli-0.3.0 → ry_cli-0.4.0}/.github/logo.png +0 -0
  18. {ry_cli-0.3.0 → ry_cli-0.4.0}/.github/workflows/publish-python.yml +0 -0
  19. {ry_cli-0.3.0 → ry_cli-0.4.0}/.github/workflows/release-please.yml +0 -0
  20. {ry_cli-0.3.0 → ry_cli-0.4.0}/.gitignore +0 -0
  21. {ry_cli-0.3.0 → ry_cli-0.4.0}/LICENSE +0 -0
  22. {ry_cli-0.3.0 → ry_cli-0.4.0}/README.md +0 -0
  23. {ry_cli-0.3.0 → ry_cli-0.4.0}/pyproject.toml +0 -0
  24. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/generation.rs +0 -0
  25. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/lib.rs +0 -0
  26. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/module.rs +0 -0
  27. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/packages.rs +0 -0
  28. {ry_cli-0.3.0 → ry_cli-0.4.0}/src/treesitter.rs +0 -0
  29. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/expected.py +0 -0
  30. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/input.py +0 -0
  31. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/basic_async_to_sync/ry.yml +0 -0
  32. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/expected.py +0 -0
  33. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/input.py +0 -0
  34. {ry_cli-0.3.0 → ry_cli-0.4.0}/tests/fixtures/tag_rules/ry.yml +0 -0
@@ -1,11 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## [0.3.0](https://github.com/karpetrosyan/ry/compare/v0.2.0...v0.3.0) (2026-04-10)
3
+ ## [0.4.0](https://github.com/karpetrosyan/ry/compare/v0.2.0...v0.4.0) (2026-04-18)
4
4
 
5
5
 
6
6
  ### Features
7
7
 
8
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))
9
16
 
10
17
  ## [0.2.0](https://github.com/karpetrosyan/ry/compare/v0.1.0...v0.2.0) (2026-04-09)
11
18
 
@@ -375,7 +375,7 @@ dependencies = [
375
375
 
376
376
  [[package]]
377
377
  name = "ry"
378
- version = "0.3.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.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.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
@@ -36,6 +36,7 @@ pub struct Package {
36
36
  pub struct Rule {
37
37
  #[serde(default, skip_serializing_if = "Option::is_none")]
38
38
  pub id: Option<String>,
39
+ #[serde(default)]
39
40
  pub kind: RuleKind,
40
41
  #[serde(rename = "match")]
41
42
  pub match_pattern: String,
@@ -48,6 +49,12 @@ pub enum RuleKind {
48
49
  Regex,
49
50
  }
50
51
 
52
+ impl Default for RuleKind {
53
+ fn default() -> Self {
54
+ RuleKind::Regex
55
+ }
56
+ }
57
+
51
58
  #[derive(Debug, Serialize, Deserialize)]
52
59
  #[serde(untagged)]
53
60
  pub enum TargetVariant {
@@ -27,6 +27,7 @@ pub enum DiagnosticKind {
27
27
  generate_end_byte: usize,
28
28
  generated_end_byte: Option<usize>,
29
29
  transformed_code: String,
30
+ actual_code: String,
30
31
  indentation: usize,
31
32
  source_line: usize,
32
33
  },
@@ -297,6 +297,7 @@ fn validate_generate_node(
297
297
  generate_end_byte,
298
298
  generated_end_byte: Some(next.end_byte()),
299
299
  transformed_code: transformed,
300
+ actual_code: next_text.to_string(),
300
301
  indentation,
301
302
  source_line: start_line + 1,
302
303
  },
@@ -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)",
@@ -0,0 +1,2 @@
1
+ input.py:1:0: error: Generate marker @sync must be followed by a generated node
2
+ Processed 1 file(s) with 1 error(s) and 0 warning(s)
@@ -0,0 +1,7 @@
1
+ async def fetch_data(): # unasync: generate @sync
2
+ result = await get_data()
3
+ return result
4
+
5
+ def fetch_data(): # unasync: generated @sync
6
+ result = get_data()
7
+ return result
@@ -0,0 +1,7 @@
1
+ async def fetch_data(): # unasync: generate @sync
2
+ result = await get_data()
3
+ return result
4
+
5
+ async def fetch_data(): # unasync: generated @sync
6
+ result = await get_data()
7
+ return result
@@ -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)
@@ -0,0 +1,8 @@
1
+ version: 1
2
+
3
+ defaults:
4
+ include:
5
+ - package: std
6
+
7
+ targets:
8
+ - tag: sync
@@ -0,0 +1,2 @@
1
+ input.py:1:0: error: Generate marker @mytag must be followed by a generated node
2
+ 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
@@ -0,0 +1,7 @@
1
+ version = 1
2
+ revision = 3
3
+ requires-python = ">=3.8"
4
+
5
+ [[package]]
6
+ name = "ry-cli"
7
+ source = { editable = "." }
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