Skip to content

Commit 8f7add4

Browse files
stsnellwesterhof
authored andcommitted
YDA-7031: ensure API functions use Optional
Ensure that API functions use Optional type annotations rather than new-style syntax (e.g. Optional[str] rather than str | None). Otherwise the API type checker can fail when running on Python 3.9.
1 parent c815540 commit 8f7add4

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

datarequest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def generate_request_id(ctx: rule.Context) -> int:
362362

363363

364364
@api.make()
365-
def api_datarequest_action_permitted(ctx: rule.Context, request_id: str, roles: list, statuses: list | None) -> api.Result:
365+
def api_datarequest_action_permitted(ctx: rule.Context, request_id: str, roles: list, statuses: Optional[list]) -> api.Result:
366366
"""Wrapper around datarequest_action_permitted.
367367
368368
:param ctx: Combined type of a callback and rei struct
@@ -382,7 +382,7 @@ def get_status(stat: str) -> status:
382382
return datarequest_action_permitted(ctx, request_id, roles, statuses)
383383

384384

385-
def datarequest_action_permitted(ctx: rule.Context, request_id: str, roles: list, statuses: list | None) -> bool:
385+
def datarequest_action_permitted(ctx: rule.Context, request_id: str, roles: list, statuses: Optional[list]) -> bool:
386386
"""Check if current user and data request status meet specified restrictions.
387387
388388
:param ctx: Combined type of a callback and rei struct
@@ -425,7 +425,7 @@ def datarequest_action_permitted(ctx: rule.Context, request_id: str, roles: list
425425

426426

427427
@api.make()
428-
def api_datarequest_roles_get(ctx: rule.Context, request_id: str | None = None) -> api.Result:
428+
def api_datarequest_roles_get(ctx: rule.Context, request_id: Optional[str] = None) -> api.Result:
429429
"""Get roles of invoking user.
430430
431431
:param ctx: Combined type of a callback and rei struct
@@ -437,7 +437,7 @@ def api_datarequest_roles_get(ctx: rule.Context, request_id: str | None = None)
437437
return datarequest_roles_get(ctx, request_id)
438438

439439

440-
def datarequest_roles_get(ctx: rule.Context, request_id: str | None = None) -> list:
440+
def datarequest_roles_get(ctx: rule.Context, request_id: Optional[str] = None) -> list:
441441
"""Get roles of invoking user.
442442
443443
:param ctx: Combined type of a callback and rei struct
@@ -922,7 +922,7 @@ def file_lock(ctx: rule.Context, coll_path: str, filename: str, readers: list[st
922922

923923

924924
@api.make()
925-
def api_datarequest_submit(ctx: rule.Context, data: dict, draft: bool, draft_request_id: str | None = None) -> api.Result:
925+
def api_datarequest_submit(ctx: rule.Context, data: dict, draft: bool, draft_request_id: Optional[str] = None) -> api.Result:
926926
"""Persist a data request to disk.
927927
928928
:param ctx: Combined type of a callback and rei struct

vault.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import subprocess
1212
import time
1313
from datetime import datetime
14-
from typing import List, Tuple
14+
from typing import List, Optional, Tuple
1515

1616
import genquery
1717
from dateutil import parser
@@ -56,7 +56,7 @@
5656

5757

5858
@api.make()
59-
def api_vault_submit(ctx: rule.Context, coll: str, previous_version: str | None = None) -> api.Result:
59+
def api_vault_submit(ctx: rule.Context, coll: str, previous_version: Optional[str] = None) -> api.Result:
6060
"""Submit data package for publication.
6161
6262
:param ctx: Combined type of a callback and rei struct

0 commit comments

Comments
 (0)