Skip to content

Commit fde0672

Browse files
committed
fix: ruff and pyright clean pass
ruff --fix: - demo.py: remove extraneous f-prefix from plain string literal (F541) - base_client.py: remove unused AsyncIterator, Iterator imports (F401) - bedrock/utils.py: remove unused Iterator import (F401); fix import block order (I001) - normalized/chat_models.py: remove unused Iterator import (F401) ruff format: - demo.py: expand tuple literal to one-entry-per-line style - bedrock/utils.py: wrap long _stream_generator signature to fit line-length pyright (--pythonpath .venv/bin/python): - bedrock/chat_models.py: UiPathChatBedrockConverse and UiPathChatBedrock mix UiPathBaseLLMClient (max_retries: int) with ChatBedrockConverse/ChatBedrock (max_retries: int | None); the type narrowing is intentional — our field enforces a non-None default of 0 and the httpx client accepts int | None. Suppress with # type: ignore[override] on both class definition lines, which is the correct pyright mechanism for intentional incompatible base-class field merges in multiple-inheritance mixins.
1 parent ffd4ee7 commit fde0672

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

packages/uipath_langchain_client/demo.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,29 @@ def calculate(expression: str) -> str:
137137
expression: A mathematical expression to evaluate (e.g., "2 + 2").
138138
"""
139139
import ast
140+
140141
try:
141142
# Restrict to a safe subset: only literals and basic arithmetic operators.
142143
# This prevents arbitrary code execution via eval().
143144
tree = ast.parse(expression, mode="eval")
144145
allowed_node_types = (
145-
ast.Expression, ast.BinOp, ast.UnaryOp, ast.Constant,
146-
ast.Add, ast.Sub, ast.Mult, ast.Div, ast.FloorDiv,
147-
ast.Mod, ast.Pow, ast.USub, ast.UAdd,
146+
ast.Expression,
147+
ast.BinOp,
148+
ast.UnaryOp,
149+
ast.Constant,
150+
ast.Add,
151+
ast.Sub,
152+
ast.Mult,
153+
ast.Div,
154+
ast.FloorDiv,
155+
ast.Mod,
156+
ast.Pow,
157+
ast.USub,
158+
ast.UAdd,
148159
)
149160
for node in ast.walk(tree):
150161
if not isinstance(node, allowed_node_types):
151-
return f"Error: unsupported operation in expression"
162+
return "Error: unsupported operation in expression"
152163
result = eval(compile(tree, "<string>", "eval"), {"__builtins__": {}})
153164
return str(result)
154165
except Exception as e:

packages/uipath_langchain_client/src/uipath_langchain_client/base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import logging
2727
from abc import ABC
28-
from collections.abc import AsyncGenerator, AsyncIterator, Generator, Iterator, Mapping, Sequence
28+
from collections.abc import AsyncGenerator, Generator, Mapping, Sequence
2929
from functools import cached_property
3030
from typing import Any, Literal
3131

packages/uipath_langchain_client/src/uipath_langchain_client/clients/bedrock/chat_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _patched_format_data_content_block(block: dict) -> dict:
4848
) from e
4949

5050

51-
class UiPathChatBedrockConverse(UiPathBaseChatModel, ChatBedrockConverse):
51+
class UiPathChatBedrockConverse(UiPathBaseChatModel, ChatBedrockConverse): # type: ignore[override]
5252
api_config: UiPathAPIConfig = UiPathAPIConfig(
5353
api_type=ApiType.COMPLETIONS,
5454
routing_mode=RoutingMode.PASSTHROUGH,
@@ -77,7 +77,7 @@ def setup_uipath_client(self) -> Self:
7777
return self
7878

7979

80-
class UiPathChatBedrock(UiPathBaseChatModel, ChatBedrock):
80+
class UiPathChatBedrock(UiPathBaseChatModel, ChatBedrock): # type: ignore[override]
8181
api_config: UiPathAPIConfig = UiPathAPIConfig(
8282
api_type=ApiType.COMPLETIONS,
8383
routing_mode=RoutingMode.PASSTHROUGH,

packages/uipath_langchain_client/src/uipath_langchain_client/clients/bedrock/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22
import json
3+
from collections.abc import Generator
34
from typing import Any
4-
from collections.abc import Generator, Iterator
55

66
from httpx import Client
77

@@ -51,7 +51,9 @@ def __init__(self, httpx_client: Client | None = None, region_name: str = "PLACE
5151
self.httpx_client = httpx_client
5252
self.meta = _MockClientMeta(region_name=region_name)
5353

54-
def _stream_generator(self, request_body: dict[str, Any]) -> Generator[dict[str, Any], None, None]:
54+
def _stream_generator(
55+
self, request_body: dict[str, Any]
56+
) -> Generator[dict[str, Any], None, None]:
5557
if self.httpx_client is None:
5658
raise ValueError("httpx_client is not set")
5759
with self.httpx_client.stream("POST", "/", json=_serialize_bytes(request_body)) as response:

packages/uipath_langchain_client/src/uipath_langchain_client/clients/normalized/chat_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"""
2525

2626
import json
27-
from collections.abc import AsyncGenerator, Callable, Generator, Iterator, Sequence
27+
from collections.abc import AsyncGenerator, Callable, Generator, Sequence
2828
from typing import Any
2929

3030
from langchain_core.callbacks import (

0 commit comments

Comments
 (0)