Skip to content

Commit

Permalink
Merge pull request #1543 from google/google_sync
Browse files Browse the repository at this point in the history
Google sync
  • Loading branch information
rchen152 authored Dec 7, 2023
2 parents 3372893 + bbf10c1 commit 4748e55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pytype/pattern_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ def check_ending(self,
elif start in self._literal_tracker:
tracker = self._literal_tracker[start]
else:
assert False
# We have nested matches, one of which is not an enum
continue
if tracker.is_valid:
if uncovered := tracker.uncovered:
ret.append((start, uncovered))
Expand Down
2 changes: 1 addition & 1 deletion pytype/stubs/builtins/typing.pytd
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ class Required(Generic[_T]): ...
class NotRequired(Generic[_T]): ...
Self = TypeVar('Self')
class TypeVarTuple: ...
class Unpack: ...
class Unpack(Generic[_T]): ...

def assert_type(val, typ, /): ...
def assert_never(arg: Never, /) -> Never: ...
Expand Down
18 changes: 18 additions & 0 deletions pytype/tests/test_pattern_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,24 @@ class Color(enum.Enum):
def f(x: Color, y: Color) -> int | str | None: ...
""")

def test_nested_mixed(self):
self.CheckWithErrors("""
from enum import Enum
class Color(Enum):
RED = 0
GREEN = 1
BLUE = 2
def f(x: Color, y: str):
match x: # incomplete-match
case Color.RED:
return 10
case Color.GREEN:
match y:
case "bold":
return 10
""")

def test_multiple(self):
ty, _ = self.InferWithErrors("""
from enum import Enum
Expand Down

0 comments on commit 4748e55

Please sign in to comment.