Commit bd34766
[TEST] example for enums in namespaces (#131)
* [TEST] example for enums in namespaces
* Fix scoped enum handling for namespaced enums
- Change from unscoped `cpdef enum` to scoped `cpdef enum class`
to properly generate Python Enum classes with type-safe validation
- Rename enum identifiers from double underscore (Foo__MyEnum) to
single underscore (Foo_MyEnum) for cleaner naming
- Add missing wrap-as annotation to MyEnum2 for consistency
- Fixes "redeclared" warnings for enum values at module level
The scoped enums now use isinstance() type checking instead of
numeric range validation, properly distinguishing between different
enum types with the same values.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add documentation and changelog for namespaced enum support
- Update CHANGELOG.md with new features for v0.24.0:
- Support for enums with same name in different namespaces
- Support for arbitrary key types in operator[]
- Add comprehensive documentation to enums.pxd explaining the pattern
for wrapping namespaced enums with wrap-as annotation
- Add documentation to enums.hpp explaining the C++ structure
- Add detailed docstring to test_enums() explaining:
- How scoped enums are mapped to Python Enum classes
- The pattern for handling namespace conflicts
- Type-safe enum validation behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Timo Sachsenberg <[email protected]>
Co-authored-by: Claude <[email protected]>1 parent aba2a69 commit bd34766
File tree
4 files changed
+166
-8
lines changed- tests
- test_files
4 files changed
+166
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
53 | 76 | | |
54 | 77 | | |
55 | 78 | | |
| |||
66 | 89 | | |
67 | 90 | | |
68 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
69 | 100 | | |
70 | 101 | | |
71 | 102 | | |
| 103 | + | |
| 104 | + | |
72 | 105 | | |
73 | | - | |
74 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
75 | 112 | | |
76 | 113 | | |
77 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
1 | 19 | | |
2 | 20 | | |
3 | 21 | | |
| 22 | + | |
4 | 23 | | |
5 | 24 | | |
6 | | - | |
| 25 | + | |
7 | 26 | | |
8 | 27 | | |
| 28 | + | |
9 | 29 | | |
10 | 30 | | |
11 | | - | |
| 31 | + | |
12 | 32 | | |
13 | 33 | | |
| 34 | + | |
| 35 | + | |
14 | 36 | | |
15 | 37 | | |
16 | 38 | | |
| |||
19 | 41 | | |
20 | 42 | | |
21 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
22 | 57 | | |
23 | | - | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
2 | 42 | | |
3 | 43 | | |
4 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
5 | 52 | | |
6 | | - | |
7 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
8 | 57 | | |
9 | 58 | | |
10 | | - | |
| 59 | + | |
| 60 | + | |
11 | 61 | | |
12 | 62 | | |
13 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
14 | 67 | | |
15 | 68 | | |
16 | 69 | | |
17 | 70 | | |
18 | 71 | | |
19 | 72 | | |
20 | | - | |
| 73 | + | |
| 74 | + | |
21 | 75 | | |
22 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
23 | 80 | | |
24 | 81 | | |
25 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments