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

@ -2646,7 +2646,10 @@ class TestSpecial(unittest.TestCase):
self.assertEqual(Private._Private__corporal, 'Radar')
self.assertEqual(Private._Private__major_, 'Hoolihan')
@unittest.skip("Accessing all values retained for performance reasons, see GH-93910")
@unittest.skipIf(
python_version <= (3, 13),
'member.member access currently deprecated',
)
def test_exception_for_member_from_member_access(self):
with self.assertRaisesRegex(AttributeError, "<enum .Di.> member has no attribute .NO."):
class Di(Enum):
@ -2654,6 +2657,17 @@ class TestSpecial(unittest.TestCase):
NO = 0
nope = Di.YES.NO
@unittest.skipIf(
python_version > (3, 13),
'member.member access now raises',
)
def test_warning_for_member_from_member_access(self):
with self.assertWarnsRegex(DeprecationWarning, '`member.member` access .* is deprecated and will be removed in 3.14'):
class Di(Enum):
YES = 1
NO = 0
warn = Di.YES.NO
self.assertIs(warn, Di.NO)
def test_dynamic_members_with_static_methods(self):
#