Pending removal in Python 3.21
------------------------------
+* :mod:`abc`
+
+ * Soft-deprecated since Python 3.3 :class:`abc.abstractclassmethod`,
+ :class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty`
+ now raise a :exc:`DeprecationWarning`.
+ These classes will be removed in Python 3.21, instead
+ use :func:`abc.abstractmethod` with :func:`classmethod`,
+ :func:`staticmethod`, and :class:`property` respectively.
+
* :mod:`ast`:
* Classes ``slice``, ``Index``, ``ExtSlice``, ``Suite``, ``Param``,
.. decorator:: abstractclassmethod
.. versionadded:: 3.2
- .. deprecated:: 3.3
+ .. deprecated-removed:: 3.3 3.21
It is now possible to use :class:`classmethod` with
:func:`abstractmethod`, making this decorator redundant.
.. decorator:: abstractstaticmethod
.. versionadded:: 3.2
- .. deprecated:: 3.3
+ .. deprecated-removed:: 3.3 3.21
It is now possible to use :class:`staticmethod` with
:func:`abstractmethod`, making this decorator redundant.
.. decorator:: abstractproperty
- .. deprecated:: 3.3
+ .. deprecated-removed:: 3.3 3.21
It is now possible to use :class:`property`, :meth:`property.getter`,
:meth:`property.setter` and :meth:`property.deleter` with
:func:`abstractmethod`, making this decorator redundant.
.. include:: ../deprecations/pending-removal-in-3.20.rst
+.. include:: ../deprecations/pending-removal-in-3.21.rst
+
.. include:: ../deprecations/pending-removal-in-future.rst
.. _whatsnew312-removed:
.. include:: ../deprecations/pending-removal-in-3.20.rst
+.. include:: ../deprecations/pending-removal-in-3.21.rst
+
.. include:: ../deprecations/pending-removal-in-future.rst
CPython Bytecode Changes
.. include:: ../deprecations/pending-removal-in-3.20.rst
+.. include:: ../deprecations/pending-removal-in-3.21.rst
+
.. include:: ../deprecations/pending-removal-in-future.rst
.. include:: ../deprecations/pending-removal-in-3.20.rst
+.. include:: ../deprecations/pending-removal-in-3.21.rst
+
.. include:: ../deprecations/pending-removal-in-future.rst
.. include:: ../deprecations/soft-deprecations.rst
Deprecated
==========
+* :mod:`abc`
+
+ * Soft-deprecated since Python 3.3 :class:`abc.abstractclassmethod`,
+ :class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty`
+ now raise a :exc:`DeprecationWarning`.
+ These classes will be removed in Python 3.21, instead
+ use :func:`abc.abstractmethod` with :func:`classmethod`,
+ :func:`staticmethod`, and :class:`property` respectively.
+
* :mod:`ast`:
* Classes ``slice``, ``Index``, ``ExtSlice``, ``Suite``, ``Param``,
.. Add deprecations above alphabetically, not here at the end.
+.. include:: ../deprecations/pending-removal-in-3.17.rst
+
+.. include:: ../deprecations/pending-removal-in-3.19.rst
+
+.. include:: ../deprecations/pending-removal-in-3.20.rst
+
+.. include:: ../deprecations/pending-removal-in-future.rst
+
Porting to Python 3.16
======================
def my_abstract_classmethod(cls, ...):
...
+ .. deprecated-removed: 3.3 3.21
+
"""
__isabstractmethod__ = True
def __init__(self, callable):
+ import warnings
+ warnings._deprecated('abc.abstractclassmethod', remove=(3, 21))
callable.__isabstractmethod__ = True
super().__init__(callable)
def my_abstract_staticmethod(...):
...
+ .. deprecated-removed: 3.3 3.21
+
"""
__isabstractmethod__ = True
def __init__(self, callable):
+ import warnings
+ warnings._deprecated('abc.abstractstaticmethod', remove=(3, 21))
callable.__isabstractmethod__ = True
super().__init__(callable)
def my_abstract_property(self):
...
+ .. deprecated-removed: 3.3 3.21
+
"""
__isabstractmethod__ = True
+ def __init__(
+ self,
+ fget=None,
+ fset=None,
+ fdel=None,
+ doc=None,
+ ):
+ import warnings
+ warnings._deprecated('abc.abstractproperty', remove=(3, 21))
+ super().__init__(fget, fset, fdel, doc)
+
try:
from _abc import (get_cache_token, _abc_init, _abc_register,
import abc
import _py_abc
from inspect import isabstract
+from test.support import warnings_helper
def test_factory(abc_ABCMeta, abc_get_cache_token):
class TestLegacyAPI(unittest.TestCase):
def test_abstractproperty_basics(self):
- @abc.abstractproperty
- def foo(self): pass
+ with self.assertWarnsRegex(
+ DeprecationWarning,
+ 'abstractproperty',
+ ):
+ @abc.abstractproperty
+ def foo(self): pass
+
self.assertTrue(foo.__isabstractmethod__)
def bar(self): pass
self.assertNotHasAttr(bar, "__isabstractmethod__")
- class C(metaclass=abc_ABCMeta):
- @abc.abstractproperty
- def foo(self): return 3
+ with self.assertWarnsRegex(
+ DeprecationWarning,
+ 'abstractproperty',
+ ):
+ class C(metaclass=abc_ABCMeta):
+ @abc.abstractproperty
+ def foo(self): return 3
self.assertRaises(TypeError, C)
class D(C):
@property
self.assertFalse(getattr(D.foo, "__isabstractmethod__", False))
def test_abstractclassmethod_basics(self):
- @abc.abstractclassmethod
- def foo(cls): pass
+ with self.assertWarnsRegex(
+ DeprecationWarning,
+ 'abstractclassmethod',
+ ):
+ @abc.abstractclassmethod
+ def foo(cls): pass
+
self.assertTrue(foo.__isabstractmethod__)
@classmethod
def bar(cls): pass
self.assertFalse(getattr(bar, "__isabstractmethod__", False))
- class C(metaclass=abc_ABCMeta):
- @abc.abstractclassmethod
- def foo(cls): return cls.__name__
+ with self.assertWarnsRegex(
+ DeprecationWarning,
+ 'abstractclassmethod',
+ ):
+ class C(metaclass=abc_ABCMeta):
+ @abc.abstractclassmethod
+ def foo(cls): return cls.__name__
+
self.assertRaises(TypeError, C)
class D(C):
@classmethod
self.assertEqual(D().foo(), 'D')
def test_abstractstaticmethod_basics(self):
- @abc.abstractstaticmethod
- def foo(): pass
+ with self.assertWarnsRegex(
+ DeprecationWarning,
+ 'abstractstaticmethod',
+ ):
+ @abc.abstractstaticmethod
+ def foo(): pass
+
self.assertTrue(foo.__isabstractmethod__)
@staticmethod
def bar(): pass
self.assertFalse(getattr(bar, "__isabstractmethod__", False))
- class C(metaclass=abc_ABCMeta):
- @abc.abstractstaticmethod
- def foo(): return 3
+ with self.assertWarnsRegex(
+ DeprecationWarning,
+ 'abstractstaticmethod',
+ ):
+ class C(metaclass=abc_ABCMeta):
+ @abc.abstractstaticmethod
+ def foo(): return 3
+
self.assertRaises(TypeError, C)
class D(C):
@staticmethod
msg = r"class C without an implementation for abstract methods 'method_one', 'method_two'"
self.assertRaisesRegex(TypeError, msg, C)
+ @warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_abstractmethod_integration(self):
for abstractthing in [abc.abstractmethod, abc.abstractproperty,
abc.abstractclassmethod,
--- /dev/null
+Raise :exc:`DeprecationWarning` on using :class:`abc.abstractclassmethod`,
+:class:`abc.abstractstaticmethod`, and :class:`abc.abstractproperty`,
+schedule its removal for Python 3.21.