Skip to content

Better message for invalid types like List(int) #4172

Closed
@JukkaL

Description

@JukkaL

The error message "invalid type comment or annotation" isn't very helpful if a user writes List(int) instead of List[int] (or Optional(int)). This seems to be a common error.

Example:

from typing import List

def f():
    # type: () -> List(int)   # invalid type comment or annotation
    return [1]

A better message could be something like this:

program.py:3: error: Syntax error in type annotation
program.py:3:note: Suggestion: Use List[...] instead of List(...)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions