-
Notifications
You must be signed in to change notification settings - Fork 285
Closed
Description
I looked at PEP 591 and saw no mention of unpacking.
Currently (AFAIK) there does not appear to be a way to make unpacked variables Final, either inline or by declaring variables first. Some lines which look like they might work but don't:
x: Final, y: Final = True, False
(x, y): Final = True, False # *only single target (not tuple) can be annotated [syntax]*
x, y: Final = True, False # syntax error, confusing
(x, y) = Final[(True, False)] # syntax ok but x and y inferred by Mypy as Any, error at runtimeOf course the first is very verbose and usually you wouldn't want to have one value be final and another not when unpacking.
The second makes some sense except it would be nice to retain the optional parentheses feature.
Metadata
Metadata
Assignees
Labels
No labels