Skip to content

Commit a83271d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent ab1414f commit a83271d

24 files changed

Lines changed: 142 additions & 256 deletions

examples/mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def calculate_tool(args):
4646
result = eval(expression, {"__builtins__": {}}, {})
4747
return f"{expression} = {result}"
4848
except Exception as e:
49-
return f"Error: {str(e)}"
49+
return f"Error: {e!s}"
5050

5151

5252
@app.mcp.tool(

integration_tests/base_routes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,12 @@ async def empty_websocket_endpoint(websocket):
181181
@empty_websocket_endpoint.on_connect
182182
async def empty_websocket_on_connect(websocket):
183183
"""Test async handler with no return"""
184-
pass
185184

186185

187186
@empty_websocket_endpoint.on_close
188187
async def empty_websocket_on_close(websocket):
189188
"""Test async handler with explicit None return"""
190-
return None
189+
return
191190

192191

193192
# ===== Lifecycle handlers =====

integration_tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import socket
66
import subprocess
77
import time
8-
from typing import List
98

109
import pytest
1110

1211
from integration_tests.helpers.network_helpers import get_network_host
1312

1413

15-
def spawn_process(command: List[str]) -> subprocess.Popen:
14+
def spawn_process(command: list[str]) -> subprocess.Popen:
1615
if platform.system() == "Windows":
1716
command[0] = "python"
1817
process = subprocess.Popen(command, shell=True, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)

integration_tests/helpers/http_methods_helpers.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Optional
2-
31
import requests
42

53
BASE_URL = "http://127.0.0.1:8080"
@@ -39,7 +37,7 @@ def get(
3937

4038
def post(
4139
endpoint: str,
42-
data: Optional[dict] = None,
40+
data: dict | None = None,
4341
expected_status_code: int = 200,
4442
headers: dict = {},
4543
should_check_response: bool = True,
@@ -135,7 +133,7 @@ def json_patch(
135133

136134
def multipart_post(
137135
endpoint: str,
138-
files: Optional[dict] = None,
136+
files: dict | None = None,
139137
expected_status_code: int = 200,
140138
should_check_response: bool = True,
141139
) -> requests.Response:
@@ -157,7 +155,7 @@ def multipart_post(
157155

158156
def put(
159157
endpoint: str,
160-
data: Optional[dict] = None,
158+
data: dict | None = None,
161159
expected_status_code: int = 200,
162160
headers: dict = {},
163161
should_check_response: bool = True,
@@ -180,7 +178,7 @@ def put(
180178

181179
def patch(
182180
endpoint: str,
183-
data: Optional[dict] = None,
181+
data: dict | None = None,
184182
expected_status_code: int = 200,
185183
headers: dict = {},
186184
should_check_response: bool = True,
@@ -203,7 +201,7 @@ def patch(
203201

204202
def delete(
205203
endpoint: str,
206-
data: Optional[dict] = None,
204+
data: dict | None = None,
207205
expected_status_code: int = 200,
208206
headers: dict = {},
209207
should_check_response: bool = True,
@@ -226,7 +224,7 @@ def delete(
226224

227225
def head(
228226
endpoint: str,
229-
data: Optional[dict] = None,
227+
data: dict | None = None,
230228
expected_status_code: int = 200,
231229
headers: dict = {},
232230
should_check_response: bool = True,
@@ -252,7 +250,7 @@ def head(
252250
def generic_http_helper(
253251
method: str,
254252
endpoint: str,
255-
data: Optional[dict] = None,
253+
data: dict | None = None,
256254
expected_status_code: int = 200,
257255
headers: dict = {},
258256
should_check_response: bool = True,

integration_tests/subroutes/__init__.py

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

77
sub_router = SubRouter(prefix="/sub_router")
88

9-
__all__ = ["sub_router", "di_subrouter", "static_router", "async_auth_subrouter", "inherited_auth_subrouter"]
9+
__all__ = ["async_auth_subrouter", "di_subrouter", "inherited_auth_subrouter", "static_router", "sub_router"]
1010

1111

1212
@sub_router.websocket("/ws")

integration_tests/test_basic_routes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# - most common return types
44
# - sync and async
55

6-
from typing import Optional
76

87
import pytest
98

@@ -36,8 +35,8 @@
3635
def test_basic_get(
3736
route: str,
3837
expected_text: str,
39-
expected_header_key: Optional[str],
40-
expected_header_value: Optional[str],
38+
expected_header_key: str | None,
39+
expected_header_value: str | None,
4140
session,
4241
):
4342
res = get(route)
@@ -59,7 +58,7 @@ def test_basic_get(
5958
)
6059
def test_json_get(route: str, expected_json: dict, session):
6160
res = get(route)
62-
for key in expected_json.keys():
61+
for key in expected_json:
6362
assert key in res.json()
6463
assert res.json()[key] == expected_json[key]
6564

@@ -94,6 +93,6 @@ def test_json_get(route: str, expected_json: dict, session):
9493
)
9594
def test_http_request_info_get(route: str, expected_json: dict, session):
9695
res = get(route)
97-
for key in expected_json.keys():
96+
for key in expected_json:
9897
assert key in res.json()
9998
assert res.json()[key] == expected_json[key]

robyn/__init__.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,30 +1168,30 @@ def cors_middleware(request):
11681168

11691169

11701170
__all__ = [
1171-
"Robyn",
1172-
"Request",
1173-
"Response",
1174-
"status_codes",
1175-
"jsonify",
1176-
"serve_file",
1177-
"serve_html",
1178-
"html",
1179-
"StreamingResponse",
1180-
"SSEResponse",
1181-
"SSEMessage",
11821171
"ALLOW_CORS",
1183-
"SubRouter",
11841172
"AuthenticationHandler",
11851173
"Headers",
1186-
"WebSocketConnector",
1187-
"WebSocketAdapter",
1188-
"WebSocketDisconnect",
11891174
"JsonBody",
11901175
"MCPApp",
1191-
"TestClient",
1192-
"RequestMethod",
1176+
"Request",
11931177
"RequestBody",
1178+
"RequestMethod",
11941179
"RequestURL",
1180+
"Response",
1181+
"Robyn",
1182+
"SSEMessage",
1183+
"SSEResponse",
11951184
"Session",
11961185
"SessionManager",
1186+
"StreamingResponse",
1187+
"SubRouter",
1188+
"TestClient",
1189+
"WebSocketAdapter",
1190+
"WebSocketConnector",
1191+
"WebSocketDisconnect",
1192+
"html",
1193+
"jsonify",
1194+
"serve_file",
1195+
"serve_html",
1196+
"status_codes",
11971197
]

robyn/_param_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import inspect
99
import logging
1010
import types
11-
from typing import Any, Dict, Optional, Set, Tuple, Union, get_args, get_origin
11+
from typing import Any, Union, get_args, get_origin
1212

1313
_logger = logging.getLogger(__name__)
1414

@@ -23,7 +23,7 @@ class QueryParamValidationError(Exception):
2323
"""Raised when a query or path parameter cannot be coerced to the expected type,
2424
or when a required parameter is missing."""
2525

26-
def __init__(self, param_name: str, value: Optional[str], expected_type: type, message: Optional[str] = None):
26+
def __init__(self, param_name: str, value: str | None, expected_type: type, message: str | None = None):
2727
self.param_name = param_name
2828
self.value = value
2929
self.expected_type = expected_type
@@ -36,7 +36,7 @@ def __init__(self, param_name: str, value: Optional[str], expected_type: type, m
3636
super().__init__(self.detail)
3737

3838

39-
def unwrap_optional(annotation) -> Tuple[Any, bool]:
39+
def unwrap_optional(annotation) -> tuple[Any, bool]:
4040
"""
4141
If annotation is Optional[T] (i.e. T | None / Union[T, None]), return (T, True).
4242
Handles both typing.Union and PEP 604 union syntax (X | Y).
@@ -91,11 +91,11 @@ def coerce_value(value: str, target_type: type, param_name: str):
9191

9292

9393
def resolve_individual_params(
94-
unresolved_params: Dict[str, inspect.Parameter],
94+
unresolved_params: dict[str, inspect.Parameter],
9595
query_params,
96-
path_params: Optional[Dict[str, str]],
97-
route_param_names: Set[str],
98-
) -> Dict[str, Any]:
96+
path_params: dict[str, str] | None,
97+
route_param_names: set[str],
98+
) -> dict[str, Any]:
9999
"""
100100
Resolve handler parameters as individual path or query parameters.
101101
@@ -167,7 +167,7 @@ def resolve_individual_params(
167167
return resolved
168168

169169

170-
def parse_route_param_names(endpoint: str) -> Set[str]:
170+
def parse_route_param_names(endpoint: str) -> set[str]:
171171
"""
172172
Extract parameter names from a route endpoint pattern.
173173
e.g. "/users/:id/posts/:post_id" -> {"id", "post_id"}

robyn/ai.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,14 @@ class MemoryProvider(ABC):
6666
@abstractmethod
6767
async def store(self, user_id: str, data: dict[str, Any]) -> None:
6868
"""Store data in memory"""
69-
pass
7069

7170
@abstractmethod
7271
async def retrieve(self, user_id: str, query: str | None = None) -> list[dict[str, Any]]:
7372
"""Retrieve data from memory"""
74-
pass
7573

7674
@abstractmethod
7775
async def clear(self, user_id: str) -> None:
7876
"""Clear memory for a user"""
79-
pass
8077

8178

8279
class InMemoryProvider(MemoryProvider):
@@ -132,7 +129,6 @@ class AgentRunner(ABC):
132129
@abstractmethod
133130
async def run(self, query: str, **kwargs) -> dict[str, Any]:
134131
"""Execute the agent with the given query"""
135-
pass
136132

137133

138134
class SimpleRunner(AgentRunner):

robyn/jsonify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import Any, Dict, List, Union
1+
from typing import Any
22

33
import orjson
44

55

6-
def jsonify(data: Union[Dict[str, Any], List[Any]]) -> str:
6+
def jsonify(data: dict[str, Any] | list[Any]) -> str:
77
"""
88
This function serializes input data to a json string
99

0 commit comments

Comments
 (0)