mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-20 06:35:46 +02:00
* `strict=False` is the default, pyupgrade to min version 3.10 adds this to be explicit w/ behavior
18 lines
456 B
Python
18 lines
456 B
Python
import re
|
|
|
|
|
|
class AnyStr(str):
|
|
def __init__(self, prefix: str | re.Pattern = "") -> None:
|
|
super().__init__()
|
|
self.prefix = prefix
|
|
|
|
def __eq__(self, other: object) -> bool:
|
|
return isinstance(other, str) and (
|
|
other.startswith(self.prefix)
|
|
if isinstance(self.prefix, str)
|
|
else self.prefix.match(other)
|
|
)
|
|
|
|
def __hash__(self) -> int:
|
|
return hash((str(self), self.prefix))
|