chore: improve usage of striping prefix or suffix of string with Ruff 0.6.5 (#8392)

This commit is contained in:
Bowen Liang
2024-09-13 23:34:39 +08:00
committed by GitHub
parent aad6f340b3
commit 5b98acde2f
20 changed files with 44 additions and 60 deletions

View File

@@ -30,7 +30,7 @@ class AddWorksheetRecordTool(BuiltinTool):
elif not host.startswith(("http://", "https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url = f"{host}/v2/open/worksheet/addRow"
headers = {"Content-Type": "application/json"}

View File

@@ -29,7 +29,7 @@ class DeleteWorksheetRecordTool(BuiltinTool):
elif not host.startswith(("http://", "https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url = f"{host}/v2/open/worksheet/deleteRow"
headers = {"Content-Type": "application/json"}

View File

@@ -27,7 +27,7 @@ class GetWorksheetFieldsTool(BuiltinTool):
elif not host.startswith(("http://", "https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url = f"{host}/v2/open/worksheet/getWorksheetInfo"
headers = {"Content-Type": "application/json"}

View File

@@ -38,7 +38,7 @@ class GetWorksheetPivotDataTool(BuiltinTool):
elif not host.startswith(("http://", "https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url = f"{host}/report/getPivotData"
headers = {"Content-Type": "application/json"}

View File

@@ -30,7 +30,7 @@ class ListWorksheetRecordsTool(BuiltinTool):
elif not (host.startswith("http://") or host.startswith("https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url_fields = f"{host}/v2/open/worksheet/getWorksheetInfo"
headers = {"Content-Type": "application/json"}

View File

@@ -24,7 +24,7 @@ class ListWorksheetsTool(BuiltinTool):
elif not (host.startswith("http://") or host.startswith("https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url = f"{host}/v1/open/app/get"
result_type = tool_parameters.get("result_type", "")

View File

@@ -33,7 +33,7 @@ class UpdateWorksheetRecordTool(BuiltinTool):
elif not host.startswith(("http://", "https://")):
return self.create_text_message("Invalid parameter Host Address")
else:
host = f"{host[:-1] if host.endswith('/') else host}/api"
host = f"{host.removesuffix('/')}/api"
url = f"{host}/v2/open/worksheet/editRow"
headers = {"Content-Type": "application/json"}