Skip to content

Commit

Permalink
fix: ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
skellys committed Oct 31, 2023
1 parent 1d5e95f commit 55fe6ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pytest_ruff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from subprocess import Popen, PIPE

# Python<=3.8 don't support typing with builtin dict.
from typing import Dict

Expand All @@ -12,7 +13,9 @@
def pytest_addoption(parser):
group = parser.getgroup("general")
group.addoption("--ruff", action="store_true", help="enable checking with ruff")
group.addoption("--ruff-format", action="store_true", help="enable format checking with ruff")
group.addoption(
"--ruff-format", action="store_true", help="enable format checking with ruff"
)


def pytest_configure(config):
Expand Down Expand Up @@ -63,7 +66,7 @@ def collect(self):

def check_file(self, path):
ruff = find_ruff_bin()
command = [ruff, "check", path, '--quiet', '--show-source', '--force-exclude']
command = [ruff, "check", path, "--quiet", "--show-source", "--force-exclude"]
child = Popen(command, stdout=PIPE, stderr=PIPE)
stdout, _ = child.communicate()
if stdout:
Expand All @@ -72,7 +75,7 @@ def check_file(self, path):

def format_file(self, path):
ruff = find_ruff_bin()
command = [ruff, "format", path, '--quiet', '--check', '--force-exclude']
command = [ruff, "format", path, "--quiet", "--check", "--force-exclude"]
with Popen(command) as child:
pass

Expand Down
4 changes: 3 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def test_pytest_ruff():
).communicate()
out_utf8 = out.decode("utf-8")
assert "`os` imported but unused" in out_utf8
assert "force-exclude:1:1: E902 No such file or directory (os error 2)" not in out_utf8
assert (
"force-exclude:1:1: E902 No such file or directory (os error 2)" not in out_utf8
)


def test_pytest_ruff_format():
Expand Down

0 comments on commit 55fe6ee

Please sign in to comment.