pylint-dev/pylint

Using return value of a function that returns None is not always reported.

Open

#10,476 opened on 2025年8月5日

GitHub で見る
 (4 comments) (0 reactions) (1 assignee)Python (4,978 stars) (1,059 forks)batch import
False Negative 🦋Good first issueHacktoberfestHelp wanted 🙏Needs specification :closed_lock_with_key:

説明

Bug description

def f1(i: int) -> None:
    print(i)


def f2() -> None:
    r = f1(2)  # assignment-from-no-return
    if not r:
        print("error")
    if not f1(2):  # no error
        print("error")

Configuration

Command used

pylint experiments/type_test.py -E

Pylint output

experiments/type_test.py:6:4: E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)

Expected behavior

In the code snippet, line 6 will report an error, but line 9 doesn't. I'd expect to see an error on line 9, since the code essentially does the same thing. Not sure whether this is by design or a bug. If it's by design, feel free to change this issue to a feature request.

Pylint version

pylint 3.3.7
astroid 3.3.10
Python 3.13.5 (main, Jun 11 2025, 15:36:57) [Clang 17.0.0 (clang-1700.0.13.3)]

OS / Environment

MacOS 15.5

Additional dependencies

コントリビューターガイド