Skip to content

Commit 154ab82

Browse files
authored
✨ feat: Upgrade gentest formatter to Ruff (#1058)
Co-authored-by: rahul <raxhvl@users.noreply.github.com>
1 parent a4adea6 commit 154ab82

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/cli/gentest/source_code_generator.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,24 @@ def format_code(code: str) -> str:
6767
# Create a Path object for the input file
6868
input_file_path = Path(temp_file.name)
6969

70-
# Get the path to the black executable in the virtual environment
70+
# Get the path to the formatter executable in the virtual environment
7171
if sys.platform.startswith("win"):
72-
black_path = Path(sys.prefix) / "Scripts" / "black.exe"
72+
formatter_path = Path(sys.prefix) / "Scripts" / "ruff.exe"
7373
else:
74-
black_path = Path(sys.prefix) / "bin" / "black"
74+
formatter_path = Path(sys.prefix) / "bin" / "ruff"
7575

76-
# Call black to format the file
76+
# Call ruff to format the file
7777
config_path = Path(sys.prefix).parent / "pyproject.toml"
7878

7979
subprocess.run(
80-
[str(black_path), str(input_file_path), "--quiet", "--config", str(config_path)],
80+
[
81+
str(formatter_path),
82+
"format",
83+
str(input_file_path),
84+
"--quiet",
85+
"--config",
86+
str(config_path),
87+
],
8188
check=True,
8289
)
8390

src/cli/gentest/templates/blockchain_test/transaction.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Gentest autogenerated test from `tx.hash`:
33
{{ tx_hash }}
4-
https://etherscan.io/tx/{{tx_hash}}
4+
https://etherscan.io/tx/{{tx_hash}}.
55
"""
66

77
from typing import Dict
@@ -25,7 +25,7 @@ def test_transaction_{{ tx_hash }}(
2525
):
2626
"""
2727
Gentest autogenerated test for tx.hash:
28-
{{ tx_hash }}
28+
{{ tx_hash }}.
2929
"""
3030
pre = {{ pre_state | stringify }}
3131

0 commit comments

Comments
 (0)