From f1a6770dac6ce64491b4ce5d1df595169d097d59 Mon Sep 17 00:00:00 2001 From: FHU-yezi Date: Thu, 23 Jan 2025 23:22:47 +0800 Subject: [PATCH] =?UTF-8?q?feat!:=20`Literal`=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E8=BD=AC=E4=B8=BA=E5=85=A8=E5=A4=A7=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jkit/article.py | 4 ++-- jkit/collection.py | 8 ++++---- jkit/jpep/ftn_macket.py | 6 +++--- jkit/notebook.py | 6 +++--- jkit/user.py | 10 +++++----- uv.lock | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/jkit/article.py b/jkit/article.py index 3b03ed6..5b14184 100644 --- a/jkit/article.py +++ b/jkit/article.py @@ -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]: @@ -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, }, diff --git a/jkit/collection.py b/jkit/collection.py index dc63d07..b5d9f4e 100644 --- a/jkit/collection.py +++ b/jkit/collection.py @@ -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() @@ -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 diff --git a/jkit/jpep/ftn_macket.py b/jkit/jpep/ftn_macket.py index 7487881..f2ef483 100644 --- a/jkit/jpep/ftn_macket.py +++ b/jkit/jpep/ftn_macket.py @@ -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 @@ -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": { diff --git a/jkit/notebook.py b/jkit/notebook.py index 67553d5..b720342 100644 --- a/jkit/notebook.py +++ b/jkit/notebook.py @@ -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() @@ -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 diff --git a/jkit/user.py b/jkit/user.py index be3a507..fb1bfd5 100644 --- a/jkit/user.py +++ b/jkit/user.py @@ -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() @@ -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 diff --git a/uv.lock b/uv.lock index e648f29..e2243eb 100644 --- a/uv.lock +++ b/uv.lock @@ -118,7 +118,7 @@ wheels = [ [[package]] name = "jkit" -version = "3.0.0a16" +version = "3.0.0b1" source = { editable = "." } dependencies = [ { name = "httpx", extra = ["http2"] },