pytype icon indicating copy to clipboard operation
pytype copied to clipboard

Pattern matching fail when not specifying all enum values #1591

Open deborshi-web opened this issue 11 months ago • 0 comments

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 avatar Jan 09 '25 04:01 deborshi-web