Skip to content

Commit 5621990

Browse files
committed
add future annotations test - fix linting errors, revert some tests to previous mode
1 parent bc4db19 commit 5621990

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

doc/source/changelog.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ v2.4.0 (2025-09-18)
77

88
* Implemented `Support Python 3.14, drop 3.8 support <https://github.com/bckohan/enum-properties/issues/97>`_
99

10-
.. warning::
11-
12-
If you are using a dataclass enum with additional properties, you will now need to encapsulate
13-
the dataclass attributes in a tuple as the first element of the enum member tuple. This syntax
14-
worked before but it was also lenient and took the first N elements of the member tuple that
15-
were not properties. This change makes the syntax more explicit and less error prone and was
16-
necessitated to support Python 3.14 because properties are determined after the enum member
17-
values are set on the class due to lazy evaluation of annotations.
18-
1910

2011
v2.3.0 (2025-03-29)
2112
===================

src/enum_properties/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class MyEnum(SymmetricMixin, enum.Enum, metaclass=EnumPropertiesMeta):
406406
__first_class_members__: t.List[str]
407407

408408
@classmethod
409-
def __prepare__(mcs, cls, bases, **kwargs):
409+
def __prepare__(metacls, cls, bases, **kwds): # type: ignore[override]
410410
"""
411411
Strip properties out of inheritance and record them on our class
412412
dictionary for per-value based assignment in ``__new__``.
@@ -429,7 +429,7 @@ def __prepare__(mcs, cls, bases, **kwargs):
429429
else:
430430
real_bases.append(base)
431431

432-
class_dict = super().__prepare__(cls, tuple(real_bases), **kwargs)
432+
class_dict = super().__prepare__(cls, tuple(real_bases), **kwds)
433433

434434
class _PropertyEnumDict(class_dict.__class__): # type: ignore[name-defined]
435435
"""
@@ -630,7 +630,7 @@ def __new__(mcs, classname, bases, classdict, **kwargs):
630630
In python 3.14+ annotations are loaded after enum members are
631631
defined, so we have to reconcile our properties here.
632632
"""
633-
from annotationlib import (
633+
from annotationlib import ( # pyright: ignore[reportMissingImports]
634634
Format,
635635
call_annotate_function,
636636
get_annotate_from_class_namespace,
@@ -901,7 +901,7 @@ def __hash__(self):
901901
return enum.Flag.__hash__(self)
902902

903903

904-
class IntFlagProperties( # type: ignore[misc]
904+
class IntFlagProperties(
905905
DecomposeMixin, SymmetricMixin, enum.IntFlag, metaclass=EnumPropertiesMeta
906906
):
907907
"""

tests/annotations/test_flags.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ class CreatureDataHashableMixin:
432432
class CreatureHybrid(CreatureDataMixin, EnumProperties):
433433
kingdom: Annotated[str, Symmetric()]
434434

435-
BEETLE = ("small", 6, False), "insect"
435+
BEETLE = "small", 6, False, "insect"
436436
DOG = (
437437
(
438438
"medium",
@@ -457,8 +457,8 @@ class CreatureHybrid(CreatureDataMixin, EnumProperties):
457457
class CreatureHybridSpecialized(CreatureDataMixin, EnumProperties):
458458
kingdom: Annotated[str, Symmetric()]
459459

460-
BEETLE = ("small", 6), "insect"
461-
DOG = ("medium", 4, False), "mammal"
460+
BEETLE = "small", 6, "insect"
461+
DOG = "medium", 4, False, "mammal"
462462

463463
@specialize(BEETLE)
464464
def function(self):
@@ -493,7 +493,7 @@ def function(self):
493493
class CreatureHybridSpecialized(CreatureDataHashableMixin, EnumProperties):
494494
kingdom: Annotated[str, Symmetric()]
495495

496-
BEETLE = ("small", 6), "insect"
496+
BEETLE = "small", 6, "insect"
497497
DOG = (
498498
(
499499
"medium",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from __future__ import annotations
2+
from tests.annotations.test import *

tests/legacy/test_flags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ class CreatureHybrid(CreatureDataMixin, EnumProperties, s("kingdom")):
449449
class CreatureHybridSpecialized(
450450
CreatureDataMixin, EnumProperties, s("kingdom")
451451
):
452-
BEETLE = ("small", 6), "insect"
453-
DOG = ("medium", 4, False), "mammal"
452+
BEETLE = "small", 6, "insect"
453+
DOG = "medium", 4, False, "mammal"
454454

455455
@specialize(BEETLE)
456456
def function(self):
@@ -485,7 +485,7 @@ def function(self):
485485
class CreatureHybridSpecialized(
486486
CreatureDataHashableMixin, EnumProperties, s("kingdom")
487487
):
488-
BEETLE = ("small", 6), "insect"
488+
BEETLE = "small", 6, "insect"
489489
DOG = (
490490
(
491491
"medium",

0 commit comments

Comments
 (0)