Skip to content

Improve message when function is missing return type #5952

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

Closed
JukkaL opened this issue Nov 26, 2018 · 1 comment · Fixed by #6773
Closed

Improve message when function is missing return type #5952

JukkaL opened this issue Nov 26, 2018 · 1 comment · Fixed by #6773

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 26, 2018

If a function takes no arguments (or only self) and --disallow-untyped-defs is enabled, the error message "Function is missing a type annotation" is not very helpful. Here's an idea for a better message:

foo.py:2: error: Function must have a return type annotation ('disallow_untyped_defs' enabled)
foo.py:2: note: Use "-> None" if function does not return a value

The error message could be further specialized for __init__.

See #5943 for a related issue.

@allisonking
Copy link
Contributor

I'll work on this one!

ilevkivskyi pushed a commit that referenced this issue May 9, 2019
Fixes #5952

This partially relies on argument names like 'self' or 'cls', but this is OK,
since it is only used to decide the error message wording.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants