Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created June 9, 2025 17:46
Show Gist options
  • Save mypy-play/e1f1bd3254690db213102de71f894854 to your computer and use it in GitHub Desktop.
Save mypy-play/e1f1bd3254690db213102de71f894854 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Protocol, assert_type
class Desc:
def __get__(self, obj, owner=None) -> int:
return 1
class HasDesc(Protocol):
a: Desc
obj: HasDesc
assert_type(obj.a, int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment