pyright icon indicating copy to clipboard operation
pyright copied to clipboard

Enum Nonmember Attribute Access Regression

Open max-muoto opened this issue 9 months ago • 0 comments

There seems to be a regression with enum.nonmember after upgrading to 1.1.363:

import enum

class MyEnum(enum.StrEnum):
    VAL_1 = "val_1"
    VAL_2 = "val_2"

    _items = enum.nonmember({VAL_1: 1, VAL_2: 2})

    def to_int(self) -> int:
        return self._items[self]

Pyright Playground

Take this example, here Pyright isn't able to understand that __getitem__ is an attribute on the non-member dictionar.

max-muoto avatar May 15 '24 16:05 max-muoto