example of remove some reflections (#24488)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Asuka Minato
2025-08-26 00:16:59 +09:00
committed by GitHub
parent 3df04c7e9a
commit 99fec40117

View File

@@ -275,23 +275,20 @@ class ApiTool(Tool):
if files: if files:
headers.pop("Content-Type", None) headers.pop("Content-Type", None)
if method in { _METHOD_MAP = {
"get", "get": ssrf_proxy.get,
"head", "head": ssrf_proxy.head,
"post", "post": ssrf_proxy.post,
"put", "put": ssrf_proxy.put,
"delete", "delete": ssrf_proxy.delete,
"patch", "patch": ssrf_proxy.patch,
"options", }
"GET", method_lc = method.lower()
"POST", if method_lc not in _METHOD_MAP:
"PUT", raise ValueError(f"Invalid http method {method}")
"PATCH", response: httpx.Response = _METHOD_MAP[
"DELETE", method_lc
"HEAD", ]( # https://discuss.python.org/t/type-inference-for-function-return-types/42926
"OPTIONS",
}:
response: httpx.Response = getattr(ssrf_proxy, method.lower())(
url, url,
params=params, params=params,
headers=headers, headers=headers,
@@ -302,8 +299,6 @@ class ApiTool(Tool):
follow_redirects=True, follow_redirects=True,
) )
return response return response
else:
raise ValueError(f"Invalid http method {method}")
def _convert_body_property_any_of( def _convert_body_property_any_of(
self, property: dict[str, Any], value: Any, any_of: list[dict[str, Any]], max_recursive=10 self, property: dict[str, Any], value: Any, any_of: list[dict[str, Any]], max_recursive=10