Ty

Type annotations are unfortunately bulky. Yuio provides shortcuts for common annotated types such as positive ints or non-empty containers.

type yuio.ty.PosInt = Annotated[int, Gt(0)]

Positive int.

type yuio.ty.NonNegInt = Annotated[int, Ge(0)]

Non-negative int.

type yuio.ty.PosFloat = Annotated[float, Gt(0)]

Positive float.

type yuio.ty.NonNegFloat = Annotated[float, Ge(0)]

Non-negative float.

type yuio.ty.NonEmptyStr = Annotated[str, LenGt(0)]

Non-empty string.

type yuio.ty.NonEmptyList = Annotated[list[T], LenGt(0)]

Non-empty list.

type yuio.ty.NonEmptySet = Annotated[set[T], LenGt(0)]

Non-empty set.

type yuio.ty.NonEmptyFrozenSet = Annotated[frozenset[T], LenGt(0)]

Non-empty frozenset.

type yuio.ty.NonEmptyDict = Annotated[dict[K, V], LenGt(0)]

Non-empty dict.

type yuio.ty.Pair = Annotated[tuple[K, V], Tuple(delimiter=':')]

Colon-separated pair of values.

type yuio.ty.Path = pathlib.Path

Filepath.

type yuio.ty.NonExistentPath = Annotated[Path, NonExistentPath]

Filepath not pointing to an existing file or directory.

type yuio.ty.ExistingPath = Annotated[Path, ExistingPath]

Filepath pointing to an existing file or directory.

type yuio.ty.File = Annotated[Path, File]

Filepath pointing to an existing regular file.

type yuio.ty.Dir = Annotated[Path, Dir]

Filepath pointing to an existing directory.

type yuio.ty.GitRepo = Annotated[Path, GitRepo]

Filepath pointing to an existing directory that has .git sub-directory.

type yuio.ty.TimeDelta = timedelta

Time delta.

type yuio.ty.PosTimeDelta = Annotated[TimeDelta, Gt(timedelta(0))]

Positive time delta.

type yuio.ty.NonNegTimeDelta = Annotated[TimeDelta, Ge(timedelta(0))]

Non-negative time delta.

type yuio.ty.Seconds = Annotated[timedelta, Seconds()]

Timedelta that’s parsed from int as number of seconds.

type yuio.ty.PosSeconds = Annotated[Seconds, Gt(timedelta(0))]

Positive number of seconds.

type yuio.ty.NonNegSeconds = Annotated[Seconds, Ge(timedelta(0))]

Non-negative number of seconds.

Re-imports

type yuio.ty.JsonValue

Alias of yuio.json_schema.JsonValue.

type yuio.ty.SecretString

Alias of yuio.secret.SecretString.

type yuio.ty.SecretValue

Alias of yuio.secret.SecretValue.