aioe621 0.2.1__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioe621
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: A simple asynchronous httpx+pydantic wrapper over the E621's API
5
5
  Keywords: async,httpx,e621
6
6
  Author: penggrin12
@@ -58,12 +58,13 @@ from aioe621 import Client, Auth
58
58
  from aioe621.schemas import Post
59
59
  import asyncio
60
60
 
61
+ # authentication is only needed for some endpoints
61
62
  auth = Auth(
62
63
  username="hexerade",
63
64
  api_key="1nHrmzmsvJf26EhU1F7CjnjC",
64
65
  )
65
66
 
66
- # all parameters are optional
67
+ # all other Client parameters are also optional
67
68
  client = Client(
68
69
  auth=auth,
69
70
  user_agent="MyProject/1.0 (by username on e621)"
@@ -14,12 +14,13 @@ from aioe621 import Client, Auth
14
14
  from aioe621.schemas import Post
15
15
  import asyncio
16
16
 
17
+ # authentication is only needed for some endpoints
17
18
  auth = Auth(
18
19
  username="hexerade",
19
20
  api_key="1nHrmzmsvJf26EhU1F7CjnjC",
20
21
  )
21
22
 
22
- # all parameters are optional
23
+ # all other Client parameters are also optional
23
24
  client = Client(
24
25
  auth=auth,
25
26
  user_agent="MyProject/1.0 (by username on e621)"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aioe621"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "A simple asynchronous httpx+pydantic wrapper over the E621's API"
5
5
  license = { file = "LICENSE" }
6
6
  readme = "README.md"
@@ -36,4 +36,5 @@ build-backend = "uv_build"
36
36
  dev = [
37
37
  "ruff>=0.15.21",
38
38
  "pyrefly>=0.60.0",
39
+ "respx>=0.23.1",
39
40
  ]
@@ -0,0 +1,11 @@
1
+ from aioe621 import client, exceptions, schemas
2
+ from aioe621.client import Client
3
+ from aioe621.schemas import Auth
4
+
5
+ __all__: tuple[str, ...] = (
6
+ "client",
7
+ "exceptions",
8
+ "schemas",
9
+ "Client",
10
+ "Auth",
11
+ )
@@ -3,11 +3,14 @@
3
3
  import httpx
4
4
  from pydantic import BaseModel
5
5
 
6
- from aioe621.exceptions import AccessDeniedError
7
-
8
- from .endpoints.posts import Posts
9
- from .exceptions import APIError, AuthenticationError, NotFoundError
10
- from .schemas import _ErrorResponse
6
+ from aioe621 import endpoints
7
+ from aioe621.exceptions import (
8
+ AccessDeniedError,
9
+ APIError,
10
+ AuthenticationError,
11
+ NotFoundError,
12
+ )
13
+ from aioe621.schemas import _ErrorResponse
11
14
 
12
15
  if typing.TYPE_CHECKING:
13
16
  from .schemas import Auth
@@ -35,7 +38,7 @@ class Client:
35
38
  **session_kwargs,
36
39
  )
37
40
 
38
- self.posts = Posts(self)
41
+ self.posts = endpoints.Posts(self)
39
42
 
40
43
  def _get_headers(self) -> dict[str, str]:
41
44
  return {"User-Agent": self.user_agent}
@@ -0,0 +1,3 @@
1
+ from .posts import Posts
2
+
3
+ __all__: tuple[str, ...] = ("Posts",)
@@ -1,7 +1,7 @@
1
1
  import typing
2
2
 
3
3
  if typing.TYPE_CHECKING:
4
- from ..client import Client
4
+ from aioe621.client import Client
5
5
 
6
6
 
7
7
  class Endpoint:
@@ -1,15 +1,17 @@
1
- from ..schemas import Post, _PostsListResponse, _PostsOnePostResponse
2
- from .endpoint import Endpoint
1
+ from typing import Iterable
2
+
3
+ from aioe621.endpoints.endpoint import Endpoint
4
+ from aioe621.schemas import Post, _PostsListResponse, _PostsOnePostResponse
3
5
 
4
6
 
5
7
  class Posts(Endpoint):
6
8
  async def list(
7
9
  self,
8
- tags: list[str] | str,
10
+ tags: Iterable[str] | str,
9
11
  limit: int | None = None,
10
12
  page: int | None = None,
11
- ) -> list[Post]:
12
- if isinstance(tags, list):
13
+ ) -> tuple[Post, ...]:
14
+ if not isinstance(tags, str):
13
15
  tags = " ".join(tags)
14
16
 
15
17
  return (
@@ -23,6 +25,8 @@ class Posts(Endpoint):
23
25
  )
24
26
  ).posts
25
27
 
28
+ search = list
29
+
26
30
  async def get(
27
31
  self,
28
32
  id: int,
@@ -1,4 +1,15 @@
1
- import httpx
1
+ import typing
2
+
3
+ if typing.TYPE_CHECKING:
4
+ from httpx import Response
5
+
6
+ __all__: list[str] = [
7
+ "WrapperError",
8
+ "AuthenticationError",
9
+ "APIError",
10
+ "NotFoundError",
11
+ "AccessDeniedError",
12
+ ]
2
13
 
3
14
 
4
15
  class WrapperError(Exception):
@@ -16,7 +27,7 @@ class AuthenticationError(WrapperError):
16
27
 
17
28
 
18
29
  class APIError(Exception):
19
- def __init__(self, message: str, response: httpx.Response) -> None:
30
+ def __init__(self, message: str, response: "Response") -> None:
20
31
  self.method = response.request.method
21
32
  self.url = response.request.url
22
33
  super().__init__(
@@ -25,10 +36,10 @@ class APIError(Exception):
25
36
 
26
37
 
27
38
  class NotFoundError(APIError):
28
- def __init__(self, response: httpx.Response) -> None:
39
+ def __init__(self, response: "Response") -> None:
29
40
  super().__init__("Not found.", response)
30
41
 
31
42
 
32
43
  class AccessDeniedError(APIError):
33
- def __init__(self, response: httpx.Response) -> None:
44
+ def __init__(self, response: "Response") -> None:
34
45
  super().__init__("Access denied.", response)
@@ -32,7 +32,7 @@ class PreviewFile(BaseFile):
32
32
 
33
33
 
34
34
  class VideoAlternate(APIModel):
35
- fps: int
35
+ fps: float
36
36
  codec: str
37
37
  size: int
38
38
  width: int
@@ -1,4 +0,0 @@
1
- from .client import Client
2
- from .schemas import Auth
3
-
4
- __all__ = ["Client", "Auth"]
File without changes
File without changes
File without changes