Skip to content

Commit 9f624c7

Browse files
committed
Use enum.IntEnum for classes enums
1 parent 896114b commit 9f624c7

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/godot/classes.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from .hazmat cimport gdapi, gdptrs, gdextension_interface
22
from .hazmat.gdtypes cimport *
33
from .builtins cimport *
44

5-
from enum import Enum
5+
from enum import IntEnum
66

77

88
def __getattr__(name: str):
@@ -169,7 +169,7 @@ cdef object _load_class(str name):
169169
enum_item_name = next(items_spec)
170170
enum_item_value = next(items_spec)
171171
enum_items_cooked[enum_item_name] = enum_item_value
172-
attrs[enum_name] = Enum(enum_name, enum_items_cooked)
172+
attrs[enum_name] = IntEnum(enum_name, enum_items_cooked)
173173

174174
elif tag == _classes_api._tag_property:
175175
def _gen(

tests/4-use-godot-from-python/tests/test_classes.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,14 @@ def test_property(kind: str):
169169
assert_eq(node.name, godot.StringName("bar"))
170170

171171
case "enum":
172-
clodotest.skip(
173-
reason="TODO: enum currently return `int` instead of `Enum` instance"
174-
)
175172
assert_eq(
176173
node.physics_interpolation_mode,
177-
node.PhysicsInterpolationMode.PHYSICS_INTERPOLATION_MODE_INHERIT,
178-
)
179-
node.physics_interpolation_mode = (
180-
node.PhysicsInterpolationMode.PHYSICS_INTERPOLATION_MODE_ON
174+
node.PhysicsInterpolationMode.INHERIT,
181175
)
176+
node.physics_interpolation_mode = node.PhysicsInterpolationMode.ON
182177
assert_eq(
183178
node.physics_interpolation_mode,
184-
node.PhysicsInterpolationMode.PHYSICS_INTERPOLATION_MODE_ON,
179+
node.PhysicsInterpolationMode.ON,
185180
)
186181

187182
case "class":

0 commit comments

Comments
 (0)