Consider this real code:
from typing import SuperKwargs
class InferenceManager(Generic[T]):
@override
def __init__(self,
*,
default_trajectory: T,
progress_manager: None | ProgressManager,
wandb_run: None | Run
) -> None:
super().__init__()
self._progress_manager = progress_manager
self._results: list[T] = []
self._trajectory = default_trajectory
self._wandb_run = wandb_run
class TrainingInferenceManager(InferenceManager[RLTrainingResult]):
def __init__(self, training_result: TrainingResult, **kwargs: SuperKwargs):
self.training_result = training_result
super().__init__(**kwargs)
If we want full annotations for TrainingInferenceManager.__init__, we currently need to duplicate all of the superclass's parameters. I suggest adding typing.SuperKwargs that stands in place of them.
(This could be made more complicated by allowing the child class to synthesize some of the parameters.)
Related: python/mypy#8769
Consider this real code:
If we want full annotations for
TrainingInferenceManager.__init__, we currently need to duplicate all of the superclass's parameters. I suggest addingtyping.SuperKwargsthat stands in place of them.(This could be made more complicated by allowing the child class to synthesize some of the parameters.)
Related: python/mypy#8769