Skip to content

Instantly share code, notes, and snippets.

@hackaugusto
Created June 18, 2019 10:50
Show Gist options
  • Select an option

  • Save hackaugusto/01369a2ba23eb6b59cc7edfc1a25bc85 to your computer and use it in GitHub Desktop.

Select an option

Save hackaugusto/01369a2ba23eb6b59cc7edfc1a25bc85 to your computer and use it in GitHub Desktop.
from typing import Generic, Optional, TypeVar
T = TypeVar("T")
class A:
pass
class B(Generic[T]):
def __init__(self, v: T):
self.v = v
def f() -> B[A]:
return B(A())
b1: B[Optional[A]] = B(A())
b2: B[Optional[A]] = f()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment