Skip to content

Commit

Permalink
Fix logging syntax to not containt f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
amureki committed Apr 24, 2024
1 parent c549967 commit e1d8ba4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sam/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async def add_message(
files: [(str, bytes)] = None,
) -> tuple[bool, bool]:
"""Add a message to the thread."""
logger.info(f"Adding message to thread={thread_id}")
logger.info("Adding message to thread %s", thread_id)
client: openai.AsyncOpenAI = openai.AsyncOpenAI()
file_ids = []
voice_prompt = False
Expand Down
19 changes: 11 additions & 8 deletions sam/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ async def get_bot_user_id():
logger.debug("Fetching the bot's user id")
response = await client.auth_test()
_USER_HANDLE = response["user_id"]
logger.debug(f"Bot's user id is {_USER_HANDLE}")
logger.debug("Bot's user id is %s", _USER_HANDLE)
return _USER_HANDLE


async def handle_message(event: {str, Any}, say: AsyncSay):
"""Handle a message event from Slack."""
logger.debug(f"handle_message={json.dumps(event)}")
if event.get("subtype") in ["message_changed", "message_deleted"]:
logger.debug(f"Ignoring `{event['subtype']}` event {event}")
return
logger.debug("Ignoring `%s` event", event["subtype"])
return

Check failure on line 59 in sam/slack.py

View workflow job for this annotation

GitHub Actions / lint (ruff check --output-format=github .)

Ruff (W291)

sam/slack.py:59:15: W291 Trailing whitespace
bot_id = await get_bot_user_id()
channel_id = event["channel"]
channel_type = event["channel_type"]
Expand Down Expand Up @@ -128,7 +127,7 @@ async def send_response(
voice_response: bool = False,
):
"""Send a response to a message event from Slack."""
logger.debug(f"process_run={json.dumps(event)}")
logger.debug("process_run=%s", json.dumps(event))
channel_id = event["channel"]
user_id = event["user"]
try:
Expand All @@ -142,7 +141,7 @@ async def send_response(
redis.from_url(config.REDIS_URL) as redis_client,
redis_client.lock(thread_id, timeout=10 * 60),
): # 10 minutes
logger.info(f"User={user_id} starting run for Thread={thread_id}")
logger.info("User=%s starting run for Thread=%s", user_id, thread_id)
await say.client.reactions_add(
channel=channel_id,
name=random.choice(ACKNOWLEDGMENT_SMILEYS), # noqa: S311
Expand All @@ -163,7 +162,9 @@ async def send_response(
thread_ts=event.get("thread_ts", None),
)
logger.info(
f"Sam responded to the User={user_id} in Channel={channel_id} via Text"
"Sam responded to the User=%s in Channel=%s via Text",
user_id,
channel_id,
)

if voice_response:
Expand All @@ -176,7 +177,9 @@ async def send_response(
ts=msg["ts"],
)
logger.info(
f"Sam responded to the User={user_id} in Channel={channel_id} via Voice"
"Sam responded to the User=%s in Channel=%s via Voice",
user_id,
channel_id,
)


Expand Down

0 comments on commit e1d8ba4

Please sign in to comment.