Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ def __repr__(self):

class _TypeVarLike:
"""Mixin for TypeVar-like types (TypeVar and ParamSpec)."""

__slots__ = ('__name__', '__bound__', '__covariant__', '__contravariant__')

def __init__(self, bound, covariant, contravariant):
"""Used to setup TypeVars and ParamSpec's bound, covariant and
contravariant attributes.
Expand Down Expand Up @@ -805,8 +808,7 @@ def longest(x: A, y: A) -> A:
Note that only type variables defined in global scope can be pickled.
"""

__slots__ = ('__name__', '__bound__', '__constraints__',
'__covariant__', '__contravariant__', '__dict__')
__slots__ = ('__constraints__', '__dict__')

def __init__(self, name, *constraints, bound=None,
covariant=False, contravariant=False):
Expand Down Expand Up @@ -907,8 +909,7 @@ def add_two(x: float, y: float) -> float:
be pickled.
"""

__slots__ = ('__name__', '__bound__', '__covariant__', '__contravariant__',
'__dict__')
__slots__ = ('__dict__', )

@property
def args(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add missing ``__slots__`` to ``typing._TypeVarLike``. Patch by Arie
Bovenberg.