Skip to content

Commit 8b9cec7

Browse files
committed
feat: delay dandischema.models import in dandi/misctypes.py
1 parent 16f2ca1 commit 8b9cec7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

dandi/misctypes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
from functools import cache
1515
import os.path
1616
from pathlib import Path
17-
from typing import IO, TypeVar, cast
17+
from typing import IO, TYPE_CHECKING, TypeVar, cast
1818

19-
from dandischema.models import DigestType
19+
if TYPE_CHECKING:
20+
from dandischema.models import DigestType
2021

2122

2223
@dataclass
@@ -35,6 +36,8 @@ def dandi_etag(cls, value: str) -> Digest:
3536
Construct a `Digest` with the given value and a ``algorithm`` of
3637
``DigestType.dandi_etag``
3738
"""
39+
from dandischema.models import DigestType
40+
3841
return cls(algorithm=DigestType.dandi_etag, value=value)
3942

4043
@classmethod
@@ -43,6 +46,8 @@ def dandi_zarr(cls, value: str) -> Digest:
4346
Construct a `Digest` with the given value and a ``algorithm`` of
4447
``DigestType.dandi_zarr_checksum``
4548
"""
49+
from dandischema.models import DigestType
50+
4651
return cls(algorithm=DigestType.dandi_zarr_checksum, value=value)
4752

4853
def asdict(self) -> dict[DigestType, str]:
@@ -57,11 +62,15 @@ def asdict(self) -> dict[DigestType, str]:
5762
#: not actually relevant and would be too expensive to calculate
5863
@cache
5964
def get_dummy_dandi_etag() -> Digest:
65+
from dandischema.models import DigestType
66+
6067
return Digest(algorithm=DigestType.dandi_etag, value=32 * "d" + "-1")
6168

6269

6370
@cache
6471
def get_dummy_dandi_zarr_checksum() -> Digest:
72+
from dandischema.models import DigestType
73+
6574
return Digest(algorithm=DigestType.dandi_zarr_checksum, value=32 * "d" + "-1--1")
6675

6776

0 commit comments

Comments
 (0)