You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When an Enum is implemented in C++ and brought to Python via the Boost.Python.enum class is not supported like normal Enums despite being alike.
flags=dict(allow_objects=True) needs to be used to allow these Enum type hints, however there will then be no safeguarding and any value can be written into these fields.
Further Union cannot used with them.
Describe the solution you'd like Boost.Python.enum should possible as type like the standard Python Enums
A workaround is to construct a intermediate enum.
One would need to reconstruct all enums by hand or use the functional approach:
DummyEnum = Enum("DummyEnum", {str(name):value for value, name in RealEnum.values.items()})
@dataclass
class Mine():
greeting: DummyEnum = RealEnum.HELLO # type: ignore
However the functional approach does not allow for correct type hints here.
The text was updated successfully, but these errors were encountered:
This seems like a niche use case that is unlikely to ever get supported unless someone who really needs it submits a complete PR for it. Also unless Boost.Python.enum is a subclass of enum.Enum this may require a lot of changes in the code (and if it is I'm not 100% sure how easy it'd be...)
Is your feature request related to a problem? Please describe.
When an Enum is implemented in C++ and brought to Python via the
Boost.Python.enum
class is not supported like normal Enums despite being alike.flags=dict(allow_objects=True)
needs to be used to allow these Enum type hints, however there will then be no safeguarding and any value can be written into these fields.Further
Union
cannot used with them.Describe the solution you'd like
Boost.Python.enum
should possible as type like the standard Python EnumsA workaround is to construct a intermediate enum.
One would need to reconstruct all enums by hand or use the functional approach:
However the functional approach does not allow for correct type hints here.
The text was updated successfully, but these errors were encountered: