Skip to content

Type of enum value being incorrectly inferred #744

@ltcmelo

Description

@ltcmelo
Contributor

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @ltcmelo

      Issue actions

        Type of enum value being incorrectly inferred · Issue #744 · pylint-dev/astroid