Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile with Union #104

Open
pfeatherstone opened this issue Aug 24, 2023 · 3 comments
Open

Failed to compile with Union #104

pfeatherstone opened this issue Aug 24, 2023 · 3 comments
Labels
question User queries

Comments

@pfeatherstone
Copy link

I have a function with signature:

from  typing import Union
from   jaxtyping import Float, jaxtyped
from   typeguard import typechecked

@jaxtyped
@typechecked
def fn(x: Union[Float[torch.Tensor, "B F"], int]): ...

which doesn't work. It fails to compile the AST

@patrick-kidger
Copy link
Owner

What version of typeguard? I think this was a bug in earlier versions of typeguard.

@patrick-kidger patrick-kidger added the question User queries label Aug 24, 2023
@pfeatherstone
Copy link
Author

4.1.0

@patrick-kidger
Copy link
Owner

Thanks!

Looks like this is still an outstanding bug in typeguard. Here's a reproducer that doesn't use jaxtyping:

import numpy as np
from typeguard import typechecked
from typing import Annotated, Union

@typechecked
def fn(x: Union[Annotated[np.ndarray, "B F"], int]): ...

I'd recommend reporting this as a bug on their issue tracker.

As a workaround for now, I'd recommend either downgrading to typeguard 2.*, or to use beartype instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User queries
Projects
None yet
Development

No branches or pull requests

2 participants