Coverage for bioimageio/spec/_internal/io_basics.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-02-05 13:53 +0000

1from pathlib import Path 

2from typing import Any, ClassVar, Type 

3 

4import pydantic 

5import zipp 

6from annotated_types import Predicate 

7from pydantic import RootModel, StringConstraints 

8from typing_extensions import Annotated 

9 

10from .validated_string import ValidatedString 

11 

12FileName = str 

13FilePath = Annotated[pydantic.FilePath, pydantic.Field(title="FilePath")] 

14AbsoluteDirectory = Annotated[ 

15 pydantic.DirectoryPath, 

16 Predicate(Path.is_absolute), 

17 pydantic.Field(title="AbsoluteDirectory"), 

18] 

19AbsoluteFilePath = Annotated[ 

20 pydantic.FilePath, 

21 Predicate(Path.is_absolute), 

22 pydantic.Field(title="AbsoluteFilePath"), 

23] 

24 

25BIOIMAGEIO_YAML = "rdf.yaml" 

26ALTERNATIVE_BIOIMAGEIO_YAML_NAMES = ("bioimageio.yaml", "model.yaml") 

27ALL_BIOIMAGEIO_YAML_NAMES = (BIOIMAGEIO_YAML,) + ALTERNATIVE_BIOIMAGEIO_YAML_NAMES 

28 

29ZipPath = zipp.Path # not zipfile.Path due to https://bugs.python.org/issue40564 

30 

31 

32class Sha256(ValidatedString): 

33 """A SHA-256 hash value""" 

34 

35 root_model: ClassVar[Type[RootModel[Any]]] = RootModel[ 

36 Annotated[ 

37 str, 

38 StringConstraints( 

39 strip_whitespace=True, to_lower=True, min_length=64, max_length=64 

40 ), 

41 ] 

42 ]