Skip to content

Better message for invalid types like (int, str) #4173

Closed
@JukkaL

Description

@JukkaL

The error message "Invalid tuple literal type" isn't very helpful if a user writes (int, str) instead of Tuple[int, str].

Example:

from typing import List

def f():
    # type: () -> (int, str)   # Invalid tuple literal type
    return (1, 'x')

A better message could be something like this:

program.py:3: error: Syntax error in type annotation
program.py:3:note: Suggestion: Use "Tuple[T1, ..., Tn]" instead of "(T1, ..., Tn)"

#4172 is closely related.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions