diff --git a/pyproject.toml b/pyproject.toml index 2fc88b3..4ad791a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "A Python implement of Agent Client Protocol (ACP, by Zed Industri authors = [{ name = "Chojan Shang", email = "psiace@apache.org" }] readme = "README.md" keywords = ['python'] -requires-python = ">=3.10,<=3.14" +requires-python = ">=3.10,<3.15" classifiers = [ "Intended Audience :: Developers", "Programming Language :: Python", diff --git a/src/acp/exceptions.py b/src/acp/exceptions.py index 898ca40..06098dd 100644 --- a/src/acp/exceptions.py +++ b/src/acp/exceptions.py @@ -13,34 +13,34 @@ def __init__(self, code: int, message: str, data: Any | None = None) -> None: self.code = code self.data = data - @staticmethod - def parse_error(data: dict[str, Any] | None = None) -> RequestError: - return RequestError(-32700, "Parse error", data) + @classmethod + def parse_error(cls, data: dict[str, Any] | None = None) -> RequestError: + return cls(-32700, "Parse error", data) - @staticmethod - def invalid_request(data: dict[str, Any] | None = None) -> RequestError: - return RequestError(-32600, "Invalid request", data) + @classmethod + def invalid_request(cls, data: dict[str, Any] | None = None) -> RequestError: + return cls(-32600, "Invalid request", data) - @staticmethod - def method_not_found(method: str) -> RequestError: - return RequestError(-32601, "Method not found", {"method": method}) + @classmethod + def method_not_found(cls, method: str) -> RequestError: + return cls(-32601, "Method not found", {"method": method}) - @staticmethod - def invalid_params(data: dict[str, Any] | None = None) -> RequestError: - return RequestError(-32602, "Invalid params", data) + @classmethod + def invalid_params(cls, data: dict[str, Any] | None = None) -> RequestError: + return cls(-32602, "Invalid params", data) - @staticmethod - def internal_error(data: dict[str, Any] | None = None) -> RequestError: - return RequestError(-32603, "Internal error", data) + @classmethod + def internal_error(cls, data: dict[str, Any] | None = None) -> RequestError: + return cls(-32603, "Internal error", data) - @staticmethod - def auth_required(data: dict[str, Any] | None = None) -> RequestError: - return RequestError(-32000, "Authentication required", data) + @classmethod + def auth_required(cls, data: dict[str, Any] | None = None) -> RequestError: + return cls(-32000, "Authentication required", data) - @staticmethod - def resource_not_found(uri: str | None = None) -> RequestError: + @classmethod + def resource_not_found(cls, uri: str | None = None) -> RequestError: data = {"uri": uri} if uri is not None else None - return RequestError(-32002, "Resource not found", data) + return cls(-32002, "Resource not found", data) def to_error_obj(self) -> dict[str, Any]: return {"code": self.code, "message": str(self), "data": self.data} diff --git a/uv.lock b/uv.lock index 4c6b491..10967c7 100644 --- a/uv.lock +++ b/uv.lock @@ -1,6 +1,6 @@ version = 1 revision = 3 -requires-python = ">=3.10, <=3.14" +requires-python = ">=3.10, <3.15" [[package]] name = "agent-client-protocol"