Skip to content

Commit

Permalink
fix ruff format subcommand, closes #843
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 7, 2024
1 parent 35ae632 commit 658a2c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nbqa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def _run_command( # pylint: disable=too-many-locals
if main_command == "mypy" and "MYPY_FORCE_COLOR" not in my_env:
my_env["MYPY_FORCE_COLOR"] = "1"

if main_command == "ruff":
if main_command == "ruff" and not sub_commands:
sub_commands.insert(0, "check")

if shell:
Expand Down
18 changes: 18 additions & 0 deletions tests/tools/test_ruff_works.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Check :code:`ruff` works as intended."""

import os
from pathlib import Path
from typing import TYPE_CHECKING

import pytest
Expand Down Expand Up @@ -109,3 +110,20 @@ def test_ruff_isort(capsys: "CaptureFixture") -> None:
out, err = capsys.readouterr()
assert out == ""
assert err == ""


def test_ruff_format(capsys: "CaptureFixture", tmp_notebook_for_testing: Path) -> None:
"""
Should ignore cell with all magics.
Parameters
----------
capsys
Pytest fixture to capture stdout and stderr.
"""

main(["ruff format", str(tmp_notebook_for_testing)])

out, err = capsys.readouterr()
assert out == "1 file reformatted\n"
assert err == ""

0 comments on commit 658a2c2

Please sign in to comment.