Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError with function type comment and annotated argument #53

Open
mrolle45 opened this issue Aug 15, 2022 · 1 comment
Open

SyntaxError with function type comment and annotated argument #53

mrolle45 opened this issue Aug 15, 2022 · 1 comment
Labels

Comments

@mrolle45
Copy link

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.
@ilevkivskyi
Copy link
Owner

Yes, this is a bug. We need to simply reject the type comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants