diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-07-25 14:20:33 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-07-25 14:20:33 +0200 |
commit | db6d60c2ef3ded8177ad0caf6d5ee6d019c487ed (patch) | |
tree | 10f483f5ac4c9cdc87541db0e9dcc867d9e7fe35 | |
parent | 2baf182d5dde39921b6020e22544472d18917291 (diff) | |
download | astroid-git-db6d60c2ef3ded8177ad0caf6d5ee6d019c487ed.tar.gz |
Use the same representation from the definition time for mocked enums.
-rw-r--r-- | brain/py2stdlib.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/brain/py2stdlib.py b/brain/py2stdlib.py index c801a92b..b6c16b16 100644 --- a/brain/py2stdlib.py +++ b/brain/py2stdlib.py @@ -301,17 +301,16 @@ def infer_enum_class(node, context=None): for target in parent.targets: # Replace all the assignments with our mocked class. classdef = dedent(''' - class %(name)s(%(base_name)s): + class %(name)s(object): @property def value(self): - return %(value)r + return %(value)s @property def name(self): return %(name)r - %(name)s = %(value)r - ''' % {'base_name': 'int' if 'Int' in basename else 'str', - 'name': target.name, - 'value': real_value.value}) + %(name)s = %(value)s + ''' % {'name': target.name, + 'value': real_value.as_string()}) fake = AstroidBuilder(MANAGER).string_build(classdef)[target.name] fake.parent = target.parent new_targets.append(fake.instanciate_class()) |