Skip to content

Inconsistent report of inconsistent-return-statements when using exit / quitΒ #10508

@GonozalIX

Description

@GonozalIX

Bug description

# pylint: disable=consider-using-sys-exit, missing-module-docstring, missing-function-docstring
def func1(i):
    if i == 1:
        return i
    quit(1)

def func2(i):
    if i == 1:
        quit(1)
    return 1

Configuration

Command used

pre-commit run pylint --file=main.py

Pylint output

************* Module main
main.py:2:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

Expected behavior

Pylint complains about inconsistent-return-statements only in func1 but not in func2.
Expected behaviour is that at least both functions are assessed the same.

If the quit statement should be used with a return or not is up to you :-)

Pylint version

pylint 3.3.8
python 3.12.11

OS / Environment

No response

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeMinor πŸ’…Polishing pylint is always nice

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions