Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
provinzkraut committed Aug 19, 2024
1 parent 1d97060 commit 1f6b6fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/test_tree_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ def test_ruff_fix_and_format(tmp_path, monkeypatch) -> None:
expected = """
import asyncio
import time
mode = 'format'
"""

Expand Down
9 changes: 7 additions & 2 deletions unasyncd/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ def __init__(
if ruff_format:
self._post_transforms.append(self._ruff_format)

def _run_ruff(self, source: str, output: str, tree: cst.Module, cmd: list[str]) -> str:
def _run_ruff(
self, source: str, output: str, tree: cst.Module, cmd: list[str]
) -> str:
args = [sys.executable, "-m", "ruff", *cmd, "--no-cache", "--quiet"]

if self._file_name:
Expand All @@ -203,10 +205,13 @@ def _run_ruff(self, source: str, output: str, tree: cst.Module, cmd: list[str])
return stdout

def _ruff_fix(self, source: str, output: str, tree: cst.Module) -> str:
return self._run_ruff(source, output, tree, cmd=["check", "--fix", "--fix-only"])
return self._run_ruff(
source, output, tree, cmd=["check", "--fix", "--fix-only"]
)

def _ruff_format(self, source: str, output: str, tree: cst.Module) -> str:
return self._run_ruff(source, output, tree, cmd=["format"])

def __call__(self, source: str) -> str:
if not source:
return ""
Expand Down

0 comments on commit 1f6b6fb

Please sign in to comment.