KEMBAR78
Give better error message for ommited parens in function type by msullivan · Pull Request #4329 · python/mypy · GitHub
Skip to content

Conversation

@msullivan
Copy link
Collaborator

Partially fixes #4323

The direct check for a paren feels janky, but I'm not sure if there is a nicer way.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, just a few minor things.

except SyntaxError:
self.fail(TYPE_COMMENT_SYNTAX_ERROR, n.lineno, n.col_offset)
if n.type_comment and n.type_comment[0] != "(":
self.note('Suggestion: wrap input types in parens', n.lineno, n.col_offset)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested what happens if there are extra spaces after # type:, such as # type:<space><space>int -> int?

Style nits: Use "argument types" instead of "input types". Spell parens as "parentheses".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it but probably should put a test for it into the test suite.

Roger.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let Jukka merge this since he started reviewing it.

@JukkaL JukkaL merged commit 0bed269 into master Dec 7, 2017
@gvanrossum gvanrossum deleted the suggest_parens branch December 8, 2017 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants