Skip to content

Support container type annotation for classes #246

Open
@Huy-Ngo

Description

@Huy-Ngo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions