How should we annotate functions that forward to their superclass?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
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.
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.)
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
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.
More from python/typing
-
topic: typing spec
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
topic: typing spec
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
topic: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
topic: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
topic: conformance tests topic: typing spec
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·