From: Arie Bovenberg Date: Mon, 10 Jan 2022 23:43:39 +0000 (+0100) Subject: bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec (#30444) X-Git-Tag: v3.11.0a4~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=081a2140083680ffc309e53699aea29e71760d70;p=thirdparty%2FPython%2Fcpython.git bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec (#30444) * add missing __slots__ to typing._TypeVarLike * add news entry * remove slots from _TypeVarLike base classes * cleanup diff * fix broken link in blurb --- diff --git a/Lib/typing.py b/Lib/typing.py index ae1dd5c2d768..d520f6b2e1b3 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -805,9 +805,6 @@ class TypeVar( _Final, _Immutable, _TypeVarLike, _root=True): Note that only type variables defined in global scope can be pickled. """ - __slots__ = ('__name__', '__bound__', '__constraints__', - '__covariant__', '__contravariant__', '__dict__') - def __init__(self, name, *constraints, bound=None, covariant=False, contravariant=False): self.__name__ = name @@ -907,9 +904,6 @@ class ParamSpec(_Final, _Immutable, _TypeVarLike, _root=True): be pickled. """ - __slots__ = ('__name__', '__bound__', '__covariant__', '__contravariant__', - '__dict__') - @property def args(self): return ParamSpecArgs(self) diff --git a/Misc/NEWS.d/next/Library/2022-01-06-21-31-14.bpo-46244.hjyfJj.rst b/Misc/NEWS.d/next/Library/2022-01-06-21-31-14.bpo-46244.hjyfJj.rst new file mode 100644 index 000000000000..5ca536a97c9c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-06-21-31-14.bpo-46244.hjyfJj.rst @@ -0,0 +1,2 @@ +Removed ``__slots__`` from :class:`typing.ParamSpec` and :class:`typing.TypeVar`. +They served no purpose. Patch by Arie Bovenberg.