codekingpro/portable-devtools
114k
1"""LangGraph specific warnings."""2 3from __future__ import annotations4 5__all__ = (6 "LangGraphDeprecationWarning",7 "LangGraphDeprecatedSinceV05",8 "LangGraphDeprecatedSinceV10",9 "LangGraphDeprecatedSinceV11",10)11 12 13class LangGraphDeprecationWarning(DeprecationWarning):14 """A LangGraph specific deprecation warning.15 16 Attributes:17 message: Description of the warning.18 since: LangGraph version in which the deprecation was introduced.19 expected_removal: LangGraph version in what the corresponding functionality expected to be removed.20 21 Inspired by the Pydantic `PydanticDeprecationWarning` class, which sets a great standard22 for deprecation warnings with clear versioning information.23 """24 25 message: str26 since: tuple[int, int]27 expected_removal: tuple[int, int]28 29 def __init__(30 self,31 message: str,32 *args: object,33 since: tuple[int, int],34 expected_removal: tuple[int, int] | None = None,35 ) -> None:36 super().__init__(message, *args)37 self.message = message.rstrip(".")38 self.since = since39 self.expected_removal = (40 expected_removal if expected_removal is not None else (since[0] + 1, 0)41 )42 43 def __str__(self) -> str:44 message = (45 f"{self.message}. Deprecated in LangGraph V{self.since[0]}.{self.since[1]}"46 f" to be removed in V{self.expected_removal[0]}.{self.expected_removal[1]}."47 )48 return message49 50 51class LangGraphDeprecatedSinceV05(LangGraphDeprecationWarning):52 """A specific `LangGraphDeprecationWarning` subclass defining functionality deprecated since LangGraph v0.5.0"""53 54 def __init__(self, message: str, *args: object) -> None:55 super().__init__(message, *args, since=(0, 5), expected_removal=(2, 0))56 57 58class LangGraphDeprecatedSinceV10(LangGraphDeprecationWarning):59 """A specific `LangGraphDeprecationWarning` subclass defining functionality deprecated since LangGraph v1.0.0"""60 61 def __init__(self, message: str, *args: object) -> None:62 super().__init__(message, *args, since=(1, 0), expected_removal=(2, 0))63 64 65class LangGraphDeprecatedSinceV11(LangGraphDeprecationWarning):66 """A specific `LangGraphDeprecationWarning` subclass defining functionality deprecated since LangGraph v1.1.0"""67 68 def __init__(self, message: str, *args: object) -> None:69 super().__init__(message, *args, since=(1, 1), expected_removal=(3, 0))70 