Commit cf595fb
Use IntEnum instead of Enum for enum class wrappers (#222)
Change the generated Python enum wrappers to inherit from IntEnum
instead of Enum. This fixes a bug where set parameters containing
enum class values would fail with "TypeError: an integer is required"
when iterating.
The issue was that:
1. Generated code declares `cdef int item0` for iteration
2. But iterating over a set of Enum values yields Enum objects, not ints
3. Cython cannot assign an Enum object to `cdef int`
With IntEnum:
- Enum values ARE integers (isinstance(val, int) is True)
- Cython's `cdef int` can directly accept IntEnum values
- Round-trip operations (get → set) work correctly
- Backwards compatible with code expecting integers
Tested with pyOpenMS which uses `cdef enum class ActivationMethod`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0501161 commit cf595fb
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
2040 | 2040 | | |
2041 | 2041 | | |
2042 | 2042 | | |
2043 | | - | |
| 2043 | + | |
2044 | 2044 | | |
2045 | 2045 | | |
2046 | 2046 | | |
| |||
0 commit comments