Skip to content

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

@NielsPT

Description

@NielsPT

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

Metadata

Metadata

Assignees

Labels

False Negative 🦋No message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsNeeds specification 🔐Accepted as a potential improvement, and needs to specify edge cases, message names, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions