chore: apply ruff's pyupgrade linter rules to modernize Python code with targeted version (#2419)

This commit is contained in:
Bowen Liang
2024-02-09 15:21:33 +08:00
committed by GitHub
parent 589099a005
commit 063191889d
246 changed files with 912 additions and 937 deletions

View File

@@ -1,5 +1,4 @@
from datetime import datetime
from typing import Type
from langchain.tools import BaseTool
from pydantic import BaseModel, Field
@@ -12,7 +11,7 @@ class DatetimeToolInput(BaseModel):
class DatetimeTool(BaseTool):
"""Tool for querying current datetime."""
name: str = "current_datetime"
args_schema: Type[BaseModel] = DatetimeToolInput
args_schema: type[BaseModel] = DatetimeToolInput
description: str = "A tool when you want to get the current date, time, week, month or year, " \
"and the time zone is UTC. Result is \"<date> <time> <timezone> <week>\"."

View File

@@ -7,7 +7,7 @@ import subprocess
import tempfile
import unicodedata
from contextlib import contextmanager
from typing import Any, Type
from typing import Any
import requests
from bs4 import BeautifulSoup, CData, Comment, NavigableString
@@ -56,7 +56,7 @@ class WebReaderTool(BaseTool):
"""Reader tool for getting website title and contents. Gives more control than SimpleReaderTool."""
name: str = "web_reader"
args_schema: Type[BaseModel] = WebReaderToolInput
args_schema: type[BaseModel] = WebReaderToolInput
description: str = "use this to read a website. " \
"If you can answer the question based on the information provided, " \
"there is no need to use."
@@ -208,7 +208,7 @@ def extract_using_readabilipy(html):
subprocess.check_call(["node", "ExtractArticle.js", "-i", html_path, "-o", article_json_path])
# Read output of call to Readability.parse() from JSON file and return as Python dictionary
with open(article_json_path, "r", encoding="utf-8") as json_file:
with open(article_json_path, encoding="utf-8") as json_file:
input_json = json.loads(json_file.read())
# Deleting files after processing