Skip to content

Error caused by print inside a list comprehension #10455

@dilsonlira

Description

@dilsonlira

Bug Report

A function whose signature says it doesn't return anything (and it actually doesn't) gets a Mypy error: "print" does not return a value.

To Reproduce

A simplistic example:

# script1.py

def print_items_of_a_list(a: list) -> None:
    [print(item) for item in a]

Expected Behavior

Since the signature says it returns None and it actually returns None, this code is not supposed to cause an error.

Actual Behavior

script1.py:4: error: "print" does not return a value

Your Environment

  • Mypy version used: 0.812
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): default
  • Python version used: 3.6.0
  • Operating system and version: macOS 11.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions