imitation
imitation copied to clipboard
Replace Callable with Protocol + ParamSpec
Type definitions like https://github.com/HumanCompatibleAI/imitation/blob/4232b454b61181e322a666b7ef4c684afa587516/src/imitation/policies/serialize.py#L23-L23
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:
...