|
9 | 9 |
|
10 | 10 | from bioimageio.spec._internal.constants import DOI_REGEX, SI_UNIT_REGEX |
11 | 11 | from bioimageio.spec._internal.types._file_source import AbsoluteFilePath as AbsoluteFilePath |
| 12 | +from bioimageio.spec._internal.types._file_source import FileName as FileName |
12 | 13 | from bioimageio.spec._internal.types._file_source import FileSource as FileSource |
| 14 | +from bioimageio.spec._internal.types._file_source import PermissiveFileSource as PermissiveFileSource |
13 | 15 | from bioimageio.spec._internal.types._file_source import RelativeFilePath as RelativeFilePath |
| 16 | +from bioimageio.spec._internal.types._file_source import StrictFileSource as StrictFileSource |
14 | 17 | from bioimageio.spec._internal.types._generated_spdx_license_type import DeprecatedLicenseId as DeprecatedLicenseId |
15 | 18 | from bioimageio.spec._internal.types._generated_spdx_license_type import LicenseId as LicenseId |
16 | 19 | from bioimageio.spec._internal.types._version import Version as Version |
|
23 | 26 | validate_orcid_id, |
24 | 27 | ) |
25 | 28 |
|
26 | | -T = TypeVar("T") |
27 | 29 | S = TypeVar("S", bound=Sequence[Any]) |
28 | | - |
29 | 30 | NotEmpty = Annotated[S, annotated_types.MinLen(1)] |
30 | 31 |
|
31 | 32 | Datetime = Annotated[datetime, BeforeValidator(validate_datetime)] |
32 | 33 | """Timestamp in [ISO 8601](#https://en.wikipedia.org/wiki/ISO_8601) format |
33 | 34 | with a few restrictions listed [here](https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat).""" |
34 | 35 |
|
| 36 | +Doi = NewType("Doi", Annotated[str, StringConstraints(pattern=DOI_REGEX)]) |
| 37 | +FormatVersionPlaceholder = Literal["latest", "discover"] |
35 | 38 | IdentifierStr = Annotated[ # allows to init child NewTypes with str |
36 | 39 | NotEmpty[str], |
37 | 40 | AfterValidator(validate_identifier), |
|
40 | 43 | Identifier = NewType("Identifier", IdentifierStr) |
41 | 44 | LowerCaseIdentifierStr = Annotated[IdentifierStr, annotated_types.LowerCase] # allows to init child NewTypes with str |
42 | 45 | LowerCaseIdentifier = NewType("LowerCaseIdentifier", LowerCaseIdentifierStr) |
| 46 | +OrcidId = NewType("OrcidId", Annotated[str, AfterValidator(validate_orcid_id)]) |
43 | 47 | ResourceId = NewType( |
44 | 48 | "ResourceId", |
45 | 49 | Annotated[ |
|
48 | 52 | annotated_types.Predicate(lambda s: "\\" not in s and s[0] != "/" and s[-1] != "/"), |
49 | 53 | ], |
50 | 54 | ) |
51 | | -DatasetId = NewType("DatasetId", ResourceId) |
52 | | -FileName = str |
53 | | -OrcidId = NewType("OrcidId", Annotated[str, AfterValidator(validate_orcid_id)]) |
54 | 55 | Sha256 = NewType("Sha256", Annotated[str, annotated_types.Len(64, 64)]) |
55 | | - |
56 | 56 | SiUnit = NewType( |
57 | 57 | "SiUnit", |
58 | 58 | Annotated[ |
|
62 | 62 | ], |
63 | 63 | ) |
64 | 64 | Unit = Union[Literal["arbitrary unit", "px"], SiUnit] |
65 | | -FormatVersionPlaceholder = Literal["latest", "discover"] |
66 | | - |
67 | 65 |
|
68 | 66 | # types as loaded from YAML 1.2 (with ruamel.yaml) |
69 | 67 | YamlLeafValue = Union[bool, date, datetime, float, int, str, None] |
|
76 | 74 | # and don't open another issue a la https://github.com/pydantic/pydantic/issues/8021 |
77 | 75 | YamlValue = Union[YamlLeafValue, YamlArray, YamlMapping] |
78 | 76 |
|
| 77 | +# derived types |
| 78 | +DatasetId = NewType("DatasetId", ResourceId) |
79 | 79 | RdfContent = Dict[str, YamlValue] |
80 | | -Doi = NewType("Doi", Annotated[str, StringConstraints(pattern=DOI_REGEX)]) |
0 commit comments