Skip to content

Commit 924d160

Browse files
authored
Merge pull request #124 from UiPath/fix/linter
fix: lint types
2 parents 7744563 + e8b74b7 commit 924d160

File tree

8 files changed

+1810
-1615
lines changed

8 files changed

+1810
-1615
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dev = [
4949
"pytest>=7.4.0",
5050
"pytest-cov>=4.1.0",
5151
"pytest-mock>=3.11.1",
52+
"pytest-asyncio>=1.0.0",
5253
"pre-commit>=4.1.0",
5354
"numpy>=1.24.0",
5455
"pytest_httpx>=0.35.0"
@@ -100,6 +101,8 @@ disallow_untyped_defs = false
100101
testpaths = ["tests"]
101102
python_files = "test_*.py"
102103
addopts = "-ra -q"
104+
asyncio_default_fixture_loop_scope = "function"
105+
asyncio_mode = "auto"
103106

104107
[[tool.uv.index]]
105108
name = "testpypi"

src/uipath_langchain/_cli/_runtime/_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class LangGraphRuntimeContext(UiPathRuntimeContext):
1111
"""Context information passed throughout the runtime execution."""
1212

1313
langgraph_config: Optional[LangGraphConfig] = None
14-
state_graph: Optional[StateGraph] = None
14+
state_graph: Optional[StateGraph[Any, Any]] = None
1515
output: Optional[Any] = None
1616
state: Optional[Any] = (
1717
None # TypedDict issue, the actual type is: Optional[langgraph.types.StateSnapshot]

src/uipath_langchain/_cli/_runtime/_runtime.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ async def cleanup(self):
271271
if hasattr(self, "graph_config") and self.graph_config:
272272
await self.graph_config.cleanup()
273273

274-
def _extract_graph_result(self, final_chunk, graph: CompiledStateGraph):
274+
def _extract_graph_result(
275+
self, final_chunk, graph: CompiledStateGraph[Any, Any, Any]
276+
):
275277
"""
276278
Extract the result from a LangGraph output chunk according to the graph's output channels.
277279

src/uipath_langchain/_cli/_utils/_graph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ class GraphConfig:
2121
path: str
2222
file_path: str
2323
graph_var: str
24-
_graph: Optional[Union[StateGraph, CompiledStateGraph]] = None
24+
_graph: Optional[Union[StateGraph[Any, Any], CompiledStateGraph[Any, Any, Any]]] = (
25+
None
26+
)
2527

2628
@classmethod
2729
def from_config(cls, name: str, path: str) -> "GraphConfig":
2830
file_path, graph_var = path.split(":")
2931
return cls(name=name, path=path, file_path=file_path, graph_var=graph_var)
3032

31-
async def load_graph(self) -> Union[StateGraph, CompiledStateGraph]:
33+
async def load_graph(
34+
self,
35+
) -> Union[StateGraph[Any, Any], CompiledStateGraph[Any, Any, Any]]:
3236
"""Load graph from the specified path"""
3337
try:
3438
cwd = os.path.abspath(os.getcwd())

src/uipath_langchain/_cli/cli_init.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def process_nullable_types(
5454
return schema
5555

5656

57-
def generate_schema_from_graph(graph: CompiledStateGraph) -> Dict[str, Any]:
57+
def generate_schema_from_graph(
58+
graph: CompiledStateGraph[Any, Any, Any],
59+
) -> Dict[str, Any]:
5860
"""Extract input/output schema from a LangGraph graph"""
5961
schema = {
6062
"input": {"type": "object", "properties": {}, "required": []},

src/uipath_langchain/embeddings/embeddings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class UiPathOpenAIEmbeddings(UiPathRequestMixin, OpenAIEmbeddings):
5959
)
6060

6161
def embed_documents(
62-
self, texts: List[str], chunk_size: Optional[int] = None
62+
self, texts: List[str], chunk_size: Optional[int] = None, **kwargs
6363
) -> List[List[float]]:
6464
"""Embed a list of documents using the UiPath."""
6565
embeddings = []
@@ -83,6 +83,7 @@ async def aembed_documents(
8383
self,
8484
texts: List[str],
8585
chunk_size: Optional[int] = None,
86+
**kwargs,
8687
) -> List[List[float]]:
8788
"""Async version of embed_documents."""
8889
embeddings = []

tests/hitl/mocks/api_trigger_hitl.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
import dataclasses
1+
from typing import TypedDict
22

33
from langgraph.checkpoint.memory import MemorySaver
44
from langgraph.graph import END, START, StateGraph
55
from langgraph.types import interrupt
66

77

8-
@dataclasses.dataclass
9-
class Input:
10-
pass
11-
12-
13-
@dataclasses.dataclass
14-
class Output:
8+
class State(TypedDict):
159
message: str
1610

1711

18-
def main_node(input: Input) -> Output:
12+
def main_node(state: State) -> State:
1913
response = interrupt("interrupt message")
20-
return Output(message=response)
14+
return {"message": response}
2115

2216

23-
builder = StateGraph(input=Input, output=Output)
17+
builder: StateGraph[State] = StateGraph(State)
2418

2519
builder.add_node("main_node", main_node)
2620

uv.lock

Lines changed: 1787 additions & 1598 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)