This file contains 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 overload, Literal | |
class Base: | |
pass | |
class A(Base): | |
pass | |
class B(Base): |
This file contains 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
class A: | |
pass | |
class B(A): | |
def say_hello(self): | |
pass | |
def func_of_a(var1: A) -> None: |
This file contains 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
class A: | |
pass | |
class B(A): | |
def say_hello(self): | |
pass | |
def func_of_a(var1: A) -> None: |
This file contains 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
class A: | |
pass | |
class B(A): | |
def say_hello(self): | |
pass | |
def func_of_a(var1: A) -> None: |
This file contains 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
class A: | |
pass | |
class B(A): | |
def say_hello(self): | |
pass | |
def func_of_a(var1: A) -> None: |
This file contains 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 Protocol, Iterator, TypeVar | |
T = TypeVar('T', covariant = True) | |
class Grouping(Protocol[T]): | |
@staticmethod | |
def __class_getitem__(key): | |
... | |
def __iter__(self) -> Iterator[T]: | |
... |
This file contains 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 Literal | |
a: int = 3 | |
if isinstance(a, float): | |
reveal_type(a) # Never touched at runtime, but Mypy says `int`. | |
b: Literal[3] = 3 | |
if isinstance(b, float): |
This file contains 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
import typing as t | |
a: t.Literal[1 | None] | |
reveal_type(a) |
This file contains 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
import typing as t | |
a: t.Literal[1 | 2] | |
reveal_type(a) |
This file contains 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 TypedDict, TYPE_CHECKING, Any | |
class Movie(TypedDict): | |
name: str | |
year: int | |
def isassignable(x: object, T: type) -> bool: | |
return True |
NewerOlder