-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
mypy not compatible with any named axes? #35
Comments
This is expected - mypy thinks that the string is being used as part of a forward reference, rather than as a literal string. Python's typing system can be a bit of a mess in edge cases like this. One solution is to actually define some objects with the name of these strings. Another is to use the appropriate annotations to have mypy ignore the error. |
Got it - no worries, I understand the constraints here. It might be helpful to update the section of the documentation discussing |
Latest version of Pyright ( |
How exactly is this supposed to work? Even with the following from torchtyping import TensorType # type: ignore
def batch_outer_product(
x: TensorType[
"batch", # type: ignore
"x_channels", # type: ignore
],
y: TensorType[
"batch", # type: ignore
"y_channels", # type: ignore
],
) -> TensorType[
"batch", # type: ignore
"x_channels", # type: ignore
"y_channels", # type: ignore
]:
return x.unsqueeze(-1) * y.unsqueeze(-2) I'm getting:
I assume this line in the documentation is no longer valid, right?
The underlying issue (python/mypy#10266) has been closed. |
When I specify a type like
TensorType["batch_size", "num_channels", "x", "y"]
, I get a mypy error likeerror: Name "batch_size" is not defined
for each of the named axes. Is this expected? Am I doing something wrong? This is with the most recent mypy,0.950
.The text was updated successfully, but these errors were encountered: