[Python] generate enums as IntEnum or IntFlag type when requested#8782
[Python] generate enums as IntEnum or IntFlag type when requested#8782jtdavis777 wants to merge 15 commits intogoogle:masterfrom
Conversation
|
Some docs at least in |
|
I played around a bit and it seemed fine, i couldn't integrated it into our main product because this crate was not updated yet rdelfin/flatbuffers-build#30 |
| for (auto import_entry : imports) { | ||
| const std::string local_import = "." + mod; | ||
|
|
||
| // If we have a file called, say, "MyType.py" and in it we have a |
There was a problem hiding this comment.
This seems a separate fix? Usually good to keep those in separate PRs, though no biggie keeping it here for now.
There was a problem hiding this comment.
oh I think this is totally unrelated -- just a result of my poor branch management it seems. will remove.
|
|
Will you still updated this MR @jtdavis777 ? |
|
@fliiix yes it is on my list! Thank you for the reminder. |
|
No hurry, I just finally got some time to look at changes and im running this right now on my version and am still interested to have this at some point on master :) |
|
Im integrating the latest version right now any updates on this MR? I would still like to use that at some point :) |
|
No updates yet, I want to just fold it into the typing flag. Apologies for the delays! |
| GenReceiver(struct_def, code_ptr); | ||
| code += namer_.Method(field); | ||
| code += "(self):"; | ||
| code += "(self):"; // TODO: add typing |
There was a problem hiding this comment.
Not forgotten, just ran out of steam last night. Haha :)
Fixes #8617 and addresses #5083
This PR has enum types inherit from
IntEnumor (IntFlagforbit_flags) directly, instead of just providing this as type hinting, and changes the setter function signatures to require enum types. This code should still be backward and forward compatible on receipt, as ints are still returned by the getters.This code, chiefly, allows users to go to and from string string values to the enum values, but also provides some runtime type safety (over just type hint safety).