Skip to content

Commit 8dd7457

Browse files
authored
chore: add ruff linter (#287)
1 parent 5715dec commit 8dd7457

File tree

92 files changed

+2954
-3256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2954
-3256
lines changed

.github/workflows/checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Check typing
6060
run: poetry run mypy --install-types --non-interactive --strict --no-warn-unused-ignores $(echo "${{ matrix.lib }}" | tr "-" "_")
6161

62-
security:
62+
linting:
6363
runs-on: ubuntu-latest
6464
strategy:
6565
matrix:
@@ -82,8 +82,8 @@ jobs:
8282
poetry --version
8383
- name: Install dependencies and library
8484
run: poetry install
85-
- name: Check security
86-
run: poetry run bandit -sB105 -r .
85+
- name: Check linting
86+
run: poetry run ruff check .
8787

8888
tests:
8989
runs-on: ubuntu-latest

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ typing:
4040
poetry run mypy --install-types --non-interactive --strict $$(echo $$lib | tr "-" "_"); \
4141
done
4242

43-
security:
43+
lint:
4444
for lib in $(LIBRARIES); do \
4545
cd ${WORKDIR}/$$lib && \
46-
poetry run bandit --version && \
47-
poetry run bandit -r ./; \
46+
poetry run ruff --version && \
47+
poetry run ruff check ./; \
4848
done
4949

5050
test:

scaleway-async/poetry.lock

Lines changed: 91 additions & 207 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scaleway-async/pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ python = "^3.8"
2727
scaleway-core = "^1"
2828

2929
[tool.poetry.group.dev.dependencies]
30-
mypy = "*"
31-
black = "^22.10.0"
32-
bandit = { extras = ["toml"], version = "^1.7.4" }
3330
scaleway-core = { path = "../scaleway-core", develop = true }
31+
ruff = "^0.0.286"
32+
mypy = "^1.5.1"
33+
black = "^23.7.0"
3434

3535
[build-system]
3636
requires = ["poetry-core"]
3737
build-backend = "poetry.core.masonry.api"
38+
39+
[tool.ruff]
40+
ignore = ["E501"]

scaleway-async/scaleway_async/account/v2/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def create_project(
5757

5858
res = self._request(
5959
"POST",
60-
f"/account/v2/projects",
60+
"/account/v2/projects",
6161
body=marshal_CreateProjectRequest(
6262
CreateProjectRequest(
6363
name=name or random_name(prefix="proj"),
@@ -102,7 +102,7 @@ async def list_projects(
102102

103103
res = self._request(
104104
"GET",
105-
f"/account/v2/projects",
105+
"/account/v2/projects",
106106
params={
107107
"name": name,
108108
"order_by": order_by,

scaleway-async/scaleway_async/account/v2/marshalling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515

1616
def unmarshal_Project(data: Any) -> Project:
17-
if type(data) is not dict:
17+
if not isinstance(data, dict):
1818
raise TypeError(
19-
f"Unmarshalling the type 'Project' failed as data isn't a dictionary."
19+
"Unmarshalling the type 'Project' failed as data isn't a dictionary."
2020
)
2121

2222
args: Dict[str, Any] = {}
2323

2424
field = data.get("created_at", None)
25-
args["created_at"] = parser.isoparse(field) if type(field) is str else field
25+
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
2626

2727
field = data.get("description", None)
2828
args["description"] = field
@@ -37,15 +37,15 @@ def unmarshal_Project(data: Any) -> Project:
3737
args["organization_id"] = field
3838

3939
field = data.get("updated_at", None)
40-
args["updated_at"] = parser.isoparse(field) if type(field) is str else field
40+
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field
4141

4242
return Project(**args)
4343

4444

4545
def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse:
46-
if type(data) is not dict:
46+
if not isinstance(data, dict):
4747
raise TypeError(
48-
f"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
48+
"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
4949
)
5050

5151
args: Dict[str, Any] = {}

scaleway-async/scaleway_async/account/v3/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def create_project(
5454

5555
res = self._request(
5656
"POST",
57-
f"/account/v3/projects",
57+
"/account/v3/projects",
5858
body=marshal_ProjectApiCreateProjectRequest(
5959
ProjectApiCreateProjectRequest(
6060
description=description,
@@ -97,7 +97,7 @@ async def list_projects(
9797

9898
res = self._request(
9999
"GET",
100-
f"/account/v3/projects",
100+
"/account/v3/projects",
101101
params={
102102
"name": name,
103103
"order_by": order_by,

scaleway-async/scaleway_async/account/v3/marshalling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515

1616
def unmarshal_Project(data: Any) -> Project:
17-
if type(data) is not dict:
17+
if not isinstance(data, dict):
1818
raise TypeError(
19-
f"Unmarshalling the type 'Project' failed as data isn't a dictionary."
19+
"Unmarshalling the type 'Project' failed as data isn't a dictionary."
2020
)
2121

2222
args: Dict[str, Any] = {}
2323

2424
field = data.get("created_at", None)
25-
args["created_at"] = parser.isoparse(field) if type(field) is str else field
25+
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
2626

2727
field = data.get("description", None)
2828
args["description"] = field
@@ -37,15 +37,15 @@ def unmarshal_Project(data: Any) -> Project:
3737
args["organization_id"] = field
3838

3939
field = data.get("updated_at", None)
40-
args["updated_at"] = parser.isoparse(field) if type(field) is str else field
40+
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field
4141

4242
return Project(**args)
4343

4444

4545
def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse:
46-
if type(data) is not dict:
46+
if not isinstance(data, dict):
4747
raise TypeError(
48-
f"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
48+
"Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary."
4949
)
5050

5151
args: Dict[str, Any] = {}

scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222

2323
def unmarshal_ServerTypeCPU(data: Any) -> ServerTypeCPU:
24-
if type(data) is not dict:
24+
if not isinstance(data, dict):
2525
raise TypeError(
26-
f"Unmarshalling the type 'ServerTypeCPU' failed as data isn't a dictionary."
26+
"Unmarshalling the type 'ServerTypeCPU' failed as data isn't a dictionary."
2727
)
2828

2929
args: Dict[str, Any] = {}
@@ -38,9 +38,9 @@ def unmarshal_ServerTypeCPU(data: Any) -> ServerTypeCPU:
3838

3939

4040
def unmarshal_ServerTypeDisk(data: Any) -> ServerTypeDisk:
41-
if type(data) is not dict:
41+
if not isinstance(data, dict):
4242
raise TypeError(
43-
f"Unmarshalling the type 'ServerTypeDisk' failed as data isn't a dictionary."
43+
"Unmarshalling the type 'ServerTypeDisk' failed as data isn't a dictionary."
4444
)
4545

4646
args: Dict[str, Any] = {}
@@ -55,9 +55,9 @@ def unmarshal_ServerTypeDisk(data: Any) -> ServerTypeDisk:
5555

5656

5757
def unmarshal_ServerTypeMemory(data: Any) -> ServerTypeMemory:
58-
if type(data) is not dict:
58+
if not isinstance(data, dict):
5959
raise TypeError(
60-
f"Unmarshalling the type 'ServerTypeMemory' failed as data isn't a dictionary."
60+
"Unmarshalling the type 'ServerTypeMemory' failed as data isn't a dictionary."
6161
)
6262

6363
args: Dict[str, Any] = {}
@@ -72,9 +72,9 @@ def unmarshal_ServerTypeMemory(data: Any) -> ServerTypeMemory:
7272

7373

7474
def unmarshal_OS(data: Any) -> OS:
75-
if type(data) is not dict:
75+
if not isinstance(data, dict):
7676
raise TypeError(
77-
f"Unmarshalling the type 'OS' failed as data isn't a dictionary."
77+
"Unmarshalling the type 'OS' failed as data isn't a dictionary."
7878
)
7979

8080
args: Dict[str, Any] = {}
@@ -98,18 +98,18 @@ def unmarshal_OS(data: Any) -> OS:
9898

9999

100100
def unmarshal_Server(data: Any) -> Server:
101-
if type(data) is not dict:
101+
if not isinstance(data, dict):
102102
raise TypeError(
103-
f"Unmarshalling the type 'Server' failed as data isn't a dictionary."
103+
"Unmarshalling the type 'Server' failed as data isn't a dictionary."
104104
)
105105

106106
args: Dict[str, Any] = {}
107107

108108
field = data.get("created_at", None)
109-
args["created_at"] = parser.isoparse(field) if type(field) is str else field
109+
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
110110

111111
field = data.get("deletable_at", None)
112-
args["deletable_at"] = parser.isoparse(field) if type(field) is str else field
112+
args["deletable_at"] = parser.isoparse(field) if isinstance(field, str) else field
113113

114114
field = data.get("id", None)
115115
args["id"] = field
@@ -133,7 +133,7 @@ def unmarshal_Server(data: Any) -> Server:
133133
args["type_"] = field
134134

135135
field = data.get("updated_at", None)
136-
args["updated_at"] = parser.isoparse(field) if type(field) is str else field
136+
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field
137137

138138
field = data.get("vnc_url", None)
139139
args["vnc_url"] = field
@@ -145,9 +145,9 @@ def unmarshal_Server(data: Any) -> Server:
145145

146146

147147
def unmarshal_ServerType(data: Any) -> ServerType:
148-
if type(data) is not dict:
148+
if not isinstance(data, dict):
149149
raise TypeError(
150-
f"Unmarshalling the type 'ServerType' failed as data isn't a dictionary."
150+
"Unmarshalling the type 'ServerType' failed as data isn't a dictionary."
151151
)
152152

153153
args: Dict[str, Any] = {}
@@ -174,9 +174,9 @@ def unmarshal_ServerType(data: Any) -> ServerType:
174174

175175

176176
def unmarshal_ListOSResponse(data: Any) -> ListOSResponse:
177-
if type(data) is not dict:
177+
if not isinstance(data, dict):
178178
raise TypeError(
179-
f"Unmarshalling the type 'ListOSResponse' failed as data isn't a dictionary."
179+
"Unmarshalling the type 'ListOSResponse' failed as data isn't a dictionary."
180180
)
181181

182182
args: Dict[str, Any] = {}
@@ -191,9 +191,9 @@ def unmarshal_ListOSResponse(data: Any) -> ListOSResponse:
191191

192192

193193
def unmarshal_ListServerTypesResponse(data: Any) -> ListServerTypesResponse:
194-
if type(data) is not dict:
194+
if not isinstance(data, dict):
195195
raise TypeError(
196-
f"Unmarshalling the type 'ListServerTypesResponse' failed as data isn't a dictionary."
196+
"Unmarshalling the type 'ListServerTypesResponse' failed as data isn't a dictionary."
197197
)
198198

199199
args: Dict[str, Any] = {}
@@ -207,9 +207,9 @@ def unmarshal_ListServerTypesResponse(data: Any) -> ListServerTypesResponse:
207207

208208

209209
def unmarshal_ListServersResponse(data: Any) -> ListServersResponse:
210-
if type(data) is not dict:
210+
if not isinstance(data, dict):
211211
raise TypeError(
212-
f"Unmarshalling the type 'ListServersResponse' failed as data isn't a dictionary."
212+
"Unmarshalling the type 'ListServersResponse' failed as data isn't a dictionary."
213213
)
214214

215215
args: Dict[str, Any] = {}

0 commit comments

Comments
 (0)