💡 add rule utils docstring

This commit is contained in:
yanyongyu
2020-09-13 13:01:23 +08:00
parent ce2700c1d2
commit f79eabdc61
15 changed files with 212 additions and 89 deletions

View File

@ -25,7 +25,7 @@ sidebarDepth: 0
* **返回**
* Callable[..., Awaitable[Any]]
* `Callable[..., Awaitable[Any]]`
@ -34,35 +34,6 @@ sidebarDepth: 0
基类:`json.encoder.JSONEncoder`
* **类型**
`json.JSONEncoder`
* **说明**
`JSONEncoder` used when encoding `Message` (List of dataclasses)
### `default(o)`
Implement this method in a subclass such that it returns
a serializable object for `o`, or calls the base implementation
(to raise a `TypeError`).
For example, to support arbitrary iterators, you could
implement default like this:
```default
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
```
JSON序列化 `Message` (List[Dataclass]) 时使用的 `JSONEncoder`