Skip to content

Instantly share code, notes, and snippets.

@nilsso
Created August 7, 2022 03:43
Show Gist options
  • Select an option

  • Save nilsso/6a157c652c8139b181c17f97d8f7aa18 to your computer and use it in GitHub Desktop.

Select an option

Save nilsso/6a157c652c8139b181c17f97d8f7aa18 to your computer and use it in GitHub Desktop.
import typing
T = typing.TypeVar("T")
def not_none(v: T | None) -> T:
assert v is not None
return v
def foo() -> int | None:
return 1
a = not_none(foo()) # pyright shows "int"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment