Skip to content

Commit d46bf96

Browse files
committed
suppress stderr in call to ruff
1 parent 7cead40 commit d46bf96

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

jupyterlab_code_formatter/formatters.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ def format_code(self, code: str, notebook: bool, args: List[str] = [], **options
456456

457457

458458
class RuffFixFormatter(CommandLineFormatter):
459+
ruff_args = ["check", "-eq", "--fix-only", "-"]
460+
459461
@property
460462
def label(self) -> str:
461463
return f"Apply ruff Formatter"
@@ -467,7 +469,11 @@ def __init__(self):
467469
ruff_command = find_ruff_bin()
468470
except (ImportError, FileNotFoundError):
469471
ruff_command = "ruff"
470-
self.command = [ruff_command, "check", "--fix-only", "-"]
472+
self.command = [ruff_command, *self.ruff_args]
473+
474+
475+
class RuffFormatFormatter(RuffFixFormatter):
476+
ruff_args = ["format", "-q", "-"]
471477

472478

473479
SERVER_FORMATTERS = {
@@ -477,6 +483,7 @@ def __init__(self):
477483
"yapf": YapfFormatter(),
478484
"isort": IsortFormatter(),
479485
"ruff": RuffFixFormatter(),
486+
"ruffformat": RuffFormatFormatter(),
480487
"formatR": FormatRFormatter(),
481488
"styler": StylerFormatter(),
482489
"scalafmt": CommandLineFormatter(command=["scalafmt", "--stdin"]),

0 commit comments

Comments
 (0)