Skip to content

Commit

Permalink
feat!: Literal 参数转为全大写
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Jan 23, 2025
1 parent 3fd9e35 commit f1a6770
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions jkit/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ async def iter_comments(
self,
*,
start_page: int = 1,
direction: Literal["asc", "desc"] = "desc",
direction: Literal["ASC", "DESC"] = "DESC",
author_only: bool = False,
page_size: int = 10,
) -> AsyncGenerator[ArticleCommentInfo, None]:
Expand All @@ -398,7 +398,7 @@ async def iter_comments(
path=f"/shakespeare/notes/{await self.id}/comments",
params={
"page": now_page,
"order_by": direction,
"order_by": direction.lower(),
"author_only": author_only,
"count": page_size,
},
Expand Down
8 changes: 4 additions & 4 deletions jkit/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def iter_articles(
self,
*,
start_page: int = 1,
order_by: Literal["add_time", "last_comment_time", "popularity"] = "add_time",
order_by: Literal["ADD_TIME", "LAST_COMMENT_TIME", "POPULARITY"] = "ADD_TIME",
page_size: int = 20,
) -> AsyncGenerator[CollectionArticleInfo, None]:
await self._auto_check()
Expand All @@ -176,9 +176,9 @@ async def iter_articles(
"page": now_page,
"count": page_size,
"ordered_by": {
"add_time": "time",
"last_comment_time": "comment_time",
"popularity": "hot",
"ADD_TIME": "time",
"LAST_COMMENT_TIME": "comment_time",
"POPULARITY": "hot",
}[order_by],
},
) # type: ignore
Expand Down
6 changes: 3 additions & 3 deletions jkit/jpep/ftn_macket.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FTNMacket(ResourceObject):
async def iter_orders(
self,
*,
type: Literal["buy", "sell"],
type: Literal["BUY", "SELL"],
start_page: int = 1,
) -> AsyncGenerator[FTNMacketOrderRecord, None]:
now_page = start_page
Expand All @@ -62,12 +62,12 @@ async def iter_orders(
params={"page": now_page},
json={
"filter": [
{"trade": 1 if type == "buy" else 0},
{"trade": 1 if type == "BUY" else 0},
{"status": 1},
{"finish": 0},
{"tradable": {">": "0"}},
],
"sort": "price,pub_date" if type == "buy" else "-price,pub_date",
"sort": "price,pub_date" if type == "BUY" else "-price,pub_date",
"bind": [
{
"member.user": {
Expand Down
6 changes: 3 additions & 3 deletions jkit/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def iter_articles(
self,
*,
start_page: int = 1,
order_by: Literal["add_time", "last_comment_time"] = "add_time",
order_by: Literal["ADD_TIME", "LAST_COMMENT_TIME"] = "ADD_TIME",
page_size: int = 20,
) -> AsyncGenerator[NotebookArticleInfo, None]:
await self._auto_check()
Expand All @@ -173,8 +173,8 @@ async def iter_articles(
"page": now_page,
"count": page_size,
"order_by": {
"add_time": "added_at",
"last_comment_time": "commented_at",
"ADD_TIME": "added_at",
"LAST_COMMENT_TIME": "commented_at",
}[order_by],
},
) # type: ignore
Expand Down
10 changes: 5 additions & 5 deletions jkit/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ async def iter_articles(
*,
start_page: int = 1,
order_by: Literal[
"published_at", "last_comment_time", "popularity"
] = "published_at",
"PUBLISHED_AT", "LAST_COMMENT_TIME", "POPULARITY"
] = "PUBLISHED_AT",
page_size: int = 10,
) -> AsyncGenerator[UserArticleInfo, None]:
await self._auto_check()
Expand All @@ -374,9 +374,9 @@ async def iter_articles(
"page": now_page,
"count": page_size,
"order_by": {
"published_at": "shared_at",
"last_comment_time": "commented_at",
"popularity": "top",
"PUBLISHED_AT": "shared_at",
"LAST_COMMENT_TIME": "commented_at",
"POPULARITY": "top",
}[order_by],
},
) # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1a6770

Please sign in to comment.