Closed
Description
Hello!
I'm running into a false positive for assignment-from-no-return when doing inheritance of a method where some instances of it raise an exception and others return a value.
This issue is not fixed on the preview release.
Steps to reproduce
The following example should demonstrate the problem:
"""Pylint Test"""
class Parent:
"""Parent class"""
def compute(self):
"""This isn't supported by all child classes"""
# pylint: disable=no-self-use
raise ValueError('Not supported for this object')
def test(self):
"""Test"""
result = self.compute()
return result
class Child(Parent):
"""Child class"""
def compute(self):
"""This is supported for this child class"""
return 42
Current behavior
************* Module pylint_test
/tmp/pylint_test.py:15:8: E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)
-----------------------------------
Your code has been rated at 4.44/10
Expected behavior
Since a value is returned in all cases except when an exception is raised, I would not expect this to return an error.
pylint --version output
pylint 2.4.3
astroid 2.3.2
Python 3.8.0 (default, Oct 15 2019, 17:41:05)
[Clang 11.0.0 (clang-1100.0.20.17)]
Thanks for a great tool, and for your time on this!