-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
This concerns using ruff check --fix
to fix code (#296) instead of the new ruff format
command.
Since ruff 0.1.0, the functionality no longer works. This is because since astral-sh/ruff#7838, ruff emits to stderr, which jupyterlab_code_formatter interprets as an error.
A potential fix is to add the -e
and -q
flags to the ruff call, which sets the exit code to 0 and suppresses stderr respectively.
class RuffFixFormatter(CommandLineFormatter):
@property
def label(self) -> str:
return f"Apply ruff Formatter"
def __init__(self):
try:
from ruff.__main__ import find_ruff_bin
ruff_command = find_ruff_bin()
except (ImportError, FileNotFoundError):
ruff_command = "ruff"
self.command = [ruff_command, "check", "-eq", "--fix-only", "-"]
I edited my installation of jupyterlab_code_formatter to the above and it works, but I haven't had a chance to test more systematically.
y9c, redeboer and vanheck
Metadata
Metadata
Assignees
Labels
No labels