1414from functools import cache
1515import os .path
1616from 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
5964def 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
6471def 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