Repository navigation
Conversation
|
I don't think this is a great solution. Here's my understanding:
So I think we should allow the Is it difficult in the code to allow slices in |
|
We need @Zac-HD here 🙂 Do we really need to only support |
|
Here's my desired behaviour: from typing import Annotated, Dict
from torchtyping import TensorType
a: Annotated[int, 1:2] # no error
b: Dict[int, x:y] # as for Dict[int, slice(x,y)]
c: Dict[x:y] # as for Dict[slice(x,y)]
t: TensorType["batch":..., float] # no error - important to support third-party experimentationAnd those errors, with my desired suggestions, are: error: Invalid type comment or annotation [valid-type]
note: Suggestion: use slice[...] instead of slice(...) # use slice[...] instead of `:` slice notation
error: "dict" expects 2 type arguments, but 1 given [type-arg]
error: Invalid type comment or annotation [valid-type]
note: Suggestion: use slice[...] instead of slice(...) # use `x, y` instead of `:` slice notationAs far as I can tell, the original motivation for erroring out on slices was to direct users from In priority order, it's most important for me that |
Now
Dict[x:y]can be silently skipped and treated asAnyif--disable-error-code slice-syntaxis specified.I hope that this is what our users with custom plugins are looking for.
Closes #10266
Refs #11241
CC @Zac-HD