Skip to content

Commit bc4db19

Browse files
committed
tests passing on 3.14 #97
1 parent e78069f commit bc4db19

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/enum_properties/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ def __setitem__(self, key, value):
601601
value = self.AnnotationPropertyRecorder(self)
602602
before = len(self._member_names)
603603
super().__setitem__(key, value)
604+
if key in {"_generate_next_value_", "_ignore_"}:
605+
# this EnumDict renders auto() - so we need to make sure that
606+
# any custom _generate_next_value_ is set on it
607+
class_dict[key] = value
604608
if len(self._member_names) > before:
605609
self._create_properties_ = _lazy_annotations_
606610

@@ -711,7 +715,13 @@ def add_coerce_type(typ: t.Type[t.Any]):
711715
for idx, member in enumerate(cls.__members__.values()): # type: ignore[var-annotated]
712716
member = t.cast(enum.Enum, member)
713717
for prop, values in classdict._ep_properties_.items():
714-
setattr(member, prop, values[idx])
718+
try:
719+
setattr(member, prop, values[idx])
720+
except IndexError as ierr:
721+
raise ValueError(
722+
f"{member} must have {len(classdict._ep_properties_)} property "
723+
"values."
724+
) from ierr
715725

716726
# we reverse to maintain precedence order for symmetric lookups
717727
cls._num_sym_props_ = 0

tests/annotations/test_nestedclass.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ class Type2:
247247
class Type3:
248248
pass
249249

250-
# should not be interpreted as a property
251-
label: str
252-
253250
VALUE1 = Type1, "label1"
254251
VALUE2 = Type2, "label2"
255252
VALUE3 = Type3, "label3"

tests/legacy/test_type_hints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from unittest import TestCase
23

34
from enum_properties import IntEnumProperties, p, s

0 commit comments

Comments
 (0)