How should we annotate functions that forward to their superclass?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
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.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation files, tests, or entry points are named. Start by reading the proposed SuperKwargs behavior and related mypy issue #8769; the issue needs an agreed design for forwarded and synthesized parameters before implementation can be scoped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100