Skip to content

Commit

Permalink
🥴 Having no __match_args__ is ok.
Browse files Browse the repository at this point in the history
It will simply fall into the type matching phase.
  • Loading branch information
rentruewang committed Jul 11, 2024
1 parent 19453cc commit 7d6336b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/src/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def world(self):
return "world"


class NotDecomposable:
pass


if __name__ == "__main__":
dc = DataClass(name="name", value=3)

Expand Down Expand Up @@ -68,3 +72,16 @@ def world(self):
match nested:
case Nested(item=DataClass(value=val, name=nam)):
print(val, nam)

nd = NotDecomposable()

match nd:
case NotDecomposable():
print("Still matches.")

try:
_ = nd.__match_args__

raise ValueError("Unreachable.")
except AttributeError:
pass

0 comments on commit 7d6336b

Please sign in to comment.