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

UP037 with torchtyping can be annoying #12082

Open
fsouza opened this issue Jun 28, 2024 · 1 comment
Open

UP037 with torchtyping can be annoying #12082

fsouza opened this issue Jun 28, 2024 · 1 comment

Comments

@fsouza
Copy link
Contributor

fsouza commented Jun 28, 2024

(I wasn't sure if this was the ~same as #10812 so I figured opening a new issue wouldn't hurt)

When using torchtyping, it's common to write annotations like TensorType["batch", "x_channels"]. ruff doesn't like that because of the quoted "batch" and "x_channels" (and removes the quote with autofix, leading to invalid code).

For now, we're resorting to # noqa, but I wonder if this is something ruff can handle.

@knyazer
Copy link

knyazer commented Jul 2, 2024

Does not answer your question, but torchtyping is currently in an almost deprecated state: prefer to use jaxtyping (it supports typing of anything numpy-ish, but the name is slightly misleading).

I think at some point I was reading some stuff from Patrick (the author of torchtyping) about what he uses in his workflow, and his observation was that most static analysis tools work poorly with his typing libraries, so the main intent behind using the type annotations was to use them with beartype, a runtime typechecker.

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