False positive for inconsistent-return-statements
with method annotated with NoReturn
return type
#8747
Labels
False Positive 🦟
A message is emitted but nothing is wrong with the code
Milestone
Bug description
repro.py
Configuration
Command used
Pylint output
Expected behavior
Pylint version
My pylint configuration is pinned to pylint 2.15.8 astroid 2.13.5 Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] But I was able to repro this on the latest released version of pylint (2.17.4 at time of writing).
OS / Environment
Additional dependencies
No response
I did an initial investigation, and might have an idea of what's going on:
During the
inconsistent-return-statements
lint, there's an attempt made infer whether the return type of a function call isNoReturn
.pylint/pylint/checkers/refactoring/refactoring_checker.py
Lines 2001 to 2016 in a67ffbd
But
_is_function_def_never_returning
only inspects the return type if the node passed in is anodes.FunctionDef
. But callingnode.func.inferred()[0]
on the method call (e.g.self._never_returns()
) returns the corresponding method definition node as typeastroid.BoundMethod
. Since that isn't anodes.FunctionDef
,_is_function_def_never_returning
never even looks to see if the return type isNoReturn
.pylint/pylint/checkers/refactoring/refactoring_checker.py
Lines 1956 to 1957 in a67ffbd
The text was updated successfully, but these errors were encountered: