Skip to content

Commit

Permalink
feat: 公开 Msgspec 约束模块供外部使用
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Mar 14, 2024
1 parent 69380ce commit 389a8eb
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 66 deletions.
22 changes: 11 additions & 11 deletions jkit/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@
ResourceObject,
SlugAndUrlObject,
)
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import (
normalize_assets_amount,
normalize_datetime,
normalize_percentage,
)
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_article_slug
from jkit.identifier_convert import article_slug_to_url, article_url_to_slug
from jkit.msgspec_constraints import (
CollectionSlug,
NonEmptyStr,
NonNegativeFloat,
Expand All @@ -36,16 +46,6 @@
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import (
normalize_assets_amount,
normalize_datetime,
normalize_percentage,
)
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_article_slug
from jkit.identifier_convert import article_slug_to_url, article_url_to_slug

if TYPE_CHECKING:
from jkit.collection import Collection
Expand Down
14 changes: 7 additions & 7 deletions jkit/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
ResourceObject,
SlugAndUrlObject,
)
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount, normalize_datetime
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_collection_slug
from jkit.identifier_convert import collection_slug_to_url, collection_url_to_slug
from jkit.msgspec_constraints import (
ArticleSlug,
CollectionSlug,
NonEmptyStr,
Expand All @@ -29,12 +35,6 @@
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount, normalize_datetime
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_collection_slug
from jkit.identifier_convert import collection_slug_to_url, collection_url_to_slug

if TYPE_CHECKING:
from jkit.article import Article
Expand Down
2 changes: 1 addition & 1 deletion jkit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from msgspec import Struct, convert, field, to_builtins
from typing_extensions import Self

from jkit._constraints import NonEmptyStr
from jkit.msgspec_constraints import NonEmptyStr


class ConfigObject(Struct):
Expand Down
8 changes: 4 additions & 4 deletions jkit/jianshu_lottery.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from typing import TYPE_CHECKING, Any, AsyncGenerator, Dict, List

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import normalize_datetime
from jkit.config import CONFIG
from jkit.msgspec_constraints import (
NonEmptyStr,
NormalizedDatetime,
PositiveInt,
UserName,
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import normalize_datetime
from jkit.config import CONFIG

if TYPE_CHECKING:
from jkit.user import User
Expand Down
8 changes: 4 additions & 4 deletions jkit/jpep/ftn_macket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
from typing import AsyncGenerator, Literal, Optional, Tuple

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import (
from jkit._network_request import send_post
from jkit._normalization import normalize_datetime
from jkit.config import CONFIG
from jkit.msgspec_constraints import (
NonEmptyStr,
NonNegativeInt,
NormalizedDatetime,
PositiveFloat,
PositiveInt,
)
from jkit._network_request import send_post
from jkit._normalization import normalize_datetime
from jkit.config import CONFIG


class PaymentChannels(Enum):
Expand Down
2 changes: 1 addition & 1 deletion jkit/jpep/platform_settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import NonNegativeFloat
from jkit._network_request import send_post
from jkit.config import CONFIG
from jkit.msgspec_constraints import NonNegativeFloat


class PlatformSettingsData(DataObject, **DATA_OBJECT_CONFIG):
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions jkit/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
IdAndUrlObject,
ResourceObject,
)
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount, normalize_datetime
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_notebook_id
from jkit.identifier_convert import notebook_id_to_url
from jkit.msgspec_constraints import (
ArticleSlug,
NonEmptyStr,
NonNegativeFloat,
Expand All @@ -22,12 +28,6 @@
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount, normalize_datetime
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.identifier_check import is_notebook_id
from jkit.identifier_convert import notebook_id_to_url

if TYPE_CHECKING:
from jkit.article import Article
Expand Down
14 changes: 7 additions & 7 deletions jkit/private/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
from msgspec import DecodeError

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import (
NonEmptyStr,
NonNegativeFloat,
NormalizedDatetime,
Percentage,
PositiveInt,
)
from jkit._network_request import JSON_DECODER, get_json, send_post
from jkit._normalization import (
normalize_assets_amount,
Expand All @@ -24,6 +17,13 @@
from jkit.config import CONFIG
from jkit.credential import JianshuCredential
from jkit.exceptions import BalanceNotEnoughError, WeeklyConvertLimitExceededError
from jkit.msgspec_constraints import (
NonEmptyStr,
NonNegativeFloat,
NormalizedDatetime,
Percentage,
PositiveInt,
)


class AssetsTransactionRecord(DataObject, **DATA_OBJECT_CONFIG):
Expand Down
10 changes: 5 additions & 5 deletions jkit/ranking/article_earning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
from typing import TYPE_CHECKING, AsyncGenerator, Optional, Tuple

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount
from jkit.config import CONFIG
from jkit.exceptions import APIUnsupportedError
from jkit.msgspec_constraints import (
ArticleSlug,
NonEmptyStr,
PositiveFloat,
PositiveInt,
UserName,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount
from jkit.config import CONFIG
from jkit.exceptions import APIUnsupportedError

if TYPE_CHECKING:
from jkit.article import Article
Expand Down
12 changes: 6 additions & 6 deletions jkit/ranking/assets.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from typing import TYPE_CHECKING, AsyncGenerator, Optional

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount
from jkit.config import CONFIG
from jkit.constants import MAX_ID
from jkit.exceptions import ResourceUnavailableError
from jkit.msgspec_constraints import (
NonNegativeFloat,
PositiveInt,
UserName,
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount
from jkit.config import CONFIG
from jkit.constants import MAX_ID
from jkit.exceptions import ResourceUnavailableError

if TYPE_CHECKING:
from jkit.user import User
Expand Down
2 changes: 1 addition & 1 deletion jkit/ranking/daily_update.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import TYPE_CHECKING, AsyncGenerator

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import PositiveInt, UserName, UserSlug, UserUploadedUrl
from jkit._network_request import get_json
from jkit.config import CONFIG
from jkit.msgspec_constraints import PositiveInt, UserName, UserSlug, UserUploadedUrl

if TYPE_CHECKING:
from jkit.user import User
Expand Down
10 changes: 5 additions & 5 deletions jkit/ranking/user_earning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
from typing import TYPE_CHECKING, AsyncGenerator, Literal, Optional, Tuple

from jkit._base import DATA_OBJECT_CONFIG, DataObject, ResourceObject
from jkit._constraints import (
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount
from jkit.config import CONFIG
from jkit.exceptions import APIUnsupportedError
from jkit.msgspec_constraints import (
NonNegativeFloat,
PositiveFloat,
PositiveInt,
UserName,
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_json
from jkit._normalization import normalize_assets_amount
from jkit.config import CONFIG
from jkit.exceptions import APIUnsupportedError

if TYPE_CHECKING:
from jkit.user import User
Expand Down
14 changes: 7 additions & 7 deletions jkit/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
ResourceObject,
SlugAndUrlObject,
)
from jkit._constraints import (
from jkit._network_request import get_html, get_json
from jkit._normalization import normalize_assets_amount, normalize_datetime
from jkit.config import CONFIG
from jkit.exceptions import APIUnsupportedError, ResourceUnavailableError
from jkit.identifier_check import is_user_slug
from jkit.identifier_convert import user_slug_to_url, user_url_to_slug
from jkit.msgspec_constraints import (
ArticleSlug,
CollectionSlug,
NonEmptyStr,
Expand All @@ -31,12 +37,6 @@
UserSlug,
UserUploadedUrl,
)
from jkit._network_request import get_html, get_json
from jkit._normalization import normalize_assets_amount, normalize_datetime
from jkit.config import CONFIG
from jkit.exceptions import APIUnsupportedError, ResourceUnavailableError
from jkit.identifier_check import is_user_slug
from jkit.identifier_convert import user_slug_to_url, user_url_to_slug

if TYPE_CHECKING:
from jkit.article import Article
Expand Down

0 comments on commit 389a8eb

Please sign in to comment.