Skip to content

Commit 7c1ba01

Browse files
authored
Merge pull request #107 from RedHatProductSecurity/use-ruff-formatting
Remove dependency on black and use ruff for formatting
2 parents 6c2577d + cfc513d commit 7c1ba01

File tree

8 files changed

+19
-25
lines changed

8 files changed

+19
-25
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ jobs:
1313
tox_env: ${{ matrix.tox_env }}
1414
strategy:
1515
matrix:
16-
tox_env: [py39, py310, py311, py312, py313, black, ruff, mypy]
16+
tox_env: [py39, py310, py311, py312, py313, ruff-lint, ruff-format, mypy]
1717
runs-on: ubuntu-latest

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ above to your `venv/bin/activate` file, for example:
260260
echo 'eval "$(_CVE_COMPLETE=bash_source cve)"' >> venv/bin/activate
261261
```
262262

263-
This project uses the [Black](https://black.readthedocs.io) code formatter. To reformat the entire code base after you make any changes, run:
263+
This project uses [ruff formatter](https://docs.astral.sh/ruff/formatter/) for code formatting.
264+
To reformat the entire code base after you make any changes, run:
264265

265266
```bash
266-
black .
267+
ruff format .
267268
```
268269

269-
To sort all imports using [ruff](https://docs.astral.sh/ruff/) (which replicates the behavior of
270-
[isort](https://pycqa.github.io/isort/), run:
270+
To sort all imports using [ruff's import sorting](https://docs.astral.sh/ruff/rules/#isort-i), run:
271271

272272
```bash
273273
ruff check --select I --fix .
@@ -278,8 +278,10 @@ Running tests and linters:
278278
```bash
279279
# Run all tests and format/lint checks (also run as a Github action)
280280
tox
281+
# Run lint check only
282+
tox -e ruff-lint
281283
# Run format check only
282-
tox -e black
284+
tox -e ruff-format
283285
# Run tests using a specific version of Python
284286
tox -e py313
285287
# Run a single test using a specific version of Python

cvelib/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def publish(
402402
else:
403403
click.echo("Published the following CVE:\n")
404404
print_cve_record(response_data["created"] if created else response_data["updated"])
405-
click.echo(f'\nAPI response: {response_data["message"]}')
405+
click.echo(f"\nAPI response: {response_data['message']}")
406406

407407

408408
@cli.command()
@@ -489,7 +489,7 @@ def publish_adp(
489489
else:
490490
click.echo("Published an ADP container for:\n")
491491
print_cve_record(response_data["updated"])
492-
click.echo(f'\nAPI response: {response_data["message"]}')
492+
click.echo(f"\nAPI response: {response_data['message']}")
493493

494494

495495
@cli.command()
@@ -597,7 +597,7 @@ def reject(
597597
else:
598598
click.echo("Rejected the following CVE:\n")
599599
print_cve_record(response_data["created"] if created else response_data["updated"])
600-
click.echo(f'\nAPI response: {response_data["message"]}')
600+
click.echo(f"\nAPI response: {response_data['message']}")
601601

602602

603603
@cli.command()

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[tool.black]
2-
line-length = 100
3-
41
[tool.ruff]
52
line-length = 100
63

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
dev_require = [
1414
*tests_require,
15-
"black",
1615
"ruff",
1716
"click-man",
1817
"mypy",

tests/test_cli.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def test_cve_publish_from_file(self, update_published, publish, tmp_path):
375375

376376
response_dict = {
377377
"created": self.cve_response_data,
378-
"message": f"{self.cve_id} record was " f"successfully created.",
378+
"message": f"{self.cve_id} record was successfully created.",
379379
}
380380
publish.return_value = response_dict
381381

@@ -564,10 +564,7 @@ def test_quota():
564564
result = runner.invoke(cli, DEFAULT_OPTS + ["quota"])
565565
assert result.exit_code == 0, result.output
566566
assert result.output == (
567-
"CNA quota for test_org:\n"
568-
"├─ Limit:\t100\n"
569-
"├─ Reserved:\t10\n"
570-
"└─ Available:\t90\n"
567+
"CNA quota for test_org:\n├─ Limit:\t100\n├─ Reserved:\t10\n└─ Available:\t90\n"
571568
)
572569

573570

tests/test_cve_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def test_cve_record_validation_error_is_picklable():
5959

6060

6161
class TestGeneratorMetadata:
62-
6362
@pytest.fixture
6463
def sample_cve_json(self):
6564
with open(Path(__file__).parent / "data/CVEv5_basic-example.json") as record_file:

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[tox]
2-
envlist = py{39,310,311,312,313}, black, ruff, mypy
2+
envlist = py{39,310,311,312,313}, ruff-lint, ruff-format, mypy
33

44
[testenv]
55
deps = pytest
66
commands = pytest {posargs:tests/}
77

8-
[testenv:black]
9-
deps = black
10-
commands = black --check .
11-
12-
[testenv:ruff]
8+
[testenv:ruff-lint]
139
deps = ruff
1410
commands = ruff check .
1511

12+
[testenv:ruff-format]
13+
deps = ruff
14+
commands = ruff format --check --diff .
15+
1616
[testenv:mypy]
1717
deps =
1818
mypy

0 commit comments

Comments
 (0)