| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,15 @@ | |||
| 1 | 1 | Pending removal in Python 3.21 | |
| 2 | 2 | ------------------------------ | |
| 3 | 3 | ||
| 4 | + * :mod:`abc` | ||
| 5 | + | ||
| 6 | + * Soft-deprecated since Python 3.3 :class:`abc.abstractclassmethod`, | ||
| 7 | + :class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty` | ||
| 8 | + now raise a :exc:`DeprecationWarning`. | ||
| 9 | + These classes will be removed in Python 3.21, instead | ||
| 10 | + use :func:`abc.abstractmethod` with :func:`classmethod`, | ||
| 11 | + :func:`staticmethod`, and :class:`property` respectively. | ||
| 12 | + | ||
| 4 | 13 | * :mod:`ast`: | |
| 5 | 14 | ||
| 6 | 15 | * Classes ``slice``, ``Index``, ``ExtSlice``, ``Suite``, ``Param``, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -237,7 +237,7 @@ The :mod:`!abc` module also supports the following legacy decorators: | |||
| 237 | 237 | .. decorator:: abstractclassmethod | |
| 238 | 238 | ||
| 239 | 239 | .. versionadded:: 3.2 | |
| 240 | - .. deprecated:: 3.3 | ||
| 240 | + .. deprecated-removed:: 3.3 3.21 | ||
| 241 | 241 | It is now possible to use :class:`classmethod` with | |
| 242 | 242 | :func:`abstractmethod`, making this decorator redundant. | |
| 243 | 243 | ||
@@ -258,7 +258,7 @@ The :mod:`!abc` module also supports the following legacy decorators: | |||
| 258 | 258 | .. decorator:: abstractstaticmethod | |
| 259 | 259 | ||
| 260 | 260 | .. versionadded:: 3.2 | |
| 261 | - .. deprecated:: 3.3 | ||
| 261 | + .. deprecated-removed:: 3.3 3.21 | ||
| 262 | 262 | It is now possible to use :class:`staticmethod` with | |
| 263 | 263 | :func:`abstractmethod`, making this decorator redundant. | |
| 264 | 264 | ||
@@ -278,7 +278,7 @@ The :mod:`!abc` module also supports the following legacy decorators: | |||
| 278 | 278 | ||
| 279 | 279 | .. decorator:: abstractproperty | |
| 280 | 280 | ||
| 281 | - .. deprecated:: 3.3 | ||
| 281 | + .. deprecated-removed:: 3.3 3.21 | ||
| 282 | 282 | It is now possible to use :class:`property`, :meth:`property.getter`, | |
| 283 | 283 | :meth:`property.setter` and :meth:`property.deleter` with | |
| 284 | 284 | :func:`abstractmethod`, making this decorator redundant. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1367,6 +1367,8 @@ Deprecated | |||
| 1367 | 1367 | ||
| 1368 | 1368 | .. include:: ../deprecations/pending-removal-in-3.20.rst | |
| 1369 | 1369 | ||
| 1370 | + .. include:: ../deprecations/pending-removal-in-3.21.rst | ||
| 1371 | + | ||
| 1370 | 1372 | .. include:: ../deprecations/pending-removal-in-future.rst | |
| 1371 | 1373 | ||
| 1372 | 1374 | .. _whatsnew312-removed: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2031,6 +2031,8 @@ New Deprecations | |||
| 2031 | 2031 | ||
| 2032 | 2032 | .. include:: ../deprecations/pending-removal-in-3.20.rst | |
| 2033 | 2033 | ||
| 2034 | + .. include:: ../deprecations/pending-removal-in-3.21.rst | ||
| 2035 | + | ||
| 2034 | 2036 | .. include:: ../deprecations/pending-removal-in-future.rst | |
| 2035 | 2037 | ||
| 2036 | 2038 | CPython Bytecode Changes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2748,6 +2748,8 @@ New deprecations | |||
| 2748 | 2748 | ||
| 2749 | 2749 | .. include:: ../deprecations/pending-removal-in-3.20.rst | |
| 2750 | 2750 | ||
| 2751 | + .. include:: ../deprecations/pending-removal-in-3.21.rst | ||
| 2752 | + | ||
| 2751 | 2753 | .. include:: ../deprecations/pending-removal-in-future.rst | |
| 2752 | 2754 | ||
| 2753 | 2755 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2335,6 +2335,8 @@ New deprecations | |||
| 2335 | 2335 | ||
| 2336 | 2336 | .. include:: ../deprecations/pending-removal-in-3.20.rst | |
| 2337 | 2337 | ||
| 2338 | + .. include:: ../deprecations/pending-removal-in-3.21.rst | ||
| 2339 | + | ||
| 2338 | 2340 | .. include:: ../deprecations/pending-removal-in-future.rst | |
| 2339 | 2341 | ||
| 2340 | 2342 | .. include:: ../deprecations/soft-deprecations.rst | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -215,6 +215,15 @@ tarfile | |||
| 215 | 215 | Deprecated | |
| 216 | 216 | ========== | |
| 217 | 217 | ||
| 218 | + * :mod:`abc` | ||
| 219 | + | ||
| 220 | + * Soft-deprecated since Python 3.3 :class:`abc.abstractclassmethod`, | ||
| 221 | + :class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty` | ||
| 222 | + now raise a :exc:`DeprecationWarning`. | ||
| 223 | + These classes will be removed in Python 3.21, instead | ||
| 224 | + use :func:`abc.abstractmethod` with :func:`classmethod`, | ||
| 225 | + :func:`staticmethod`, and :class:`property` respectively. | ||
| 226 | + | ||
| 218 | 227 | * :mod:`ast`: | |
| 219 | 228 | ||
| 220 | 229 | * Classes ``slice``, ``Index``, ``ExtSlice``, ``Suite``, ``Param``, | |
@@ -228,6 +237,14 @@ Deprecated | |||
| 228 | 237 | ||
| 229 | 238 | .. Add deprecations above alphabetically, not here at the end. | |
| 230 | 239 | ||
| 240 | + .. include:: ../deprecations/pending-removal-in-3.17.rst | ||
| 241 | + | ||
| 242 | + .. include:: ../deprecations/pending-removal-in-3.19.rst | ||
| 243 | + | ||
| 244 | + .. include:: ../deprecations/pending-removal-in-3.20.rst | ||
| 245 | + | ||
| 246 | + .. include:: ../deprecations/pending-removal-in-future.rst | ||
| 247 | + | ||
| 231 | 248 | ||
| 232 | 249 | Porting to Python 3.16 | |
| 233 | 250 | ====================== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,11 +36,15 @@ class C(ABC): | |||
| 36 | 36 | def my_abstract_classmethod(cls, ...): | |
| 37 | 37 | ... | |
| 38 | 38 | ||
| 39 | + .. deprecated-removed: 3.3 3.21 | ||
| 40 | + | ||
| 39 | 41 | """ | |
| 40 | 42 | ||
| 41 | 43 | __isabstractmethod__ = True | |
| 42 | 44 | ||
| 43 | 45 | def __init__(self, callable): | |
| 46 | + import warnings | ||
| 47 | + warnings._deprecated('abc.abstractclassmethod', remove=(3, 21)) | ||
| 44 | 48 | callable.__isabstractmethod__ = True | |
| 45 | 49 | super().__init__(callable) | |
| 46 | 50 | ||
@@ -56,11 +60,15 @@ class C(ABC): | |||
| 56 | 60 | def my_abstract_staticmethod(...): | |
| 57 | 61 | ... | |
| 58 | 62 | ||
| 63 | + .. deprecated-removed: 3.3 3.21 | ||
| 64 | + | ||
| 59 | 65 | """ | |
| 60 | 66 | ||
| 61 | 67 | __isabstractmethod__ = True | |
| 62 | 68 | ||
| 63 | 69 | def __init__(self, callable): | |
| 70 | + import warnings | ||
| 71 | + warnings._deprecated('abc.abstractstaticmethod', remove=(3, 21)) | ||
| 64 | 72 | callable.__isabstractmethod__ = True | |
| 65 | 73 | super().__init__(callable) | |
| 66 | 74 | ||
@@ -76,10 +84,23 @@ class C(ABC): | |||
| 76 | 84 | def my_abstract_property(self): | |
| 77 | 85 | ... | |
| 78 | 86 | ||
| 87 | + .. deprecated-removed: 3.3 3.21 | ||
| 88 | + | ||
| 79 | 89 | """ | |
| 80 | 90 | ||
| 81 | 91 | __isabstractmethod__ = True | |
| 82 | 92 | ||
| 93 | + def __init__( | ||
| 94 | + self, | ||
| 95 | + fget=None, | ||
| 96 | + fset=None, | ||
| 97 | + fdel=None, | ||
| 98 | + doc=None, | ||
| 99 | + ): | ||
| 100 | + import warnings | ||
| 101 | + warnings._deprecated('abc.abstractproperty', remove=(3, 21)) | ||
| 102 | + super().__init__(fget, fset, fdel, doc) | ||
| 103 | + | ||
| 83 | 104 | ||
| 84 | 105 | try: | |
| 85 | 106 | from _abc import (get_cache_token, _abc_init, _abc_register, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,20 +11,30 @@ | |||
| 11 | 11 | import abc | |
| 12 | 12 | import _py_abc | |
| 13 | 13 | from inspect import isabstract | |
| 14 | + from test.support import warnings_helper | ||
| 14 | 15 | ||
| 15 | 16 | def test_factory(abc_ABCMeta, abc_get_cache_token): | |
| 16 | 17 | class TestLegacyAPI(unittest.TestCase): | |
| 17 | 18 | ||
| 18 | 19 | def test_abstractproperty_basics(self): | |
| 19 | - @abc.abstractproperty | ||
| 20 | - def foo(self): pass | ||
| 20 | + with self.assertWarnsRegex( | ||
| 21 | + DeprecationWarning, | ||
| 22 | + 'abstractproperty', | ||
| 23 | + ): | ||
| 24 | + @abc.abstractproperty | ||
| 25 | + def foo(self): pass | ||
| 26 | + | ||
| 21 | 27 | self.assertTrue(foo.__isabstractmethod__) | |
| 22 | 28 | def bar(self): pass | |
| 23 | 29 | self.assertNotHasAttr(bar, "__isabstractmethod__") | |
| 24 | 30 | ||
| 25 | - class C(metaclass=abc_ABCMeta): | ||
| 26 | - @abc.abstractproperty | ||
| 27 | - def foo(self): return 3 | ||
| 31 | + with self.assertWarnsRegex( | ||
| 32 | + DeprecationWarning, | ||
| 33 | + 'abstractproperty', | ||
| 34 | + ): | ||
| 35 | + class C(metaclass=abc_ABCMeta): | ||
| 36 | + @abc.abstractproperty | ||
| 37 | + def foo(self): return 3 | ||
| 28 | 38 | self.assertRaises(TypeError, C) | |
| 29 | 39 | class D(C): | |
| 30 | 40 | @property | |
@@ -33,16 +43,26 @@ def foo(self): return super().foo | |||
| 33 | 43 | self.assertFalse(getattr(D.foo, "__isabstractmethod__", False)) | |
| 34 | 44 | ||
| 35 | 45 | def test_abstractclassmethod_basics(self): | |
| 36 | - @abc.abstractclassmethod | ||
| 37 | - def foo(cls): pass | ||
| 46 | + with self.assertWarnsRegex( | ||
| 47 | + DeprecationWarning, | ||
| 48 | + 'abstractclassmethod', | ||
| 49 | + ): | ||
| 50 | + @abc.abstractclassmethod | ||
| 51 | + def foo(cls): pass | ||
| 52 | + | ||
| 38 | 53 | self.assertTrue(foo.__isabstractmethod__) | |
| 39 | 54 | @classmethod | |
| 40 | 55 | def bar(cls): pass | |
| 41 | 56 | self.assertFalse(getattr(bar, "__isabstractmethod__", False)) | |
| 42 | 57 | ||
| 43 | - class C(metaclass=abc_ABCMeta): | ||
| 44 | - @abc.abstractclassmethod | ||
| 45 | - def foo(cls): return cls.__name__ | ||
| 58 | + with self.assertWarnsRegex( | ||
| 59 | + DeprecationWarning, | ||
| 60 | + 'abstractclassmethod', | ||
| 61 | + ): | ||
| 62 | + class C(metaclass=abc_ABCMeta): | ||
| 63 | + @abc.abstractclassmethod | ||
| 64 | + def foo(cls): return cls.__name__ | ||
| 65 | + | ||
| 46 | 66 | self.assertRaises(TypeError, C) | |
| 47 | 67 | class D(C): | |
| 48 | 68 | @classmethod | |
@@ -51,16 +71,26 @@ def foo(cls): return super().foo() | |||
| 51 | 71 | self.assertEqual(D().foo(), 'D') | |
| 52 | 72 | ||
| 53 | 73 | def test_abstractstaticmethod_basics(self): | |
| 54 | - @abc.abstractstaticmethod | ||
| 55 | - def foo(): pass | ||
| 74 | + with self.assertWarnsRegex( | ||
| 75 | + DeprecationWarning, | ||
| 76 | + 'abstractstaticmethod', | ||
| 77 | + ): | ||
| 78 | + @abc.abstractstaticmethod | ||
| 79 | + def foo(): pass | ||
| 80 | + | ||
| 56 | 81 | self.assertTrue(foo.__isabstractmethod__) | |
| 57 | 82 | @staticmethod | |
| 58 | 83 | def bar(): pass | |
| 59 | 84 | self.assertFalse(getattr(bar, "__isabstractmethod__", False)) | |
| 60 | 85 | ||
| 61 | - class C(metaclass=abc_ABCMeta): | ||
| 62 | - @abc.abstractstaticmethod | ||
| 63 | - def foo(): return 3 | ||
| 86 | + with self.assertWarnsRegex( | ||
| 87 | + DeprecationWarning, | ||
| 88 | + 'abstractstaticmethod', | ||
| 89 | + ): | ||
| 90 | + class C(metaclass=abc_ABCMeta): | ||
| 91 | + @abc.abstractstaticmethod | ||
| 92 | + def foo(): return 3 | ||
| 93 | + | ||
| 64 | 94 | self.assertRaises(TypeError, C) | |
| 65 | 95 | class D(C): | |
| 66 | 96 | @staticmethod | |
@@ -168,6 +198,7 @@ def method_two(self): | |||
| 168 | 198 | msg = r"class C without an implementation for abstract methods 'method_one', 'method_two'" | |
| 169 | 199 | self.assertRaisesRegex(TypeError, msg, C) | |
| 170 | 200 | ||
| 201 | + @warnings_helper.ignore_warnings(category=DeprecationWarning) | ||
| 171 | 202 | def test_abstractmethod_integration(self): | |
| 172 | 203 | for abstractthing in [abc.abstractmethod, abc.abstractproperty, | |
| 173 | 204 | abc.abstractclassmethod, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + Raise :exc:`DeprecationWarning` on using :class:`abc.abstractclassmethod`, | ||
| 2 | + :class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty`, | ||
| 3 | + schedule its removal for Python 3.21. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments