satori-python 0.17.1__tar.gz → 0.17.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.
Files changed (29) hide show
  1. {satori_python-0.17.1 → satori_python-0.17.3}/PKG-INFO +2 -1
  2. {satori_python-0.17.1 → satori_python-0.17.3}/README.md +1 -0
  3. {satori_python-0.17.1 → satori_python-0.17.3}/pyproject.toml +6 -4
  4. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/__init__.py +1 -1
  5. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/account.py +4 -3
  6. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/account.pyi +4 -3
  7. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/parser.py +1 -1
  8. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/__init__.py +13 -3
  9. {satori_python-0.17.1 → satori_python-0.17.3}/LICENSE +0 -0
  10. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/__init__.py +0 -0
  11. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/config.py +0 -0
  12. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/network/__init__.py +0 -0
  13. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/network/base.py +0 -0
  14. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/network/util.py +0 -0
  15. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/network/webhook.py +0 -0
  16. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/network/websocket.py +0 -0
  17. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/client/protocol.py +0 -0
  18. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/const.py +0 -0
  19. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/element.py +0 -0
  20. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/event.py +0 -0
  21. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/exception.py +0 -0
  22. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/model.py +0 -0
  23. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/adapter.py +0 -0
  24. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/connection.py +0 -0
  25. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/formdata.py +0 -0
  26. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/model.py +0 -0
  27. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/route.py +0 -0
  28. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/server/utils.py +0 -0
  29. {satori_python-0.17.1 → satori_python-0.17.3}/src/satori/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python
3
- Version: 0.17.1
3
+ Version: 0.17.3
4
4
  Summary: Satori Protocol SDK for python
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -84,6 +84,7 @@ pip install satori-python-server
84
84
  | Satori | `pip install satori-python-adapter-satori` | satori.adapters.satori |
85
85
  | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
86
86
  | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
87
+ | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook |
87
88
 
88
89
  ### 社区适配器
89
90
 
@@ -52,6 +52,7 @@ pip install satori-python-server
52
52
  | Satori | `pip install satori-python-adapter-satori` | satori.adapters.satori |
53
53
  | OneBot V11 | `pip install satori-python-adapter-onebot11` | satori.adapters.onebot11.forward, satori.adapters.onebot11.reverse |
54
54
  | Console | `pip install satori-python-adapter-console` | satori.adapters.console |
55
+ | Milky | `pip install satori-python-adapter-milky` | satori.adapters.milky.main, satori.adapters.milky.webhook |
55
56
 
56
57
  ### 社区适配器
57
58
 
@@ -29,7 +29,7 @@ classifiers = [
29
29
  "Programming Language :: Python :: 3.12",
30
30
  "Operating System :: OS Independent",
31
31
  ]
32
- version = "0.17.1"
32
+ version = "0.17.3"
33
33
 
34
34
  [project.license]
35
35
  text = "MIT"
@@ -75,7 +75,7 @@ excludes = [
75
75
  composite = [
76
76
  "isort ./src/ ./example/",
77
77
  "black ./src/ ./example/",
78
- "ruff check ./src/ ./example/",
78
+ "ruff check",
79
79
  ]
80
80
 
81
81
  [tool.pdm.version]
@@ -99,7 +99,9 @@ extra_standard_library = [
99
99
  line-length = 120
100
100
  target-version = "py310"
101
101
  exclude = [
102
- "exam.py",
102
+ "exam_qps.py",
103
+ "exam1.py",
104
+ "exam2.py",
103
105
  ]
104
106
 
105
107
  [tool.ruff.lint]
@@ -117,7 +119,7 @@ ignore = [
117
119
  "F403",
118
120
  "F405",
119
121
  "C901",
120
- "UP038",
122
+ "T201",
121
123
  ]
122
124
 
123
125
  [tool.pyright]
@@ -42,4 +42,4 @@ from .model import Role as Role
42
42
  from .model import Upload as Upload
43
43
  from .model import User as User
44
44
 
45
- __version__ = "0.17.1"
45
+ __version__ = "0.17.3"
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import asyncio
4
- from dataclasses import dataclass
4
+ from dataclasses import dataclass, field
5
5
  from typing_extensions import Generic, TypeVar # noqa: UP035
6
6
 
7
7
  from yarl import URL
@@ -10,8 +10,8 @@ from satori.model import Login
10
10
 
11
11
  from .protocol import ApiProtocol
12
12
 
13
- TP = TypeVar("TP", bound="ApiProtocol", default=ApiProtocol)
14
- TP1 = TypeVar("TP1", bound="ApiProtocol", default=ApiProtocol)
13
+ TP = TypeVar("TP", bound="ApiProtocol", default=ApiProtocol, covariant=True)
14
+ TP1 = TypeVar("TP1", bound="ApiProtocol", default=ApiProtocol, covariant=True)
15
15
 
16
16
 
17
17
  @dataclass
@@ -21,6 +21,7 @@ class ApiInfo:
21
21
  path: str = ""
22
22
  token: str | None = None
23
23
  timeout: float | None = None
24
+ api_base: URL = field(init=False)
24
25
 
25
26
  def __post_init__(self):
26
27
  if self.path and not self.path.startswith("/"):
@@ -26,8 +26,8 @@ from satori.model import (
26
26
 
27
27
  from .protocol import ApiProtocol
28
28
 
29
- TP = TypeVar("TP", bound="ApiProtocol", default=ApiProtocol)
30
- TP1 = TypeVar("TP1", bound="ApiProtocol", default=ApiProtocol)
29
+ TP = TypeVar("TP", bound="ApiProtocol", default=ApiProtocol, covariant=True)
30
+ TP1 = TypeVar("TP1", bound="ApiProtocol", default=ApiProtocol, covariant=True)
31
31
 
32
32
  class Api(Protocol):
33
33
  token: str | None = None
@@ -42,7 +42,8 @@ class ApiInfo(Api):
42
42
  path: str = "",
43
43
  token: str | None = None,
44
44
  timeout: float | None = None,
45
- ): ...
45
+ ):
46
+ self.api_base: URL = ...
46
47
 
47
48
  class Account(Generic[TP]):
48
49
  adapter: str
@@ -306,7 +306,7 @@ def parse_tokens(tokens: list[str | Token], context: dict | None = None) -> list
306
306
  while mat := attr_pat.search(token.extra):
307
307
  key = mat.group(1)
308
308
  groupdict = mat.groupdict()
309
- v2 = groupdict.get("value2", groupdict.get("value1"))
309
+ v2 = groupdict.get("value2") or groupdict.get("value1")
310
310
  curly = groupdict.get("curly")
311
311
  if curly and context is not None:
312
312
  attrs[key] = interpolate(curly, context)
@@ -60,6 +60,16 @@ _T_ws_endpoint = TypeVar("_T_ws_endpoint", bound=Callable[[WebSocket], Awaitable
60
60
  StarletteResponse = Response
61
61
 
62
62
 
63
+ async def _json(self: StarletteRequest) -> Any:
64
+ if not hasattr(self, "_json"):
65
+ body = await self.body()
66
+ self._json = decode(body)
67
+ return self._json
68
+
69
+
70
+ StarletteRequest.json = _json
71
+
72
+
63
73
  async def _request_handler(action: str, request: StarletteRequest, func: RouteCall, platform: str, self_id: str):
64
74
  if action == Api.UPLOAD_CREATE.value:
65
75
  async with request.form() as form:
@@ -78,7 +88,7 @@ async def _request_handler(action: str, request: StarletteRequest, func: RouteCa
78
88
  Request(
79
89
  request,
80
90
  action,
81
- decode(await request.body()),
91
+ await request.json(),
82
92
  platform=platform,
83
93
  self_id=self_id,
84
94
  )
@@ -407,7 +417,7 @@ class Server(Service, RouterMixin):
407
417
  return JSONResponse(content=Meta(logins, proxy_urls).dump())
408
418
 
409
419
  async def webhook_create_handler(self, request: StarletteRequest):
410
- body = decode(await request.body())
420
+ body = await request.json()
411
421
  url = body["url"]
412
422
  token = body.get("token")
413
423
  self.webhooks.append(WebhookEndpoint(url, token))
@@ -427,7 +437,7 @@ class Server(Service, RouterMixin):
427
437
  return Response()
428
438
 
429
439
  async def webhook_delete_handler(self, request: StarletteRequest):
430
- body = decode(await request.body())
440
+ body = await request.json()
431
441
  url = body["url"]
432
442
  for endpoint in self.webhooks:
433
443
  if endpoint.url == url:
File without changes