Skip to content

invalid-type-form emitted for unusual index operations in non-type-expression contexts #727

@sharkdp

Description

@sharkdp

ty emits invalid-type-form for non-type expressions like the following that do not produce errors at runtime:

tuple[1]

While the above case may seem nonsensical, there are real-world code examples where a strict treatment of non-type tuple[ ] expressions under the restricted grammar of type-expressions would lead to false positives (astral-sh/ruff#18991 (comment)). For example:

runtime_type_representation = tuple[(int, str) * 3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions