Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
tox_env: ${{ matrix.tox_env }}
strategy:
matrix:
tox_env: [py39, py310, py311, py312, py313, black, ruff, mypy]
tox_env: [py39, py310, py311, py312, py313, ruff-lint, ruff-format, mypy]
runs-on: ubuntu-latest
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ above to your `venv/bin/activate` file, for example:
echo 'eval "$(_CVE_COMPLETE=bash_source cve)"' >> venv/bin/activate
```

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

```bash
black .
ruff format .
```

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

```bash
ruff check --select I --fix .
Expand All @@ -278,8 +278,10 @@ Running tests and linters:
```bash
# Run all tests and format/lint checks (also run as a Github action)
tox
# Run lint check only
tox -e ruff-lint
# Run format check only
tox -e black
tox -e ruff-format
# Run tests using a specific version of Python
tox -e py313
# Run a single test using a specific version of Python
Expand Down
6 changes: 3 additions & 3 deletions cvelib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def publish(
else:
click.echo("Published the following CVE:\n")
print_cve_record(response_data["created"] if created else response_data["updated"])
click.echo(f'\nAPI response: {response_data["message"]}')
click.echo(f"\nAPI response: {response_data['message']}")


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


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


@cli.command()
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[tool.black]
line-length = 100

[tool.ruff]
line-length = 100

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

dev_require = [
*tests_require,
"black",
"ruff",
"click-man",
"mypy",
Expand Down
7 changes: 2 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def test_cve_publish_from_file(self, update_published, publish, tmp_path):

response_dict = {
"created": self.cve_response_data,
"message": f"{self.cve_id} record was " f"successfully created.",
"message": f"{self.cve_id} record was successfully created.",
}
publish.return_value = response_dict

Expand Down Expand Up @@ -564,10 +564,7 @@ def test_quota():
result = runner.invoke(cli, DEFAULT_OPTS + ["quota"])
assert result.exit_code == 0, result.output
assert result.output == (
"CNA quota for test_org:\n"
"├─ Limit:\t100\n"
"├─ Reserved:\t10\n"
"└─ Available:\t90\n"
"CNA quota for test_org:\n├─ Limit:\t100\n├─ Reserved:\t10\n└─ Available:\t90\n"
)


Expand Down
1 change: 0 additions & 1 deletion tests/test_cve_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def test_cve_record_validation_error_is_picklable():


class TestGeneratorMetadata:

@pytest.fixture
def sample_cve_json(self):
with open(Path(__file__).parent / "data/CVEv5_basic-example.json") as record_file:
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[tox]
envlist = py{39,310,311,312,313}, black, ruff, mypy
envlist = py{39,310,311,312,313}, ruff-lint, ruff-format, mypy

[testenv]
deps = pytest
commands = pytest {posargs:tests/}

[testenv:black]
deps = black
commands = black --check .

[testenv:ruff]
[testenv:ruff-lint]
deps = ruff
commands = ruff check .

[testenv:ruff-format]
deps = ruff
commands = ruff format --check --diff .

[testenv:mypy]
deps =
mypy
Expand Down