Skip to content

SyntaxError with function type comment and annotated argument #53

@mrolle45

Description

@mrolle45

Bug Report:

Example program:

def f(x: bool
	) -> foo:
	# type: (int) -> str
	pass

Result of com2ann:

def f(x: bool: int
        ) -> str:
        pass

The x: bool: int is a SyntaxError.
In this situation, there are various ways to handle it:

  • Reject the function type comment. Preferably, output an explanation for the rejection.
  • If the function comment and the parameter annotation are the same, leave the parameter as is.
    In any event, you will have to examine the syntax tree for the function def and find the parameter annotations.
    If the function comment uses an ellipsis, then this does not apply; only the return type annotation is added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions