mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-15 09:23:57 +00:00
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:
parent
5b9bdcac1b
commit
39a5d02225
@ -52,7 +52,7 @@ class MHTMLLoader(BaseLoader):
|
|||||||
message = email.message_from_string(f.read())
|
message = email.message_from_string(f.read())
|
||||||
parts = message.get_payload()
|
parts = message.get_payload()
|
||||||
|
|
||||||
if type(parts) is not list:
|
if not isinstance(parts, list):
|
||||||
parts = [message]
|
parts = [message]
|
||||||
|
|
||||||
for part in parts:
|
for part in parts:
|
||||||
|
@ -103,7 +103,7 @@ class MyScaleTranslator(Visitor):
|
|||||||
value = comparison.value
|
value = comparison.value
|
||||||
comp = comparison.comparator
|
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
|
# convert timestamp for datetime objects
|
||||||
if type(value) is datetime.date:
|
if type(value) is datetime.date:
|
||||||
|
@ -129,7 +129,7 @@ class SerpAPIWrapper(BaseModel):
|
|||||||
"""Process response from SerpAPI."""
|
"""Process response from SerpAPI."""
|
||||||
if "error" in res.keys():
|
if "error" in res.keys():
|
||||||
raise ValueError(f"Got error from SerpAPI: {res['error']}")
|
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]
|
res["answer_box"] = res["answer_box"][0]
|
||||||
if "answer_box" in res.keys() and "answer" in res["answer_box"].keys():
|
if "answer_box" in res.keys() and "answer" in res["answer_box"].keys():
|
||||||
toret = res["answer_box"]["answer"]
|
toret = res["answer_box"]["answer"]
|
||||||
|
@ -5,7 +5,7 @@ def test_joplin_loader() -> None:
|
|||||||
loader = JoplinLoader()
|
loader = JoplinLoader()
|
||||||
docs = loader.load()
|
docs = loader.load()
|
||||||
|
|
||||||
assert type(docs) is list
|
assert isinstance(docs, list)
|
||||||
assert type(docs[0].page_content) is str
|
assert isinstance(docs[0].page_content, str)
|
||||||
assert type(docs[0].metadata["source"]) is str
|
assert isinstance(docs[0].metadata["source"], str)
|
||||||
assert type(docs[0].metadata["title"]) is str
|
assert isinstance(docs[0].metadata["title"], str)
|
||||||
|
Loading…
Reference in New Issue
Block a user