Skip to content

Optional feature: return statement at the end of a function #237

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
pylint-bot opened this issue May 7, 2014 · 6 comments
Closed

Optional feature: return statement at the end of a function #237

pylint-bot opened this issue May 7, 2014 · 6 comments
Labels
Enhancement ✨ Improvement to a component

Comments

@pylint-bot
Copy link

Originally reported by: Anonymous


It would be nice to have a checker checking whether all functions end with a return-statement. The trivial statement
'return '
should be allowed, too. This feature should be optional and by default be turned off in the config file, e.g.
'min-returns=0'.


@pylint-bot
Copy link
Author

Original comment by BitBucket: SylvainDe, GitHub: @SylvainDe?:


Maybe I got it wrong but it might be even more interesting (as in less false negative) to have a warning if the functions doesn't return a value (either by the lack of "return" at the end or by a "return" with no value associated) in functions where we return an actual value in at least one place.

For instance :

#!python

def example():
    if 3 < 4:
        return True # we return something here
    # so it would probably make sense to return something here too.

@pylint-bot
Copy link
Author

Original comment by BitBucket: SylvainDe, GitHub: @SylvainDe?:


As a side-note, PEP 8 has been updated to reflect this kind of change : https://mail.python.org/pipermail/python-dev/2015-April/139054.html .

@pylint-bot
Copy link
Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


It would be nice to have this as well. If you want to work on a patch, that would be lovely. ;-) Otherwise I'll get to this issue at some point in the future.

@pylint-bot
Copy link
Author

Original comment by BitBucket: SylvainDe, GitHub: @SylvainDe?:


I've submitted a pull-request related to this on pep8 : https://github.com/PyCQA/pep8/pulls (I'm quite proud of the way it works but the pep8 community does not seem to be ecstatic about it).

I'll try implement something similar in for pylint in the next couple of months. I'll probably need some help : I've jointed the IRC channel and might ask on the mailing-list if I get stuck for too long.

Cheers.

@pylint-bot
Copy link
Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


That's great, don't hesitate to ask any question you might have.

@pylint-bot pylint-bot added the Enhancement ✨ Improvement to a component label Dec 9, 2015
@PCManticore
Copy link
Contributor

Closing in favor of #1267

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

No branches or pull requests

2 participants