Skip to content

inconsistent-return-statements not detected for while loop with flag #8280

Closed
@mskrzypkows

Description

@mskrzypkows

Bug description

    def get_the_answer(self):  # [inconsistent-return-statements]
        while self.is_running:
            read_message()
            if comunication_finished():
                return "done"

Configuration

No response

Command used

pylint a.py

Pylint output

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 9.97/10, +0.03)

Expected behavior

I expect to get message:
R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) because when the 'self.is_running flag changes to false, I'll receive None instead of str which isn't desired behaviour and should be detected by pylint.

Pylint version

pylint 2.16.1
astroid 2.14.2
Python 3.10.9 (main, Dec 15 2022, 17:11:09) [Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

Macos

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions