Skip to content

Type narrowing on all() call #13069

@antoscha

Description

@antoscha

Bug Report

Mypy ignores types in a explicitly checked tuple.

To Reproduce

  1. Create a file containing:
def func(a: str, b: int) -> None:
    pass


t: tuple[str | None, int | None] = ('a', None)
if not all(t):
    raise ValueError
func(*t)
  1. Run mypy.

Expected Behavior

No errors.

Actual Behavior

mypy_tuple.py:8: error: Argument 1 to "func" has incompatible type "*Tuple[Optional[str], Optional[int]]"; expected "str"
mypy_tuple.py:8: error: Argument 1 to "func" has incompatible type "*Tuple[Optional[str], Optional[int]]"; expected "int"
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.961
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10
  • Operating system and version: Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy