core: Add various ruff rules (#26836)

Adds
- ASYNC
- COM
- DJ
- EXE
- FLY
- FURB
- ICN
- INT
- LOG
- NPY
- PD
- Q
- RSE
- SLOT
- T10
- TID
- YTT

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Christophe Bornet
2024-10-08 00:30:27 +02:00
committed by GitHub
parent 5c826faece
commit 16f5fdb38b
27 changed files with 108 additions and 53 deletions

View File

@@ -1,3 +1,4 @@
import asyncio
import base64
import re
from dataclasses import asdict
@@ -289,9 +290,14 @@ async def _render_mermaid_using_pyppeteer(
img_bytes = await page.screenshot({"fullPage": False})
await browser.close()
def write_to_file(path: str, bytes: bytes) -> None:
with open(path, "wb") as file:
file.write(bytes)
if output_file_path is not None:
with open(output_file_path, "wb") as file:
file.write(img_bytes)
await asyncio.get_event_loop().run_in_executor(
None, write_to_file, output_file_path, img_bytes
)
return img_bytes