File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -118,13 +118,23 @@ def decode_json(cls, json_data: str | bytes) -> RawMessage:
118118
119119class Constructor :
120120 def __init__ (self , typ : Type , * args : Any , ** kwargs : Any ) -> None :
121- self .type = typ
122- self .args = args
123- self .kwargs = kwargs
121+ self .type : Type = typ
122+ self .args : tuple [Any ] = args
123+ self .kwargs : dict [str , Any ] = kwargs
124+
125+ # When a `__post_call__()` method is defined on the class, it will be
126+ # called by `__call__()`, normally as `self.__post_call__(agent)`.
127+ self ._post_call_fn : Callable [[Agent ], Awaitable [None ]] | None = getattr (
128+ self , "__post_call__" , None
129+ )
124130
125131 async def __call__ (self , channel : Channel , address : Address ) -> Agent :
126132 agent = self .type (* self .args , ** self .kwargs )
127133 agent .init (channel , address )
134+
135+ if self ._post_call_fn is not None :
136+ await self ._post_call_fn (agent )
137+
128138 return agent
129139
130140
You can’t perform that action at this time.
0 commit comments