[ https://issues.apache.org/jira/browse/THRIFT-2059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James Haggerty updated THRIFT-2059: ----------------------------------- Description: Currently enums are represented in Python by classes (see #546) but those classes are not referenced by structs. This means that it's impossible to find out whether something is an enum or an i32 by inspection. e.g. I want to be able to look at the number 1 and realise it's an Operation.ADD or similar. I propose adding an option 'enum' to the generator to support Python 3.4 style enums (see enum34 package on pypi). Any I32 that should be an enum is automatically converted into a proper IntEnum object on serialising, and constants are also constructed with the correct type. Patch attached. was: Currently enums are represented in Python by classes (see #546) but those classes are not referenced by structs. This means that it's impossible to find out whether something is an enum or an i32 by inspection. e.g. I want to be able to look at the number 1 and realise it's an Operation.ADD or similar. > Support for Python 3.4 enums > ---------------------------- > > Key: THRIFT-2059 > URL: https://issues.apache.org/jira/browse/THRIFT-2059 > Project: Thrift > Issue Type: Improvement > Components: Python - Compiler > Affects Versions: 0.9 > Reporter: James Haggerty > Priority: Minor > > Currently enums are represented in Python by classes (see #546) but those > classes are not referenced by structs. This means that it's impossible to > find out whether something is an enum or an i32 by inspection. > e.g. I want to be able to look at the number 1 and realise it's an > Operation.ADD or similar. > I propose adding an option 'enum' to the generator to support Python 3.4 > style enums (see enum34 package on pypi). Any I32 that should be an enum is > automatically converted into a proper IntEnum object on serialising, and > constants are also constructed with the correct type. Patch attached. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira