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 ( | |
Generic, | |
TypeVar, | |
Callable, | |
Concatenate, | |
ParamSpec, | |
reveal_type, | |
) | |
from dataclasses import dataclass |
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 ( | |
Generic, | |
TypeVar, | |
Callable, | |
Concatenate, | |
ParamSpec, | |
reveal_type, | |
) | |
from dataclasses import dataclass |
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 Tuple | |
child_min_max: Tuple[int, int] = (0, 0) |
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 TypeVar, Protocol, Generic, Callable, Any | |
T = TypeVar("T", contravariant=True) | |
# MyPy: error: Missing return statement [empty-body] | |
# MyPy: error: Cannot use a contravariant type variable as return type [misc] | |
# MyPy: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] | |
# PyRight: TypeVar "T" appears only once in generic function signature | |
# Use "object" instead (reportInvalidTypeVarUse) | |
def f_expecting_Nothing_returning_T() -> 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 TypeVar, Protocol, Generic, Callable, Any | |
T = TypeVar("T", covariant=True) | |
# MyPy: error: Missing return statement [empty-body] | |
# MyPy: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] | |
# PyRight: TypeVar "T" appears only once in generic function signature | |
# Use "object" instead (reportInvalidTypeVarUse) | |
def f_expecting_Nothing_returning_T() -> T:... | |
# MyPy: error: Cannot use a covariant type variable as a parameter [misc] |
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 TypeVar, Protocol, Generic, Callable, Any | |
T = TypeVar("T") | |
# MyPy: error: Missing return statement [empty-body] | |
# MyPy: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] | |
# PyRight: TypeVar "T" appears only once in generic function signature. | |
# Use "object" instead (reportInvalidTypeVarUse) | |
def f_expecting_Nothing_returning_T() -> T:... | |
# PyRight: TypeVar "T" appears only once in generic function signature. |
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 functools import lru_cache | |
from typing import override | |
class Foo: | |
def bar(self, x: int) -> None: pass | |
class Bar(Foo): | |
@override | |
@lru_cache | |
def bar(self, x: int) -> None: pass |
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, List, Tuple, Any | |
class Example: | |
pass | |
class Prediction: | |
pass | |
class TestMypy: |
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 Generic, TypeVar | |
T = TypeVar("T", bound=int | None) | |
class C(Generic[T]): | |
def __init__(self, x: T = None): | |
self.x = x |
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, | |
TypeVar, | |
Callable, | |
ParamSpec, | |
reveal_type, | |
) | |
X = TypeVar("X") |