mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 19:11:00 +00:00
add types
This commit is contained in:
16
nonebot/utils.py
Normal file
16
nonebot/utils.py
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import dataclasses
|
||||
|
||||
from nonebot.typing import overrides
|
||||
|
||||
|
||||
class DataclassEncoder(json.JSONEncoder):
|
||||
|
||||
@overrides(json.JSONEncoder)
|
||||
def default(self, o):
|
||||
if dataclasses.is_dataclass(o):
|
||||
return dataclasses.asdict(o)
|
||||
return super().default(o)
|
Reference in New Issue
Block a user