Skip to content

Commit

Permalink
chore: hax
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 6, 2024
1 parent 9f4cfc5 commit a9886a5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions koerce/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,19 +1222,16 @@ class Capture(Pattern):
"""

key: str
key: str | Deferred | Builder
what: Pattern

def __init__(self, k: str | Deferred | Builder, what=_any):
key: str
if isinstance(k, (Deferred, Builder)):
k = builder(k)
if isinstance(k, Variable):
key = k.name
def __init__(self, key: str | Deferred | Builder, what=_any):
if isinstance(key, (Deferred, Builder)):
key = builder(key)
if isinstance(key, Variable):
key = key.name
else:
raise TypeError("Only variables can be used as capture keys")
else:
key = k
self.key = key
self.what = pattern(what)

Expand Down

0 comments on commit a9886a5

Please sign in to comment.