Skip to content

Commit 3b5d50b

Browse files
authored
Use ruff in place of black and bandit (#101)
Signed-off-by: Federico Busetti <[email protected]>
1 parent 0a3a1b7 commit 3b5d50b

File tree

11 files changed

+86
-562
lines changed

11 files changed

+86
-562
lines changed

.bandit.yml

Lines changed: 0 additions & 405 deletions
This file was deleted.

.codeclimate.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
version: "2"
22
plugins:
3-
bandit:
4-
enabled: true
53
sonar-python:
64
enabled: true
75
exclude_patterns:
@@ -21,4 +19,4 @@ exclude_patterns:
2119
- "Tests/"
2220
- "**/vendor/"
2321
- "**/*_test.go"
24-
- "**/*.d.ts"
22+
- "**/*.d.ts"

.github/workflows/python-code-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ jobs:
2727
python -m pip install poetry
2828
poetry config virtualenvs.create false
2929
make dev-dependencies
30-
- name: Check code style with black
30+
- name: Check code style
3131
run: |
3232
make format
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

4-
name: Bandit checks
4+
name: Python typing
55

66
on:
77
push:
@@ -12,21 +12,20 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15-
bandit:
15+
typing:
1616
runs-on: ubuntu-latest
1717

1818
steps:
1919
- uses: actions/checkout@v4
20-
21-
- name: Security check - Bandit
22-
uses: ioggstream/[email protected]
23-
with:
24-
project_path: .
25-
config_file: .bandit.yml
26-
27-
# This is optional
28-
- name: Security check report artifacts
29-
uses: actions/upload-artifact@v4
20+
- name: Set up Python 3.11
21+
uses: actions/setup-python@v5
3022
with:
31-
name: Security report
32-
path: output/security_report.txt
23+
python-version: "3.11"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install poetry
28+
poetry config virtualenvs.create false
29+
make dev-dependencies
30+
- name: Check typing
31+
run: make typing

Makefile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,11 @@ migrate:
4545
poetry run alembic upgrade heads
4646

4747
format:
48-
poetry run black --check .
49-
50-
format-fix:
51-
poetry run black .
48+
poetry run ruff format --check .
5249

5350
lint:
5451
poetry run ruff .
5552

56-
lint-fix:
57-
poetry run ruff . --fix
58-
59-
bandit:
60-
poetry run bandit -c .bandit.yml -r .
61-
6253
# There are issues on how python imports are generated when using nested
6354
# packages. The following setup appears to work, however it might need
6455
# to be reviewed. https://github.com/protocolbuffers/protobuf/issues/1491
@@ -76,8 +67,11 @@ generate-proto:
7667
grpc_app/proto/*.proto
7768
git add ./grpc_app/generated
7869

79-
fix: format-fix lint-fix
80-
check: format lint typing bandit test
70+
fix:
71+
poetry run ruff . --fix
72+
poetry run ruff format .
73+
74+
check: lint format typing test
8175

8276
docs:
8377
poetry run mkdocs serve

alembic/versions/2022-11-09-203313-52b1246eda46_create_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""create books table
22
33
Revision ID: 52b1246eda46
4-
Revises:
4+
Revises:
55
Create Date: 2022-11-09 20:33:13.035514
66
77
"""

common/di_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Container(DeclarativeContainer):
3434

3535
"""
3636
Class mappings
37-
37+
3838
These are classes we want the container to manage the life cycle for
3939
(e.g. Singletons), we map them using their class name directly.
4040
"""
@@ -45,10 +45,10 @@ class Container(DeclarativeContainer):
4545

4646
"""
4747
Interface => Class mappings
48-
48+
4949
We use the interface class name as key so that we can trigger the injection
5050
using `class.__name__` and avoid using any hardcoded string or constant.
51-
51+
5252
e.g.
5353
Mapping
5454
MyInterface = providers.Factory("http_app.storage.repositories.ConcreteClass")

domains/books/_data_access_interfaces.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88

99

1010
class BookRepositoryInterface(Protocol):
11-
async def save(self, book: BookModel) -> BookModel: ...
11+
async def save(self, book: BookModel) -> BookModel:
12+
...
1213

1314
async def find(
1415
self,
1516
search_params: Union[None, Mapping[str, Any]] = None,
1617
order_by: Union[None, Iterable[Union[str, Tuple[str, SortDirection]]]] = None,
17-
) -> List[BookModel]: ...
18+
) -> List[BookModel]:
19+
...
1820

1921

2022
class BookEventGatewayInterface(Protocol):
21-
async def emit(self, event: BaseEvent) -> None: ...
23+
async def emit(self, event: BaseEvent) -> None:
24+
...

poetry.lock

Lines changed: 1 addition & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)