gh-95077: [Enum] add code-based deprecation warnings for member.member access (GH-95083)

* issue deprecation warning for member.member access
* always store member property in current class
* remove __getattr__
This commit is contained in:
Ethan Furman 2022-07-25 11:05:10 -07:00 committed by GitHub
parent 73ee5a6b86
commit 4e704d7847
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 68 deletions

View file

@ -945,23 +945,12 @@ but remain normal attributes.
""""""""""""""""""""
Enum members are instances of their enum class, and are normally accessed as
``EnumClass.member``. In Python versions ``3.5`` to ``3.10`` you could access
members from other members -- this practice was discouraged, and in ``3.11``
:class:`Enum` returns to not allowing it::
>>> class FieldTypes(Enum):
... name = 0
... value = 1
... size = 2
...
>>> FieldTypes.value.size
Traceback (most recent call last):
...
AttributeError: <enum 'FieldTypes'> member has no attribute 'size'
``EnumClass.member``. In Python versions starting with ``3.5`` you could access
members from other members -- this practice is discouraged, is deprecated
in ``3.12``, and will be removed in ``3.14``.
.. versionchanged:: 3.5
.. versionchanged:: 3.11
.. versionchanged:: 3.12
Creating members that are mixed with other data types