Home / Class/ AnyStr Class — langchain Architecture

AnyStr Class — langchain Architecture

Architecture documentation for the AnyStr class in any_str.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  c499197b_609d_7ead_1aab_c2b15958a228["AnyStr"]
  ff1b0329_5d1f_9ace_5bc7_a70a4a9bb082["any_str.py"]
  c499197b_609d_7ead_1aab_c2b15958a228 -->|defined in| ff1b0329_5d1f_9ace_5bc7_a70a4a9bb082
  55f51447_28af_845f_3b93_96253d20f08f["__init__()"]
  c499197b_609d_7ead_1aab_c2b15958a228 -->|method| 55f51447_28af_845f_3b93_96253d20f08f
  09247f78_fa26_a3c0_a478_978196cc1750["__eq__()"]
  c499197b_609d_7ead_1aab_c2b15958a228 -->|method| 09247f78_fa26_a3c0_a478_978196cc1750
  8c9557b2_8080_428e_2a6d_3f900f955a93["__hash__()"]
  c499197b_609d_7ead_1aab_c2b15958a228 -->|method| 8c9557b2_8080_428e_2a6d_3f900f955a93

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/any_str.py lines 4–19

class AnyStr(str):
    __slots__ = ("prefix",)

    def __init__(self, prefix: str | re.Pattern[str] = "") -> 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) is not None
        )

    def __hash__(self) -> int:
        return hash((str(self), self.prefix))

Frequently Asked Questions

What is the AnyStr class?
AnyStr is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/any_str.py.
Where is AnyStr defined?
AnyStr is defined in libs/langchain_v1/tests/unit_tests/agents/any_str.py at line 4.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free