Skip to content

Promote tuple size in invariant positions #2620

@hamdanal

Description

@hamdanal

Summary

Similar to literal promotion, ty should promote (homogenous?) fixed-size tuples to arbitrary size in invariant positions. This will be especially noticeable after #1240 where ty would start emitting errors on the code sample below.

languages = {
    "python": (".py", ".pyi"),
    "javascript": (".js", ".jsx", ".ts", ".tsx"),
}
reveal_type(languages)  # revealed: dict[Unknown | str, Unknown | tuple[str, str] | tuple[str, str, str, str]]
                        # expected: dict[Unknown | str, Unknown | tuple[str, ...]]

languages["ruby"] = (".rb",)  # this will error when `| Unknown` is removed (see #1240)

Version

ty 0.0.13

Metadata

Metadata

Assignees

Labels

genericsBugs or features relating to ty's generics implementation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions