satori-python-core 0.11.0__tar.gz → 0.11.2__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.1
2
2
  Name: satori-python-core
3
- Version: 0.11.0
3
+ Version: 0.11.2
4
4
  Summary: Satori Protocol SDK for python, specify common part
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -23,7 +23,7 @@ classifiers = [
23
23
  "Programming Language :: Python :: 3.12",
24
24
  "Operating System :: OS Independent",
25
25
  ]
26
- version = "0.11.0"
26
+ version = "0.11.2"
27
27
 
28
28
  [project.license]
29
29
  text = "MIT"
@@ -39,4 +39,4 @@ from .model import MessageObject as MessageObject
39
39
  from .model import Role as Role
40
40
  from .model import User as User
41
41
 
42
- __version__ = "0.11.0"
42
+ __version__ = "0.11.2"
@@ -2,7 +2,7 @@ from base64 import b64encode
2
2
  from dataclasses import InitVar, dataclass, field, fields
3
3
  from io import BytesIO
4
4
  from pathlib import Path
5
- from typing import Any, Dict, List, Optional, TypeVar, Union
5
+ from typing import Any, Dict, List, Optional, TypeVar, Union, get_args
6
6
  from typing_extensions import override
7
7
 
8
8
  from .parser import Element as RawElement
@@ -24,13 +24,14 @@ class Element:
24
24
  for f in fields(self):
25
25
  if f.name in ("_attrs", "_children"):
26
26
  continue
27
- if f.type is not str and isinstance(attr := getattr(self, f.name), str):
28
- if f.type is bool:
27
+ _type = get_args(f.type)[0] if hasattr(f.type, "__origin__") else f.type
28
+ if _type is not str and isinstance(attr := getattr(self, f.name), str):
29
+ if _type is bool:
29
30
  if attr.lower() not in ("true", "false"):
30
31
  raise TypeError(f.name, attr)
31
32
  setattr(self, f.name, attr.lower() == "true")
32
33
  else:
33
- setattr(self, f.name, f.type(attr))
34
+ setattr(self, f.name, _type(attr))
34
35
  self._attrs[f.name] = getattr(self, f.name)
35
36
  self._attrs = {k: v for k, v in self._attrs.items() if v is not None}
36
37
 
@@ -332,7 +333,6 @@ class Message(Element):
332
333
  self.__call__(*content or [])
333
334
 
334
335
 
335
- @dataclass
336
336
  class Quote(Message):
337
337
  """<quote> 元素用于表示对消息引用。
338
338