def infer_enum_class(node):
for basename in node.basenames:<EOL><INDENT>if basename not in ENUM_BASE_NAMES:<EOL><INDENT>continue<EOL><DEDENT>if node.root().name == "<STR_LIT>":<EOL><INDENT>break<EOL><DEDENT>for local, values in node.locals.items():<EOL><INDENT>if any(not isinstance(value, nodes.AssignName) for value in values):<EOL><INDENT>continue<EOL><DEDENT>targets = []<EOL>stmt = values[<NUM_LIT:0>].statement()<EOL>if isinstance(stmt, nodes.Assign):<EOL><INDENT>if isinstance(stmt.targets[<NUM_LIT:0>], nodes.Tuple):<EOL><INDENT>targets = stmt.targets[<NUM_LIT:0>].itered()<EOL><DEDENT>else:<EOL><INDENT>targets = stmt.targets<EOL><DEDENT><DEDENT>elif isinstance(stmt, nodes.AnnAssign):<EOL><INDENT>targets = [stmt.target]<EOL><DEDENT>inferred_return_value = None<EOL>if isinstance(stmt, nodes.Assign):<EOL><INDENT>if isinstance(stmt.value, nodes.Const):<EOL><INDENT>if isinstance(stmt.value.value, str):<EOL><INDENT>inferred_return_value = repr(stmt.value.value)<EOL><DEDENT>else:<EOL><INDENT>inferred_return_value = stmt.value.value<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inferred_return_value = stmt.value.as_string()<EOL><DEDENT><DEDENT>new_targets = []<EOL>for target in targets:<EOL><INDENT>classdef = dedent(<EOL>"""<STR_LIT>""".format(<EOL>name=target.name,<EOL>types="<STR_LIT:U+002CU+0020>".join(node.basenames),<EOL>return_value=inferred_return_value,<EOL>)<EOL>)<EOL>if "<STR_LIT>" in basename:<EOL><INDENT>classdef += INT_FLAG_ADDITION_METHODS.format(name=target.name)<EOL><DEDENT>fake = AstroidBuilder(MANAGER).string_build(classdef)[target.name]<EOL>fake.parent = target.parent<EOL>for method in node.mymethods():<EOL><INDENT>fake.locals[method.name] = [method]<EOL><DEDENT>new_targets.append(fake.instantiate_class())<EOL><DEDENT>node.locals[local] = new_targets<EOL><DEDENT>break<EOL><DEDENT>return node<EOL>
Specific inference for enums.