You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pattern matching fail when not specifying all enum values:
The match is missing the following cases: Environment.UAT, tenant_api.models.Environment.TEST, tenant_api.models.Environment.PROD, tenant_api.models.Environment.DEV [incomplete-match]
See my simplified code below:
classEnvironment(Enum):
DEV="DEV"UAT="UAT"TEST="TEST"PROD="PROD"deflist_items(
usecase_id: Optional[str] =Query(default=None),
environment: Optional[Environment] =Query(default=None),
asset_id: Optional[str] =Query(default=None)
) ->ListOut:
match (usecase_id, environment, asset_id):
case (None, None, None):
out= ...
case (uc, None, None):
out= ...
case (None, e, None) ife:
out= ...
case (None, None, a) ifa:
out= ...
case (None, e, a) ifeanda:
out= ...
case (u, e, None) ifuandout= ...
case (u, None, a) ifuanda:
out= ...
case (uc, e, a):
out= ...
returnout
It clearly can't figure out that all cases of the enum are handled by the variable e.
even adding a "catch all" case doesn't seem to cut it.
case_:
raiseIncompleteMatchError("One of more case statements are not being handled!")
The text was updated successfully, but these errors were encountered:
from enum import Enum
from typing import Optional
def Query(default):
return __any_object__
class Environment(Enum):
DEV = "DEV"
UAT = "UAT"
TEST = "TEST"
PROD = "PROD"
class ListOut:
pass
def list_items(
usecase_id: Optional[str] = Query(default=None),
environment: Optional[Environment] = Query(default=None),
asset_id: Optional[str] = Query(default=None)
) -> ListOut:
match (usecase_id, environment, asset_id):
case (None, None, None):
out = ListOut()
case (uc, None, None):
out = ListOut()
case (None, e, None) if e:
out = ListOut()
case (None, None, a) if a:
out = ListOut()
case (None, e, a) if e and a:
out = ListOut()
case (u, e, None) if u and e:
out = ListOut()
case (u, None, a) if u and a:
out = ListOut()
case (uc, e, a):
out = ListOut()
return out
The issue with the catch-all case is a bug that was fixed in the latest release (version 2024.02.27).
Pattern matching fail when not specifying all enum values:
The match is missing the following cases: Environment.UAT, tenant_api.models.Environment.TEST, tenant_api.models.Environment.PROD, tenant_api.models.Environment.DEV [incomplete-match]
See my simplified code below:
It clearly can't figure out that all cases of the enum are handled by the variable
e
.even adding a "catch all" case doesn't seem to cut it.
The text was updated successfully, but these errors were encountered: