Skip to content

When there's a syntax error, print the comment used #4103

@Wilfred

Description

@Wilfred

Given the Python code:

def big_function(
        x1, # type: Optional[int]
        x2, # type: Optional[int]
        x3, # type: Optional[int]
        x4, # type: Optional[int]
        x5, # type: Optional[int]]
        x6, # type: Optional[int]
        x7, # type: Optional[int]
):
    # type: (...) -> int
    return 123

Sometimes it's difficult to spot which comment has a syntax error. It would be nicer if mypy could print the comment it's looking at, to make it more obvious.

$ mypy --py2 bar.py
bar.py:1: error: syntax error in type comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions