Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created May 18, 2025 19:11
Show Gist options
  • Save mypy-play/a9e40c2205041187e112fb6c0ec20d7e to your computer and use it in GitHub Desktop.
Save mypy-play/a9e40c2205041187e112fb6c0ec20d7e to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Any
type Ge0 = tuple[Any, ...]
def ge0_to_0(shape: Ge0) -> tuple[()]:
return shape # ✅ true negative
def ge0_to_1(shape: Ge0) -> tuple[int]:
return shape # ✅ true negative
def ge0_to_2(shape: Ge0) -> tuple[int, int]:
return shape # ✅ true negative
type Ge1 = tuple[int, *tuple[Any, ...]]
def ge1_to_0(shape: Ge1) -> tuple[()]:
return shape # ✅ true positive
def ge1_to_1(shape: Ge1) -> tuple[int]:
return shape # ❌ false positive
def ge1_to_2(shape: Ge1) -> tuple[int, int]:
return shape # ❌ false positive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment