Type definitions like
|
PolicyLoaderFn = Callable[..., policies.BasePolicy] |
can (and should be, for better type safety) replaced with the usage of Protocol + ParamSpec.
Example:
from typing import ParamSpec, Protocol
P = ParamSpec("P")
class PolicyLoaderFn(Protocol[P]):
def __call__(self, venv: vec_env.VecEnv, *args: P.args, **kwargs: P.kwargs) -> policies.BasePolicy:
...
Type definitions like
imitation/src/imitation/policies/serialize.py
Line 23 in 4232b45
can (and should be, for better type safety) replaced with the usage of Protocol + ParamSpec.
Example: