-
Notifications
You must be signed in to change notification settings - Fork 235
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
Specify fixed number of elements in the tuple #221
Comments
There's no better way to specify a constant-length tuple. I'd recommend considering There is no way to specify the length of a |
I see. Thanks for clarification! |
@stargrave A bit late to this issue, but you can always do this: >>> Tuple[(Tuple[(int,) * 8],) * 4]
typing.Tuple[
typing.Tuple[int, int, int, int, int, int, int, int],
typing.Tuple[int, int, int, int, int, int, int, int],
typing.Tuple[int, int, int, int, int, int, int, int],
typing.Tuple[int, int, int, int, int, int, int, int]
] |
That doesn't actually work with mypy though.
…--Guido (mobile)
|
Ah, apologies then, it works with typing but didn't realise mypy would choke on that. |
Greetings! Currently I am moving cryptographic library from Python2/3 to mypy. I have got so-called S-box-es: tuple consisting of 8 tuples with 16 integers inside. Like this:
And I have got function requiring exactly that structure as an argument. Currently I wrote the following SboxType:
Possibly I am misunderstanding something. Is there any better and more beauty way on writing types for that kind of structures?
Similar problem arises when I want to specify bytes string (type: bytes) exactly 8 bytes long.
The text was updated successfully, but these errors were encountered: