python-sortedcontainers
python-sortedcontainers copied to clipboard
Support container type annotation for classes
trafficstars
I usually make extensive use of type annotation to take advantage of type hinting in programming tools. For example:
data: dict[int, tuple[str, int, float]] = {}
# a few data handlings later
for k, val in data.items():
foo, bar, boo = val
k would be annotated as int, val as tuple[str, int, int], and variables foo, bar, boo here would be annotated as str, int, float respectively. However, if I use SortedDict instead of dict here, it would only annotate data as SortedDict, and the other variables here would be annotated as Any.
It would be helpful to support annotation for classes such as SortedDict and SortedSet similar to builtins like dict and set.