Skip to content

Commit 5ab3f07

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4ba2c9b commit 5ab3f07

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

diracx-routers/src/diracx/routers/pilots/access_policies.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def policy(
3939
pilot_stamps: list[str] | None = None,
4040
job_db: JobDB | None = None,
4141
job_ids: list[int] | None = None,
42-
allow_legacy_pilots: bool = False
42+
allow_legacy_pilots: bool = False,
4343
):
4444
assert action, "action is a mandatory parameter"
4545

@@ -48,10 +48,11 @@ async def policy(
4848
# To manage pilots, user have to be an admin
4949
# In some special cases (described with allow_legacy_pilots), we can allow pilots
5050
if action == ActionType.MANAGE_PILOTS:
51-
5251
# To make it clear, we separate
5352
is_an_admin = SERVICE_ADMINISTRATOR in user_info.properties
54-
is_a_pilot_if_allowed = allow_legacy_pilots and GENERIC_PILOT in user_info.properties
53+
is_a_pilot_if_allowed = (
54+
allow_legacy_pilots and GENERIC_PILOT in user_info.properties
55+
)
5556

5657
if not is_an_admin and not is_a_pilot_if_allowed:
5758
raise HTTPException(
@@ -63,7 +64,7 @@ async def policy(
6364
if GENERIC_PILOT in user_info.properties:
6465
raise HTTPException(
6566
status_code=status.HTTP_403_FORBIDDEN,
66-
detail="Pilots can't read other pilots info."
67+
detail="Pilots can't read other pilots info.",
6768
)
6869

6970
#

diracx-routers/src/diracx/routers/pilots/management.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from http import HTTPStatus
44
from typing import Annotated
55

6-
from diracx.core.properties import GENERIC_PILOT
76
from fastapi import Body, Depends, HTTPException, Query, status
87

98
from diracx.core.exceptions import (
@@ -15,6 +14,7 @@
1514
PilotFieldsMapping,
1615
PilotStatus,
1716
)
17+
from diracx.core.properties import GENERIC_PILOT
1818
from diracx.logic.pilots.management import (
1919
add_jobs_to_pilot as add_jobs_to_pilot_bl,
2020
)
@@ -68,7 +68,7 @@ async def add_pilot_stamps(
6868
# TODO: Verify that grid types, sites, destination sites, etc. are valids
6969
await check_permissions(
7070
action=ActionType.MANAGE_PILOTS,
71-
allow_legacy_pilots=True # dirac-admin-add-pilot
71+
allow_legacy_pilots=True, # dirac-admin-add-pilot
7272
)
7373

7474
# Prevent someone who stole a pilot X509 to create thousands of pilots at a time
@@ -77,7 +77,7 @@ async def add_pilot_stamps(
7777
if len(pilot_stamps) != 1:
7878
raise HTTPException(
7979
status_code=status.HTTP_401_UNAUTHORIZED,
80-
detail="As a pilot, you can only create yourself."
80+
detail="As a pilot, you can only create yourself.",
8181
)
8282

8383
try:
@@ -205,10 +205,10 @@ async def update_pilot_fields(
205205
# Ensures stamps validity
206206
pilot_stamps = [mapping.PilotStamp for mapping in pilot_stamps_to_fields_mapping]
207207
await check_permissions(
208-
action=ActionType.MANAGE_PILOTS,
209-
pilot_db=pilot_db,
208+
action=ActionType.MANAGE_PILOTS,
209+
pilot_db=pilot_db,
210210
pilot_stamps=pilot_stamps,
211-
allow_legacy_pilots=True # dirac-admin-add-pilot
211+
allow_legacy_pilots=True, # dirac-admin-add-pilot
212212
)
213213

214214
# Prevent someone who stole a pilot X509 to modify thousands of pilots at a time
@@ -218,10 +218,9 @@ async def update_pilot_fields(
218218
if len(pilot_stamps) != 1:
219219
raise HTTPException(
220220
status_code=status.HTTP_401_UNAUTHORIZED,
221-
detail="As a pilot, you can only modify yourself."
221+
detail="As a pilot, you can only modify yourself.",
222222
)
223223

224-
225224
await update_pilots_fields(
226225
pilot_db=pilot_db,
227226
pilot_stamps_to_fields_mapping=pilot_stamps_to_fields_mapping,

diracx-routers/tests/pilots/test_pilot_creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"BaseAccessPolicy",
2626
"PilotAgentsDB",
2727
"PilotManagementAccessPolicy",
28-
"JobDB"
28+
"JobDB",
2929
]
3030
)
3131

0 commit comments

Comments
 (0)