-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Labels
Enhancement ✨Improvement to a componentImprovement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
Bug description
# pylint: disable=missing-module-docstring,missing-function-docstring
def function1(parameter):
parameter.do()
return # this is reported as `useless-return` as expected
def function2(parameter):
if parameter:
return
return # this is not reported as `useless-return`
def function3(parameter):
if parameter:
pass
else:
return # this is not reported as `useless-return`
def function4(parameter):
if parameter:
return
else: # this is reported as `no-else-return` as expected
return # this is not reported as `useless-return`
def function5(parameter):
try:
parameter.do()
except RuntimeError:
parameter.other()
return # this is not reported as `useless-return`
def function6(parameter):
try:
parameter.do()
except RuntimeError:
return # maybe even this should be reported - `pass` can be usedConfiguration
No response
Command used
pylint a.pyPylint output
************* Module a
4:0: R1711: Useless return at end of function or method (useless-return)
23:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)Expected behavior
Maybe more useless-return messages should be reported, see the comments in the code snippet.
Pylint version
pylint 2.17.7
astroid 2.15.8
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]OS / Environment
No response
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
Enhancement ✨Improvement to a componentImprovement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation