Skip to content

Commit 63bcbf5

Browse files
committed
Reformat test code
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent d05665a commit 63bcbf5

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ tcl
7272

7373
# Ignore Jupyter Notebook related temp files
7474
.ipynb_checkpoints/
75+
/.ruff_cache/

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,17 @@ include = [
6767
[tool.ruff.lint]
6868
# Rules: https://docs.astral.sh/ruff/rules/
6969
select = [
70-
"E", # pycodestyle
71-
"W", # pycodestyle warnings
72-
"D", # pydocstyle
73-
"F", # Pyflakes
74-
"UP", # pyupgrade
75-
"S", # flake8-bandit
70+
# "E", # pycodestyle
71+
# "W", # pycodestyle warnings
72+
# "D", # pydocstyle
73+
# "F", # Pyflakes
74+
# "UP", # pyupgrade
75+
# "S", # flake8-bandit
7676
"I", # isort
77-
"C9", # McCabe complexity
77+
# "C9", # McCabe complexity
7878
]
79-
ignore = ["D1", "D200", "D203", "D205", "D212", "D400", "D415"]
79+
ignore = ["D1", "D200", "D202", "D203", "D205", "D212", "D400", "D415"]
80+
8081

8182
[tool.ruff.lint.isort]
8283
force-single-line = true
@@ -100,3 +101,5 @@ max-complexity = 10
100101

101102
[tool.ruff.lint.per-file-ignores]
102103
# Place paths of files to be ignored by ruff here
104+
"tests/*" = ["S101"]
105+
"test_*.py" = ["S101"]

tests/test_skeleton_codestyle.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,37 @@
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
99

10+
import configparser
1011
import subprocess
1112
import unittest
12-
import configparser
13-
1413

1514
class BaseTests(unittest.TestCase):
1615
def test_skeleton_codestyle(self):
17-
"""
18-
This test shouldn't run in proliferated repositories.
19-
"""
16+
# This test shouldn't run in proliferated repositories.
17+
18+
# TODO: update with switch to pyproject.toml
2019
setup_cfg = configparser.ConfigParser()
2120
setup_cfg.read("setup.cfg")
2221
if setup_cfg["metadata"]["name"] != "skeleton":
2322
return
2423

25-
args = "venv/bin/black --check -l 100 setup.py etc tests"
24+
commands = [
25+
["venv/bin/ruff", "--check"],
26+
["venv/bin/ruff", "format", "--check"],
27+
]
28+
command = None
2629
try:
27-
subprocess.check_output(args.split())
30+
for command in commands:
31+
subprocess.check_output(command) # noqa: S603
2832
except subprocess.CalledProcessError as e:
2933
print("===========================================================")
3034
print(e.output)
3135
print("===========================================================")
3236
raise Exception(
33-
"Black style check failed; please format the code using:\n"
34-
" python -m black -l 100 setup.py etc tests",
37+
f"Code style and linting command check failed: {' '.join(command)!r}.\n"
38+
"You can check and format the code using:\n"
39+
" make valid\n",
40+
"OR:\n ruff format\n",
41+
" ruff check --fix\n",
3542
e.output,
3643
) from e

0 commit comments

Comments
 (0)