chore: typing

This commit is contained in:
ducklet 2024-05-19 22:49:46 +02:00
parent b0f5ec4cc9
commit dd39849b8d
5 changed files with 82 additions and 57 deletions

View file

@ -1,9 +1,13 @@
import re
from typing import cast
from typing import NewType, cast
import ulid
from ulid.hints import Buffer
type JSONScalar = int | float | str | None
type JSON = JSONScalar | list["JSON"] | dict[str, "JSON"]
type JSONObject = dict[str, JSON]
class ULID(ulid.ULID):
"""Extended ULID type.
@ -29,3 +33,14 @@ class ULID(ulid.ULID):
buffer = cast(memoryview, ulid.new().memory)
super().__init__(buffer)
AwardId = NewType("AwardId", ULID)
GroupId = NewType("GroupId", ULID)
ImdbMovieId = NewType("ImdbMovieId", str)
MovieId = NewType("MovieId", ULID)
MovieIdStr = NewType("MovieIdStr", str)
RatingId = NewType("RatingId", ULID)
Score100 = NewType("Score100", int) # [0, 100]
UserId = NewType("UserId", ULID)
UserIdStr = NewType("UserIdStr", str)