Consider adding a "TopLevel" keyword that stands in for the top level bound of a corresponding type variable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
Summary
Please consider a new typing keyword that stands in for the top level type of a corresponding type variable.
Motivation
Consider a test here and the corresponding definition of DistributionInfo here. The test loses all typing information because I used DistributionInfo[Any, Any, Any]. So if I want typing information, I have to use:
def test_flatten(generator: Generator,
distribution_info: DistributionInfo[NaturalParametrization[ExpectationParmetrization, JaxComplexArray],
ExpectationParametrization[NaturalParmetrization],
NumpyComplexArray]) -> None:
I would much rather just do
def test_flatten(generator: Generator,
distribution_info: DistributionInfo[TopLevel, TopLevel, TopLevel]) -> None:
It's not just shorter, but it reduces churn if the type definitions change. Note that TopLevel is recursive (it chooses the top level of the nested types too).
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
Start with the linked tests/test_flatten.py and tests/distribution_info.py to understand the typing information lost when DistributionInfo[Any, Any, Any] is used. Clarify the intended recursive semantics of TopLevel and how it differs from existing type-variable behavior. Done means the proposal has a precise specification and an agreed validation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100