💡 add di docstrings

This commit is contained in:
yanyongyu
2022-01-21 21:04:17 +08:00
parent aef585c60c
commit f9674da6ea
2 changed files with 21 additions and 5 deletions

View File

@ -1,8 +1,4 @@
"""
## 依赖注入处理模块
该模块实现了依赖注入的定义与处理。
"""
"""本模块模块实现了依赖注入的定义与处理。"""
import abc
import inspect
@ -23,6 +19,11 @@ R = TypeVar("R")
class Param(abc.ABC, FieldInfo):
"""依赖注入的基本单元 —— 参数。
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
"""
@classmethod
def _check_param(
cls, dependent: "Dependent", name: str, param: inspect.Parameter
@ -45,6 +46,16 @@ class CustomConfig(BaseConfig):
class Dependent(Generic[R]):
"""依赖注入容器
参数:
call: 依赖注入的可调用对象,可以是任何 Callable 对象
pre_checkers: 依赖注入解析前的参数检查
params: 具名参数列表
parameterless: 匿名参数列表
allow_types: 允许的参数类型
"""
def __init__(
self,
*,
@ -192,3 +203,6 @@ class Dependent(Generic[R]):
values[field.name] = value
return values
__autodoc__ = {"CustomConfig": False}