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

jaxtyped is missing type annotations #254

Closed
andriusstank opened this issue Oct 11, 2024 · 1 comment
Closed

jaxtyped is missing type annotations #254

andriusstank opened this issue Oct 11, 2024 · 1 comment

Comments

@andriusstank
Copy link

Hello,

I'm trying to use this library together with mypy, and ran into a problem that @jaxtyped decorator drops type annotations of the function, effectively disabling static type checking. For example:

from jaxtyping import jaxtyped
from typeguard import typechecked

@jaxtyped(typechecker=typechecked)
def f1(x: int) -> int:
    return x

@typechecked
def f2(x: int) -> int:
    return x

reveal_type(f1)
reveal_type(f2)
$ mypy test2.py 
test2.py:12: note: Revealed type is "Any"
test2.py:13: note: Revealed type is "def (x: builtins.int) -> builtins.int"

@typechecked decorated function retains its type, while @jaxtyped is considered as Any.

I have found a similar issue #217, it was closed, but I didn't really understand why.

patrick-kidger added a commit that referenced this issue Oct 11, 2024
@patrick-kidger
Copy link
Owner

Thanks for the report! Looks like pyright was smart enough to figure things out without the extra annotations (which is why I never noticed), but that mypy needed a helping hand. Should be fixed in #255

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

No branches or pull requests

2 participants