Skip to content

Commit 28644ec

Browse files
committed
fix: Python 3.10 compatibility
- Use timezone.utc instead of datetime.UTC (introduced in Python 3.11) - Update ruff target-version from py311 to py310 - Remove unused ty: ignore comments for unresolved-import - Add ty: ignore for deprecated langgraph.prebuilt.create_react_agent
1 parent 22c907d commit 28644ec

File tree

4 files changed

+580
-17
lines changed

4 files changed

+580
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ markers = [
7878

7979
[tool.ruff]
8080
line-length = 110
81-
target-version = "py311"
81+
target-version = "py310"
8282

8383
[tool.ruff.lint]
8484
select = [

stackone_ai/integrations/langgraph.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def _ensure_langgraph() -> None:
2525
try:
26-
from langgraph import prebuilt as _ # noqa: F401 # ty: ignore[unresolved-import]
26+
from langgraph import prebuilt as _ # noqa: F401
2727
except Exception as e: # pragma: no cover
2828
raise ImportError(
2929
"LangGraph is not installed. Install with `pip install langgraph` or "
@@ -45,7 +45,7 @@ def to_tool_node(tools: Tools | Sequence[BaseTool], **kwargs: Any) -> Any:
4545
for inclusion in a graph.
4646
"""
4747
_ensure_langgraph()
48-
from langgraph.prebuilt import ToolNode # ty: ignore[unresolved-import]
48+
from langgraph.prebuilt import ToolNode
4949

5050
langchain_tools = _to_langchain_tools(tools)
5151
return ToolNode(langchain_tools, **kwargs)
@@ -58,7 +58,7 @@ def to_tool_executor(tools: Tools | Sequence[BaseTool], **kwargs: Any) -> Any:
5858
This function now returns a ToolNode for compatibility.
5959
"""
6060
_ensure_langgraph()
61-
from langgraph.prebuilt import ToolNode # ty: ignore[unresolved-import]
61+
from langgraph.prebuilt import ToolNode
6262

6363
langchain_tools = _to_langchain_tools(tools)
6464
return ToolNode(langchain_tools, **kwargs)
@@ -81,6 +81,6 @@ def create_react_agent(llm: Any, tools: Tools | Sequence[BaseTool], **kwargs: An
8181
`Tools` collection from this SDK.
8282
"""
8383
_ensure_langgraph()
84-
from langgraph.prebuilt import create_react_agent as _create # ty: ignore[unresolved-import]
84+
from langgraph.prebuilt import create_react_agent as _create # ty: ignore[deprecated]
8585

86-
return _create(llm, _to_langchain_tools(tools), **kwargs)
86+
return _create(llm, _to_langchain_tools(tools), **kwargs) # ty: ignore[deprecated]

stackone_ai/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66
from collections.abc import Sequence
7-
from datetime import UTC, datetime
7+
from datetime import datetime, timezone
88
from enum import Enum
99
from typing import Annotated, Any, ClassVar, TypeAlias, cast
1010
from urllib.parse import quote
@@ -196,7 +196,7 @@ def execute(
196196
StackOneAPIError: If the API request fails
197197
ValueError: If the arguments are invalid
198198
"""
199-
datetime.now(UTC)
199+
datetime.now(timezone.utc)
200200
feedback_options: JsonDict = {}
201201
result_payload: JsonDict | None = None
202202
response_status: int | None = None
@@ -266,7 +266,7 @@ def execute(
266266
status = "error"
267267
raise StackOneError(f"Request failed: {exc}") from exc
268268
finally:
269-
datetime.now(UTC)
269+
datetime.now(timezone.utc)
270270
metadata: JsonDict = {
271271
"http_method": self._execute_config.method,
272272
"url": url_used,

0 commit comments

Comments
 (0)