Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern matching fail when not specifying all enum values #1591 #1860

Open
deborshi-web opened this issue Jan 9, 2025 · 0 comments
Open

Comments

@deborshi-web
Copy link

The code is running fine after i removing all default

from enum import Enum
from typing import Optional

def Query(any_object):
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(None),
environment: Optional[Environment] = Query(None), #made changes in these lines
asset_id: Optional[str] = Query(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

Origin code:
Query(default=None),
environment: Optional[Environment] = Query(default=None),
asset_id: Optional[str] = Query(default=None)

@deborshi-web deborshi-web reopened this Jan 9, 2025
@deborshi-web deborshi-web changed the title removed all defaults Pattern matching fail when not specifying all enum values #1591 Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant