ref: Add ruff rules for print (T20) (#4082)

Add ruff rules for print (T20)
This commit is contained in:
Christophe Bornet 2024-10-10 00:28:28 +02:00 committed by GitHub
commit 4e36dcc2ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 16 additions and 12 deletions

View file

@ -142,7 +142,7 @@ class AssemblyAILeMUR(Component):
return Data(data={"error": error})
def perform_lemur_action(self, transcript_group: aai.TranscriptGroup, endpoint: str) -> dict:
print("Endpoint:", endpoint, type(endpoint))
logger.info("Endpoint:", endpoint, type(endpoint))
if endpoint == "task":
result = transcript_group.lemur.task(
prompt=self.prompt,

View file

@ -1,6 +1,7 @@
import asyncio
from astra_assistants.astra_assistants_manager import AssistantManager
from loguru import logger
from langflow.base.astra_assistants.util import (
get_patched_openai_client,
@ -99,8 +100,8 @@ class AstraAssistantManager(ComponentWithCache):
self.initialized = True
async def process_inputs(self):
print(f"env_set is {self.env_set}")
print(self.tool)
logger.info(f"env_set is {self.env_set}")
logger.info(self.tool)
tools = []
tool_obj = None
if self.tool is not None and self.tool != "":

View file

@ -1,3 +1,5 @@
from loguru import logger
from langflow.base.astra_assistants.util import get_patched_openai_client
from langflow.custom.custom_component.component_with_cache import ComponentWithCache
from langflow.inputs import MultilineInput, StrInput
@ -48,7 +50,7 @@ class AssistantsCreateAssistant(ComponentWithCache):
self.client = get_patched_openai_client(self._shared_component_cache)
def process_inputs(self) -> Message:
print(f"env_set is {self.env_set}")
logger.info(f"env_set is {self.env_set}")
assistant = self.client.beta.assistants.create(
name=self.assistant_name,
instructions=self.instructions,

View file

@ -11,6 +11,7 @@ from googleapiclient.discovery import build
from langchain_core.chat_sessions import ChatSession
from langchain_core.messages import HumanMessage
from langchain_google_community.gmail.loader import GMailLoader
from loguru import logger
from langflow.custom import Component
from langflow.inputs import MessageTextInput
@ -150,15 +151,15 @@ class GmailLoaderComponent(Component):
)
messages = results.get("messages", [])
if not messages:
print("No messages found with the specified labels.")
logger.warning("No messages found with the specified labels.")
for message in messages:
try:
yield self._get_message_data(service, message)
except Exception as e:
except Exception:
if self.raise_error:
raise
else:
print(f"Error processing message {message['id']}: {e}")
logger.exception(f"Error processing message {message['id']}")
json_string = self.json_string
label_ids = self.label_ids.split(",") if self.label_ids else ["INBOX"]

View file

@ -3,6 +3,7 @@ from json import JSONDecodeError
import jq
from json_repair import repair_json
from loguru import logger
from langflow.custom import Component
from langflow.inputs import HandleInput, MessageTextInput
@ -67,8 +68,8 @@ class ParseJSONDataComponent(Component):
full_filter_str = json.dumps(to_filter_as_dict)
print("to_filter: ", to_filter)
logger.info("to_filter: ", to_filter)
results = jq.compile(self.query).input_text(full_filter_str).all()
print("results: ", results)
logger.info("results: ", results)
return [Data(data=value) if isinstance(value, dict) else Data(text=str(value)) for value in results]

View file

@ -57,7 +57,7 @@ class AsciiCanvas:
def draw(self):
"""Draws ASCII canvas on the screen."""
lines = self.get_lines()
print("\n".join(lines))
print("\n".join(lines)) # noqa: T201
def point(self, x, y, char):
"""Create a point on ASCII canvas."""

View file

@ -25,7 +25,7 @@ def set_secure_permissions(file_path: Path):
sd.SetSecurityDescriptorDacl(1, dacl, 0)
win32security.SetFileSecurity(str(file_path), win32security.DACL_SECURITY_INFORMATION, sd)
else:
print("Unsupported OS")
logger.error("Unsupported OS")
def write_secret_to_file(path: Path, value: str) -> None:

View file

@ -62,7 +62,6 @@ ignore = [
"N",
"S",
"SLF",
"T201",
"TRY3",
]