Skip to content

Iterator evaluators (e.g. any) don't erase types when in conjunction with Never functions #15703

@C-Ezra-M

Description

@C-Ezra-M

Bug Report

Functions that evaluate iterators (like any) don't disqualify a value from being of another type if there's a function that never returns (like sys.exit).

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.11&gist=bf0b47681fdf97d19050eff3473d03f6

Actual Behavior

main.py:16: error: Argument 1 to "some_function" has incompatible type "int | None"; expected "int"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.4.1
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): defaults
  • Python version used: 3.11

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