]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec (#30444)
authorArie Bovenberg <a.c.bovenberg@gmail.com>
Mon, 10 Jan 2022 23:43:39 +0000 (00:43 +0100)
committerGitHub <noreply@github.com>
Mon, 10 Jan 2022 23:43:39 +0000 (07:43 +0800)
* add missing __slots__ to typing._TypeVarLike

* add news entry

* remove slots from _TypeVarLike base classes

* cleanup diff

* fix broken link in blurb

Lib/typing.py
Misc/NEWS.d/next/Library/2022-01-06-21-31-14.bpo-46244.hjyfJj.rst [new file with mode: 0644]

index ae1dd5c2d768919c74da7fe53698ecb95e19bc74..d520f6b2e1b3d4d2cb9ceb1a5e1b4aaa8e11e7c9 100644 (file)
@@ -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 (file)
index 0000000..5ca536a
--- /dev/null
@@ -0,0 +1,2 @@
+Removed ``__slots__`` from :class:`typing.ParamSpec` and :class:`typing.TypeVar`.
+They served no purpose. Patch by Arie Bovenberg.