Created
May 18, 2025 19:11
-
-
Save mypy-play/a9e40c2205041187e112fb6c0ec20d7e to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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