mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 02:50:48 +00:00
🐛 fix DataclassEncoder bug and add test case
This commit is contained in:
@ -145,7 +145,7 @@ class DataclassEncoder(json.JSONEncoder):
|
||||
@overrides(json.JSONEncoder)
|
||||
def default(self, o):
|
||||
if dataclasses.is_dataclass(o):
|
||||
return dataclasses.asdict(o)
|
||||
return {f.name: getattr(o, f.name) for f in dataclasses.fields(o)}
|
||||
return super().default(o)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user