Cleanup of ruff warnings use isinstance() instead of type() (#9655)

Minor cosmetic PR just cleanup of `ruff` warnings use `isinstance()`
instead of `type()`
This commit is contained in:
Guy Korland 2023-08-23 17:14:31 +03:00 committed by GitHub
parent 5b9bdcac1b
commit 39a5d02225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -52,7 +52,7 @@ class MHTMLLoader(BaseLoader):
message = email.message_from_string(f.read())
parts = message.get_payload()
if type(parts) is not list:
if not isinstance(parts, list):
parts = [message]
for part in parts:

View File

@ -103,7 +103,7 @@ class MyScaleTranslator(Visitor):
value = comparison.value
comp = comparison.comparator
value = f"'{value}'" if type(value) is str else value
value = f"'{value}'" if isinstance(value, str) else value
# convert timestamp for datetime objects
if type(value) is datetime.date:

View File

@ -129,7 +129,7 @@ class SerpAPIWrapper(BaseModel):
"""Process response from SerpAPI."""
if "error" in res.keys():
raise ValueError(f"Got error from SerpAPI: {res['error']}")
if "answer_box" in res.keys() and type(res["answer_box"]) == list:
if "answer_box" in res.keys() and isinstance(res["answer_box"], list):
res["answer_box"] = res["answer_box"][0]
if "answer_box" in res.keys() and "answer" in res["answer_box"].keys():
toret = res["answer_box"]["answer"]

View File

@ -5,7 +5,7 @@ def test_joplin_loader() -> None:
loader = JoplinLoader()
docs = loader.load()
assert type(docs) is list
assert type(docs[0].page_content) is str
assert type(docs[0].metadata["source"]) is str
assert type(docs[0].metadata["title"]) is str
assert isinstance(docs, list)
assert isinstance(docs[0].page_content, str)
assert isinstance(docs[0].metadata["source"], str)
assert isinstance(docs[0].metadata["title"], str)