Skip to content

Commit d863210

Browse files
authored
Improve TypeVar stub (#4150)
1 parent b7d9a4a commit d863210

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

stdlib/2/typing.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986
99

1010
overload = object()
1111
Any = object()
12-
TypeVar = object()
12+
13+
class TypeVar:
14+
__name__: str
15+
__bound__: Optional[Type[Any]]
16+
__constraints__: Tuple[Type[Any], ...]
17+
__covariant__: bool
18+
__contravariant__: bool
19+
def __init__(self, name: str, *constraints: Type[Any], bound: Optional[Type[Any]] = ..., covariant: bool = ..., contravariant: bool = ...) -> None: ...
20+
1321
_promote = object()
1422

1523
class _SpecialForm(object):

stdlib/3/typing.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986
1010

1111
overload = object()
1212
Any = object()
13-
TypeVar = object()
13+
14+
class TypeVar:
15+
__name__: str
16+
__bound__: Optional[Type[Any]]
17+
__constraints__: Tuple[Type[Any], ...]
18+
__covariant__: bool
19+
__contravariant__: bool
20+
def __init__(self, name: str, *constraints: Type[Any], bound: Optional[Type[Any]] = ..., covariant: bool = ..., contravariant: bool = ...) -> None: ...
21+
1422
_promote = object()
1523

1624
class _SpecialForm:

0 commit comments

Comments
 (0)