Skip to content

Commit 9da531b

Browse files
author
Jens Kürten
committed
switch to ruff and upgrade bandit
1 parent 6ba7093 commit 9da531b

File tree

6 files changed

+35
-33
lines changed

6 files changed

+35
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ venv/
99
dist/
1010
.pytest_cache
1111
site/
12+
.ruff_cache

.pre-commit-config.yaml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
exclude: ^.*migrations/versions
44
repos:
5-
- repo: https://github.com/timothycrosley/isort
6-
rev: 5.12.0
5+
- repo: https://github.com/astral-sh/ruff-pre-commit
6+
# Ruff version.
7+
rev: v0.7.0
78
hooks:
8-
- id: isort
9-
exclude: ^.*migrations/versions
10-
args: [
11-
"--line-length=120","--profile=black"
12-
]
13-
- repo: https://github.com/ambv/black
14-
rev: 23.7.0
15-
hooks:
16-
- id: black
17-
18-
19-
- repo: https://github.com/PyCQA/flake8
20-
rev: 6.1.0
21-
hooks:
22-
- id: flake8
23-
args: [ "--max-line-length=120", "--per-file-ignores=*/__init__.py: F401"]
9+
# Run the linter.
10+
- id: ruff
11+
args: [ --fix ]
12+
# Run the formatter.
13+
- id: ruff-format
2414

2515
- repo: https://github.com/pre-commit/pre-commit-hooks
2616
rev: v4.4.0
@@ -39,13 +29,7 @@ repos:
3929
- id: end-of-file-fixer
4030
- id: mixed-line-ending
4131
- id: trailing-whitespace
42-
- repo: https://github.com/pycqa/pylint
43-
rev: v2.15.7
44-
hooks:
45-
- id: pylint
46-
args: ["--output-format", "parseable", "-d", "W0511", "-j", "4"]
47-
4832
- repo: https://github.com/PyCQA/bandit
49-
rev: 1.7.5
33+
rev: 1.7.10
5034
hooks:
5135
- id: bandit

csfunctions/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(
1313
transaction_id: str,
1414
instance_url: str,
1515
db_service_url: str | None = None,
16-
**kwargs
16+
**kwargs,
1717
):
1818
super().__init__(
1919
app_lang=app_lang,
@@ -23,7 +23,7 @@ def __init__(
2323
request_datetime=request_datetime,
2424
transaction_id=transaction_id,
2525
instance_url=instance_url,
26-
**kwargs
26+
**kwargs,
2727
)
2828

2929
app_lang: str = Field(..., description="ISO code of the session language that triggered the webhook.")

csfunctions/objects/briefcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Briefcase(BaseObject):
3333
def link_objects(self, data: "EventData"):
3434
parts = getattr(data, "parts", None)
3535
documents = getattr(data, "documents", None)
36-
engineering_changes = getattr(data, "engineering_changes")
36+
engineering_changes = getattr(data, "engineering_changes", None)
3737

3838
if parts and self.part_ids:
3939
self._link_parts(parts)

csfunctions/response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
actions: list[Action],
2121
event_id: str | None = None,
2222
response_type: Literal[ResponseType.WORKLOAD] | None = None, # pylint: disable=unused-argument
23-
**kwargs
23+
**kwargs,
2424
):
2525
event_id = event_id or str(uuid4())
2626
super().__init__(response_type=ResponseType.WORKLOAD, event_id=event_id, actions=actions, **kwargs)
@@ -36,7 +36,7 @@ def __init__(
3636
data: dict,
3737
event_id: str | None = None,
3838
response_type: Literal[ResponseType.DATA] | None = None,
39-
**kwargs # pylint: disable=unused-argument
39+
**kwargs, # pylint: disable=unused-argument
4040
):
4141
event_id = event_id or str(uuid4())
4242

@@ -55,7 +55,7 @@ def __init__(
5555
trace: str = "",
5656
event_id: str | None = None,
5757
response_type: Literal[ResponseType.ERROR] | None = None, # pylint: disable=unused-argument
58-
**kwargs
58+
**kwargs,
5959
):
6060
event_id = event_id or str(uuid4())
6161
super().__init__(
@@ -64,7 +64,7 @@ def __init__(
6464
message=message,
6565
error_type=error_type,
6666
trace=trace,
67-
**kwargs
67+
**kwargs,
6868
)
6969

7070
response_type: Literal[ResponseType.ERROR]

pyproject.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,22 @@ requests-mock = "^1.9.0"
3131
requests-mock = "^1.11.0"
3232
pytest = "^7.4.0"
3333

34-
[tool.black]
34+
[tool.ruff]
3535
line-length = 120
36+
37+
[tool.ruff.lint]
38+
select = [
39+
# pycodestyle
40+
"E",
41+
"W",
42+
# Pyflakes
43+
"F",
44+
# pyupgrade
45+
"UP",
46+
# flake8-bugbear
47+
"B",
48+
# flake8-simplify
49+
"SIM",
50+
# isort
51+
"I",
52+
]

0 commit comments

Comments
 (0)