From fb459ac73d4997433192aa553f253873f9204e1c Mon Sep 17 00:00:00 2001 From: William Bakst Date: Fri, 13 Dec 2024 16:43:10 -0800 Subject: [PATCH] fix: pyright errors --- .pre-commit-config.yaml | 2 +- mirascope/core/base/call_response.py | 36 ---------------------------- mirascope/core/base/stream.py | 4 ++-- pyproject.toml | 2 +- uv.lock | 10 ++++---- 5 files changed, 9 insertions(+), 45 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bd3049974..92544d262 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: ruff-format files: "^mirascope|^tests|^examples|^docs" - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.389 + rev: v1.1.390 hooks: - id: pyright - repo: local diff --git a/mirascope/core/base/call_response.py b/mirascope/core/base/call_response.py index dfbdb7d4b..28701401a 100644 --- a/mirascope/core/base/call_response.py +++ b/mirascope/core/base/call_response.py @@ -50,42 +50,6 @@ ) -# def transform_tool_outputs( -# fn: Callable[[type[_BaseCallResponseT], list[tuple[_BaseToolT, str]]], list[Any]], -# ) -> Callable[ -# [type[_BaseCallResponseT], list[tuple[_BaseToolT, JsonableType]]], -# list[Any], -# ]: -# @wraps(fn) -# def wrapper( -# cls: type[_BaseCallResponseT], -# tools_and_outputs: list[tuple[_BaseToolT, JsonableType]], -# ) -> list[Any]: -# def recursive_serializer(value: JsonableType) -> str: -# if isinstance(value, str): -# return value -# if isinstance(value, int | float | bool): -# return json.dumps(value) -# if isinstance(value, bytes): -# return base64.b64encode(value).decode("utf-8") -# if isinstance(value, BaseModel): -# return value.model_dump_json() -# if isinstance(value, list | set | tuple): -# serialized_items = [recursive_serializer(item) for item in value] -# return json.dumps(serialized_items) -# if isinstance(value, dict): -# serialized_dict = {k: recursive_serializer(v) for k, v in value.items()} -# return json.dumps(serialized_dict) -# raise TypeError(f"Unsupported type for serialization: {type(value)}") - -# transformed_tools_and_outputs = [ -# (tool, recursive_serializer(output)) for tool, output in tools_and_outputs -# ] -# return fn(cls, transformed_tools_and_outputs) - -# return wrapper - - def transform_tool_outputs( fn: Callable[[type[_BaseCallResponseT], list[tuple[_BaseToolT, str]]], list[Any]], ) -> Callable[ diff --git a/mirascope/core/base/stream.py b/mirascope/core/base/stream.py index 46fc53155..32402ffc9 100644 --- a/mirascope/core/base/stream.py +++ b/mirascope/core/base/stream.py @@ -28,7 +28,7 @@ ) from .call_kwargs import BaseCallKwargs from .call_params import BaseCallParams -from .call_response import BaseCallResponse +from .call_response import BaseCallResponse, JsonableType from .call_response_chunk import BaseCallResponseChunk from .dynamic_config import BaseDynamicConfig from .messages import Messages @@ -217,7 +217,7 @@ def _construct_message_param( ... def tool_message_params( - self, tools_and_outputs: list[tuple[_BaseToolT, str]] + self, tools_and_outputs: list[tuple[_BaseToolT, JsonableType]] ) -> list[_ToolMessageParamT]: """Returns the tool message parameters for tool call results. diff --git a/pyproject.toml b/pyproject.toml index 6bd09274e..e8a1da0ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ mcp = ["mcp>=1.0.0"] dev-dependencies = [ "ruff>=0.6.1", "pytest>=8.3.2", - "pyright>=1.1.389", + "pyright>=1.1.390", "pytest-asyncio>=0.23.8", "pytest-cov>=5.0.0", "pre-commit>=3.8.0", diff --git a/uv.lock b/uv.lock index 89cf6f71b..92d7f16ad 100644 --- a/uv.lock +++ b/uv.lock @@ -3156,7 +3156,7 @@ wheels = [ [[package]] name = "mirascope" -version = "1.12.1" +version = "1.13.0" source = { editable = "." } dependencies = [ { name = "docstring-parser" }, @@ -3323,7 +3323,7 @@ dev = [ { name = "pillow", specifier = ">=10.4.0" }, { name = "pinecone-client", specifier = ">=5.0.1" }, { name = "pre-commit", specifier = ">=3.8.0" }, - { name = "pyright", specifier = ">=1.1.389" }, + { name = "pyright", specifier = ">=1.1.390" }, { name = "pytest", specifier = ">=8.3.2" }, { name = "pytest-asyncio", specifier = ">=0.23.8" }, { name = "pytest-cov", specifier = ">=5.0.0" }, @@ -4982,15 +4982,15 @@ wheels = [ [[package]] name = "pyright" -version = "1.1.389" +version = "1.1.390" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nodeenv" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/72/4e/9a5ab8745e7606b88c2c7ca223449ac9d82a71fd5e31df47b453f2cb39a1/pyright-1.1.389.tar.gz", hash = "sha256:716bf8cc174ab8b4dcf6828c3298cac05c5ed775dda9910106a5dcfe4c7fe220", size = 21940 } +sdist = { url = "https://files.pythonhosted.org/packages/ba/42/1e0392f35dd275f9f775baf7c86407cef7f6a0d9b8e099a93e5422a7e571/pyright-1.1.390.tar.gz", hash = "sha256:aad7f160c49e0fbf8209507a15e17b781f63a86a1facb69ca877c71ef2e9538d", size = 21950 } wheels = [ - { url = "https://files.pythonhosted.org/packages/1b/26/c288cabf8cfc5a27e1aa9e5029b7682c0f920b8074f45d22bf844314d66a/pyright-1.1.389-py3-none-any.whl", hash = "sha256:41e9620bba9254406dc1f621a88ceab5a88af4c826feb4f614d95691ed243a60", size = 18581 }, + { url = "https://files.pythonhosted.org/packages/43/20/3f492ca789fb17962ad23619959c7fa642082621751514296c58de3bb801/pyright-1.1.390-py3-none-any.whl", hash = "sha256:ecebfba5b6b50af7c1a44c2ba144ba2ab542c227eb49bc1f16984ff714e0e110", size = 18579 }, ] [[package]]