Skip to content

Commit 0e5b08d

Browse files
committed
Fix broken import, more typing updates
1 parent 204b7dd commit 0e5b08d

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

tiled/_tests/test_protocols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ async def accesspolicy_protocol_functions(
426426
policy: AccessPolicy,
427427
node: BaseAdapter,
428428
principal: Principal,
429-
authn_access_tags: Optional[Set[str]],
429+
authn_access_tags: Optional[AccessTags],
430430
authn_scopes: Scopes,
431431
scopes: Scopes,
432432
) -> None:

tiled/access_control/access_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import os
3-
from types import Optional, Tuple
3+
from typing import Optional, Tuple
44

55
from ..adapters.protocols import BaseAdapter
66
from ..queries import AccessBlobFilter

tiled/server/authentication.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import warnings
55
from datetime import datetime, timedelta, timezone
66
from pathlib import Path
7-
from typing import Annotated, Any, Callable, Optional, Sequence, Set
7+
from typing import Annotated, Any, Callable, Optional, Sequence
88

99
from fastapi import (
1010
APIRouter,
@@ -60,6 +60,7 @@
6060
lookup_valid_pending_session_by_user_code,
6161
lookup_valid_session,
6262
)
63+
from ..type_aliases import AccessTags
6364
from ..utils import SHARE_TILED_PATH, SingleUserPrincipal
6465
from . import schemas
6566
from .connection_pool import get_database_session_factory
@@ -230,7 +231,7 @@ async def get_session_state(decoded_access_token=Depends(get_decoded_access_toke
230231

231232
async def get_access_tags_from_api_key(
232233
api_key: str, authenticated: bool, db: Optional[AsyncSession]
233-
) -> Optional[Set[str]]:
234+
) -> Optional[AccessTags]:
234235
if not authenticated:
235236
# Tiled is in a "single user" mode with only one API key.
236237
# In this mode, there is no meaningful access tag limit.
@@ -258,7 +259,7 @@ async def get_current_access_tags(
258259
db_factory: Callable[[], Optional[AsyncSession]] = Depends(
259260
get_database_session_factory
260261
),
261-
) -> Optional[Set[str]]:
262+
) -> Optional[AccessTags]:
262263
if api_key is not None:
263264
async with db_factory() as db:
264265
return await get_access_tags_from_api_key(
@@ -292,7 +293,7 @@ async def get_current_access_tags_websocket(
292293
db_factory: Callable[[], Optional[AsyncSession]] = Depends(
293294
get_database_session_factory
294295
),
295-
) -> Optional[Set[str]]:
296+
) -> Optional[AccessTags]:
296297
if api_key is not None:
297298
async with db_factory() as db:
298299
return await get_access_tags_from_api_key(

tiled/server/dependencies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional, Set
1+
from typing import List, Optional
22

33
import pydantic_settings
44
from fastapi import HTTPException, Query, Request
@@ -7,7 +7,7 @@
77
from ..access_control.protocols import AccessPolicy
88
from ..adapters.protocols import AnyAdapter
99
from ..structures.core import StructureFamily
10-
from ..type_aliases import Scopes
10+
from ..type_aliases import AccessTags, Scopes
1111
from ..utils import BrokenLink
1212
from .core import NoEntry
1313
from .schemas import Principal
@@ -22,7 +22,7 @@ async def get_entry(
2222
path: str,
2323
security_scopes: List[str],
2424
principal: Optional[Principal],
25-
authn_access_tags: Optional[Set[str]],
25+
authn_access_tags: Optional[AccessTags],
2626
authn_scopes: Scopes,
2727
root_tree: pydantic_settings.BaseSettings,
2828
session_state: dict,

tiled/server/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22
import time
33
from collections.abc import Generator
4-
from typing import Any, Literal, Mapping, Optional, Sequence, Set
4+
from typing import Any, Literal, Mapping, Optional, Sequence
55

66
from fastapi import Request, WebSocket
77
from starlette.types import Scope
@@ -10,7 +10,7 @@
1010
from ..access_control.protocols import AccessPolicy
1111
from ..adapters.mapping import MapAdapter
1212
from ..server.schemas import Principal
13-
from ..type_aliases import Scopes
13+
from ..type_aliases import AccessTags, Scopes
1414

1515
EMPTY_NODE = MapAdapter({})
1616
API_KEY_COOKIE_NAME = "tiled_api_key"
@@ -89,7 +89,7 @@ async def filter_for_access(
8989
entry,
9090
access_policy: Optional[AccessPolicy],
9191
principal: Principal,
92-
authn_access_tags: Optional[Set[str]],
92+
authn_access_tags: Optional[AccessTags],
9393
authn_scopes: Scopes,
9494
scopes: Sequence[str],
9595
metrics: dict[str, Any],

tiled/server/zarr.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import re
3-
from typing import Optional, Set, Tuple, Union
3+
from typing import Optional, Tuple, Union
44

55
import numcodecs
66
import orjson
@@ -10,7 +10,7 @@
1010
from starlette.status import HTTP_400_BAD_REQUEST, HTTP_500_INTERNAL_SERVER_ERROR
1111

1212
from ..structures.core import StructureFamily
13-
from ..type_aliases import Scopes
13+
from ..type_aliases import AccessTags, Scopes
1414
from ..utils import ensure_awaitable
1515
from .authentication import (
1616
get_current_access_tags,
@@ -56,7 +56,7 @@ async def get_zarr_attrs(
5656
request: Request,
5757
path: str,
5858
principal: Union[Principal] = Depends(get_current_principal),
59-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
59+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
6060
authn_scopes: Scopes = Depends(get_current_scopes),
6161
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
6262
session_state: dict = Depends(get_session_state),
@@ -92,7 +92,7 @@ async def get_zarr_group_metadata(
9292
request: Request,
9393
path: str,
9494
principal: Union[Principal] = Depends(get_current_principal),
95-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
95+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
9696
authn_scopes: Scopes = Depends(get_current_scopes),
9797
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
9898
session_state: dict = Depends(get_session_state),
@@ -120,7 +120,7 @@ async def get_zarr_array_metadata(
120120
request: Request,
121121
path: str,
122122
principal: Union[Principal] = Depends(get_current_principal),
123-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
123+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
124124
authn_scopes: Scopes = Depends(get_current_scopes),
125125
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
126126
session_state: dict = Depends(get_session_state),
@@ -164,7 +164,7 @@ async def get_zarr_array(
164164
request: Request,
165165
path: str,
166166
principal: Union[Principal] = Depends(get_current_principal),
167-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
167+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
168168
authn_scopes: Scopes = Depends(get_current_scopes),
169169
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
170170
session_state: dict = Depends(get_session_state),
@@ -283,7 +283,7 @@ async def get_zarr_metadata(
283283
request: Request,
284284
path: str,
285285
principal: Union[Principal] = Depends(get_current_principal),
286-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
286+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
287287
authn_scopes: Scopes = Depends(get_current_scopes),
288288
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
289289
session_state: dict = Depends(get_session_state),
@@ -375,7 +375,7 @@ async def get_zarr_array(
375375
path: str,
376376
block: str,
377377
principal: Union[Principal] = Depends(get_current_principal),
378-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
378+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
379379
authn_scopes: Scopes = Depends(get_current_scopes),
380380
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
381381
session_state: dict = Depends(get_session_state),
@@ -456,7 +456,7 @@ async def get_zarr_group(
456456
request: Request,
457457
path: str,
458458
principal: Union[Principal] = Depends(get_current_principal),
459-
authn_access_tags: Optional[Set[str]] = Depends(get_current_access_tags),
459+
authn_access_tags: Optional[AccessTags] = Depends(get_current_access_tags),
460460
authn_scopes: Scopes = Depends(get_current_scopes),
461461
root_tree: pydantic_settings.BaseSettings = Depends(get_root_tree),
462462
session_state: dict = Depends(get_session_state),

0 commit comments

Comments
 (0)