-
Notifications
You must be signed in to change notification settings - Fork 281
Closed
Closed
Copy link
Labels
scoping-control-flowissues related to scoping and control flowissues related to scoping and control flowstaletypechecking
Milestone
Description
Describe the Bug
When adding a utility/helper function to an enum, pyrefly doesn't seem able to understand the type of self and that a match statement is, in-fact, exhaustive
from __future__ import annotations
from typing import *
from enum import Enum
class MyEnum(Enum):
CaseA = 0
CaseB = 1
def isA(self: MyEnum) -> bool:
match self:
case MyEnum.CaseA: return True
case MyEnum.CaseB: return False
return False
def isB(self) -> bool:
match self: # <- False positive here
case MyEnum.CaseA: return False
case MyEnum.CaseB: return True
return False
def isMyEnumA(val)-> bool:
match val:
case MyEnum.CaseA: return True
case MyEnum.CaseB: return False
return False
print(MyEnum.CaseA.isA())
print(MyEnum.CaseB.isB())Sandbox Link
(Only applicable for extension issues) IDE Information
WARN sandbox.py:16:15-19: Match on Self@MyEnum is not exhaustive [non-exhaustive-match]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
scoping-control-flowissues related to scoping and control flowissues related to scoping and control flowstaletypechecking