patrick-kidger / patrick-kidger/jaxtyping
Is it possible to support tuple unpacking?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
Hi! I'm trying to type something like this:
@jaxtyped(typechecker=beartype)
def forward(
self, x: Float[torch.Tensor, "t dim"], *args: torch.Tensor
) -> tuple[torch.Tensor, "t dim"], *tuple[torch.Tensor, ...]]:
return func(x), *args
As I've read here https://github.com/patrick-kidger/jaxtyping/blob/main/docs/faq.md PEP 646 is not supported so it seem's like this kind of return value typing is not supported as of now.
I've just found that the latest version of beartype supports this kind of unpacking, so maybe there's a chance of this being supported in jaxtyping?
typing return as tuple[torch.Tensor, *tuple[torch.Tensor, ...]] also doesn't work using @jaxtyped(typechecker=beartype) but works with just @beartype
Contributor guide
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 docs/faq.md and the @jaxtyped(typechecker=beartype) usage described in the issue, then compare it with the same annotation under @beartype. Determine what is needed for PEP 646-style tuple unpacking in return annotations, and consider the issue done when the shown annotations work through jaxtyped as they do with beartype.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100