Skip to content

Type of enum value being incorrectly inferred #744

Open
@ltcmelo

Description

@ltcmelo

Note: this content is roughly equivalent to that of an still unanswered question I posted at SO.

from enum import Enum

class Whatever(Enum):
    Foo = 1
    Bar = 2

def f():
    x = Whatever.Foo

Consider the program above an a call to infer() on expression Whatever.Foo.

Current behavior

I get a (proxied) ClassDef for a Foo "type".

Expected behavior

I'd expect a (proxied) ClassDef for Whatever.

This would be according to the language specification, that says that the type of an enumeration member is the enumeration it belongs to.

astroid version: 2.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions