Skip to content

Invalid "Value of type Never is not indexable" #16468

@inducer

Description

@inducer

To Reproduce

from typing import Union, Sequence


def f(pad_width: Union[int, Sequence[int]],) -> None:
    if (isinstance(pad_width, tuple)
          and len(pad_width) == 2
          and isinstance(pad_width[0], int)
          and isinstance(pad_width[1], int)
          ):
        pass

Expected Behavior

Type-checks fine.

Actual Behavior

mypy-bug.py:8: error: Value of type Never is not indexable  [index]
mypy-bug.py:9: error: Value of type Never is not indexable  [index]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

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

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