Skip to content

bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec #30444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 10, 2022
Merged
Changes from 1 commit
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
Next Next commit
add missing __slots__ to typing._TypeVarLike
  • Loading branch information
ariebovenberg committed Jan 6, 2022
commit f3362f4df51bf4e744e521a24b4cf6eaf24c05cf
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