Created
June 18, 2019 10:50
-
-
Save hackaugusto/01369a2ba23eb6b59cc7edfc1a25bc85 to your computer and use it in GitHub Desktop.
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 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