basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

warn when enum member is non-determinate

Open KotlinIsland opened this issue 10 months ago • 2 comments

Description

def f() -> object:
    return lambda: 1

class E(Enum):
    a = f()  # expect error: `object` can potentially be `FunctionType`, wrap this value with `enum.member` to enforce expected runtime behaviour

E.a.name  # fails at runtime 

FunctionType becomes a non-member, but currently pyright assumes a super type of FunctionType is a member, use enum.member to override this and make it a member

KotlinIsland avatar Apr 14 '25 04:04 KotlinIsland

i dont get it, can u provide more info on exactly what the issue is

DetachHead avatar Apr 18 '25 11:04 DetachHead

try using it and you will see, it's completely unsound

KotlinIsland avatar Apr 18 '25 11:04 KotlinIsland