💥 correct message segment mapping funcs

This commit is contained in:
yanyongyu 2021-08-04 19:35:03 +08:00
parent 3564228183
commit 8e97a84ad8

View File

@ -10,7 +10,7 @@ import asyncio
from copy import deepcopy
from functools import partial
from typing_extensions import Protocol
from dataclasses import dataclass, field
from dataclasses import dataclass, field, asdict
from typing import (Any, Set, List, Dict, Type, Tuple, Union, TypeVar, Mapping,
Generic, Optional, Iterable)
@ -281,22 +281,22 @@ class MessageSegment(Mapping, abc.ABC, Generic[TM]):
return setattr(self, key, value)
def __iter__(self):
yield from self.data.__iter__()
yield from asdict(self).keys()
def __contains__(self, key: Any) -> bool:
return key in self.data
return key in asdict(self).keys()
def get(self, key: str, default: Any = None):
return getattr(self, key, default)
def keys(self):
return self.data.keys()
return asdict(self).keys()
def values(self):
return self.data.values()
return asdict(self).values()
def items(self):
return self.data.items()
return asdict(self).items()
def copy(self: T) -> T:
return deepcopy(self)