community: Bump ruff version to 0.9 (#29206)

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Christophe Bornet
2025-02-08 02:21:10 +01:00
committed by GitHub
parent 30f6c9f5c8
commit 723031d548
166 changed files with 5415 additions and 530 deletions

View File

@@ -70,7 +70,7 @@ class BibtexparserWrapper(BaseModel):
if "url" in entry:
url = entry["url"]
elif "doi" in entry:
url = f'https://doi.org/{entry["doi"]}'
url = f"https://doi.org/{entry['doi']}"
else:
url = None
meta = {

View File

@@ -433,7 +433,7 @@ class CassandraDatabase:
import cassio.config
except ImportError:
raise ValueError(
"cassio package not found, please install with" " `pip install cassio`"
"cassio package not found, please install with `pip install cassio`"
)
# Use pre-existing session on cassio
@@ -610,7 +610,11 @@ class Table(BaseModel):
partition_info.append((row["column_name"], row["position"]))
elif row["kind"] == "clustering":
cluster_info.append(
(row["column_name"], row["clustering_order"], row["position"])
(
row["column_name"],
row["clustering_order"],
row["position"],
)
)
partition = [

View File

@@ -460,7 +460,7 @@ class ClickupAPIWrapper(BaseModel):
if params["attribute_name"] not in task:
return {
"Error": f"""attribute_name = {params['attribute_name']} was not
"Error": f"""attribute_name = {params["attribute_name"]} was not
found in task keys {task.keys()}. Please call again with one of the key names."""
}

View File

@@ -20,8 +20,7 @@ def _import_tiktoken() -> Any:
import tiktoken
except ImportError:
raise ImportError(
"tiktoken is not installed. "
"Please install it with `pip install tiktoken`"
"tiktoken is not installed. Please install it with `pip install tiktoken`"
)
return tiktoken
@@ -90,8 +89,7 @@ class GitHubAPIWrapper(BaseModel):
installation = installation[0]
except ValueError as e:
raise ValueError(
"Please make sure to give correct github parameters "
f"Error message: {e}"
f"Please make sure to give correct github parameters Error message: {e}"
)
# create a GitHub instance:
g = installation.get_github_for_installation()
@@ -257,8 +255,7 @@ class GitHubAPIWrapper(BaseModel):
if branches:
branches_str = "\n".join(branches)
return (
f"Found {len(branches)} branches in the repository:"
f"\n{branches_str}"
f"Found {len(branches)} branches in the repository:\n{branches_str}"
)
else:
return "No branches found in the repository"
@@ -774,8 +771,7 @@ class GitHubAPIWrapper(BaseModel):
code.path, ref=self.active_branch
).decoded_content.decode()
results.append(
f"Filepath: `{code.path}`\nFile contents: "
f"{file_content}\n<END OF FILE>"
f"Filepath: `{code.path}`\nFile contents: {file_content}\n<END OF FILE>"
)
count += 1
return "\n".join(results)
@@ -839,9 +835,7 @@ class GitHubAPIWrapper(BaseModel):
results = [f"Top {max_results} results:"]
for release in releases[:max_results]:
results.append(
f"Title: {release.title}, "
f"Tag: {release.tag_name}, "
f"Body: {release.body}"
f"Title: {release.title}, Tag: {release.tag_name}, Body: {release.body}"
)
return "\n".join(results)
@@ -857,11 +851,7 @@ class GitHubAPIWrapper(BaseModel):
str: The release
"""
release = self.github_repo_instance.get_release(tag_name)
return (
f"Release: {release.title} "
f"tag: {release.tag_name} "
f"body: {release.body}"
)
return f"Release: {release.title} tag: {release.tag_name} body: {release.body}"
def run(self, mode: str, query: str) -> str:
if mode == "get_issue":

View File

@@ -138,7 +138,10 @@ class GitLabAPIWrapper(BaseModel):
for comment in comments_page:
comment = issue.notes.get(comment.id)
comments.append(
{"body": comment.body, "user": comment.author["username"]}
{
"body": comment.body,
"user": comment.author["username"],
}
)
page += 1

View File

@@ -84,7 +84,7 @@ class GooglePlacesAPIWrapper(BaseModel):
if details is not None:
places.append(details)
return "\n".join([f"{i+1}. {item}" for i, item in enumerate(places)])
return "\n".join([f"{i + 1}. {item}" for i, item in enumerate(places)])
def fetch_place_details(self, place_id: str) -> Optional[str]:
try:

View File

@@ -122,10 +122,10 @@ class GoogleScholarAPIWrapper(BaseModel):
if not total_results:
return "No good Google Scholar Result was found"
docs = [
f"Title: {result.get('title','')}\n"
f"Authors: {','.join([author.get('name') for author in result.get('publication_info',{}).get('authors',[])])}\n" # noqa: E501
f"Summary: {result.get('publication_info',{}).get('summary','')}\n"
f"Total-Citations: {result.get('inline_links',{}).get('cited_by',{}).get('total','')}" # noqa: E501
f"Title: {result.get('title', '')}\n"
f"Authors: {','.join([author.get('name') for author in result.get('publication_info', {}).get('authors', [])])}\n" # noqa: E501
f"Summary: {result.get('publication_info', {}).get('summary', '')}\n"
f"Total-Citations: {result.get('inline_links', {}).get('cited_by', {}).get('total', '')}" # noqa: E501
for result in total_results
]
return "\n\n".join(docs)

View File

@@ -123,7 +123,13 @@ class JiraAPIWrapper(BaseModel):
type = project["projectTypeKey"]
style = project["style"]
parsed.append(
{"id": id, "key": key, "name": name, "type": type, "style": style}
{
"id": id,
"key": key,
"name": name,
"type": type,
"style": style,
}
)
return parsed

View File

@@ -84,7 +84,7 @@ class MerriamWebsterAPIWrapper(BaseModel):
formatted_definitions.extend(self._format_definition(definition))
if len(formatted_definitions) == 1:
return f"Definition of '{query}':\n" f"{formatted_definitions[0]}"
return f"Definition of '{query}':\n{formatted_definitions[0]}"
result = f"Definitions of '{query}':\n\n"
for i, formatted_definition in enumerate(formatted_definitions, 1):

View File

@@ -211,8 +211,7 @@ class OpenAPISpec(OpenAPI):
)
else:
raise ValueError(
"Attempting to load an unsupported spec:"
f"\n\n{obj}\n{warning_message}"
f"Attempting to load an unsupported spec:\n\n{obj}\n{warning_message}"
)
@classmethod

View File

@@ -26,9 +26,9 @@ class Portkey:
cache_force_refresh: Optional[str] = None,
cache_age: Optional[int] = None,
) -> Dict[str, str]:
assert retry_count is None or retry_count in range(
1, 6
), "retry_count must be an integer and in range [1, 2, 3, 4, 5]"
assert retry_count is None or retry_count in range(1, 6), (
"retry_count must be an integer and in range [1, 2, 3, 4, 5]"
)
assert cache is None or cache in [
"simple",
"semantic",
@@ -37,9 +37,9 @@ class Portkey:
isinstance(cache_force_refresh, str)
and cache_force_refresh in ["True", "False"]
), "cache_force_refresh must be 'True' or 'False'"
assert cache_age is None or isinstance(
cache_age, int
), "cache_age must be an integer"
assert cache_age is None or isinstance(cache_age, int), (
"cache_age must be an integer"
)
os.environ["OPENAI_API_BASE"] = Portkey.base

View File

@@ -193,7 +193,11 @@ class PubMedAPIWrapper(BaseModel):
)
a_d = ar.get("ArticleDate", {})
pub_date = "-".join(
[a_d.get("Year", ""), a_d.get("Month", ""), a_d.get("Day", "")]
[
a_d.get("Year", ""),
a_d.get("Month", ""),
a_d.get("Day", ""),
]
)
return {

View File

@@ -24,8 +24,8 @@ from sqlalchemy.types import NullType
def _format_index(index: sqlalchemy.engine.interfaces.ReflectedIndex) -> str:
return (
f'Name: {index["name"]}, Unique: {index["unique"]},'
f' Columns: {str(index["column_names"])}'
f"Name: {index['name']}, Unique: {index['unique']},"
f" Columns: {str(index['column_names'])}"
)