-
Notifications
You must be signed in to change notification settings - Fork 22
[TEST] example for enums in namespaces #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jpfeuffer it seems like now your test with regards to type safety doesnt work any more -- I can revert this and add the namespace-enum test separately, what do you think? |
|
Yes separate tests would work great I think. Thank you! |
|
@jpfeuffer is this ready to merge? |
|
This precedes CI and needs to be updated to run the tests. And looking at our comments, it sounds like CI might fail. |
261ef34 to
bcbff3f
Compare
|
@timosachsenberg Now you can see the failures. Once they are fixed, we can merge. |
|
thanks! |
WalkthroughAdds a second C++ namespace Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tests/test_code_generator.py(1 hunks)tests/test_files/enums.hpp(1 hunks)tests/test_files/enums.pxd(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: test (==3.0.0, 3.12)
- GitHub Check: test (==3.1.0, 3.10)
- GitHub Check: test (==3.1.0, 3.11)
- GitHub Check: test (==3.1.0, 3.12)
- GitHub Check: test (==3.0.0, 3.11)
- GitHub Check: test (==3.0.0, 3.10)
- GitHub Check: test (>0.29.21, 3.10)
🔇 Additional comments (4)
tests/test_files/enums.hpp (1)
23-32: LGTM! Clean namespace and enum declaration.The addition of the
Foo2namespace with its scoped enumMyEnumis syntactically correct and follows C++ best practices. The enum values (A, C, D) are properly defined within the namespace scope.tests/test_files/enums.pxd (2)
15-21: Good use of wrap-as metadata for enum aliasing.The enum naming convention using
Foo__MyEnumwithwrap-as: MyEnummetadata provides clean Python-side naming while maintaining unique internal names. This is a good approach for namespace handling.
35-49: Well-structured namespace enum declaration.The new
Foo2namespace enum declaration follows the established pattern with proper metadata for wrapping. The documentation and member declarations are consistent with the C++ header.tests/test_code_generator.py (1)
69-72: Excellent test coverage for namespace enum functionality.The test assertions properly verify:
- Both
Foo.MyEnumandFoo2.MyEnumenum existence- Specific member access (
Bfrom original enum,Dfrom new enum)- Correct placement before existing functionality tests
This ensures the new namespace enum feature is thoroughly tested.
- 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]>
- 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]>
|
looks good to me |
Draft proposal on how to handle enums in different namespaces
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.