Skip to content

Commit

Permalink
All the Linters
Browse files Browse the repository at this point in the history
  • Loading branch information
dokterbob committed Nov 19, 2024
1 parent cc44a56 commit f356a42
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions backend/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def copy_directory(src, dst, description):
shutil.rmtree(dst)
raise
except Exception as e:
raise BuildError(f"Failed to copy {src} to {dst}: {str(e)}")
raise BuildError(f"Failed to copy {src} to {dst}: {e!s}")


def copy_frontend(project_root):
Expand Down Expand Up @@ -91,10 +91,10 @@ def build():
print("\nBuild interrupted by user")
sys.exit(1)
except BuildError as e:
print(f"\nBuild failed: {str(e)}")
print(f"\nBuild failed: {e!s}")
sys.exit(1)
except Exception as e:
print(f"\nUnexpected error: {str(e)}")
print(f"\nUnexpected error: {e!s}")
sys.exit(1)


Expand Down
4 changes: 2 additions & 2 deletions backend/chainlit/data/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,15 @@ async def delete_thread(self, thread_id: str):

BATCH_ITEM_SIZE = 25 # pylint: disable=invalid-name
for i in range(0, len(delete_requests), BATCH_ITEM_SIZE):
chunk = delete_requests[i : i + BATCH_ITEM_SIZE] # noqa: E203
chunk = delete_requests[i : i + BATCH_ITEM_SIZE]
response = self.client.batch_write_item(
RequestItems={
self.table_name: chunk, # type: ignore
}
)

backoff_time = 1
while "UnprocessedItems" in response and response["UnprocessedItems"]:
while response.get("UnprocessedItems"):
backoff_time *= 2
# Cap the backoff time at 32 seconds & add jitter
delay = min(backoff_time, 32) + random.uniform(0, 1)
Expand Down
2 changes: 1 addition & 1 deletion backend/chainlit/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def _create(self) -> bool:
try:
asyncio.create_task(data_layer.create_element(self))
except Exception as e:
logger.error(f"Failed to create element: {str(e)}")
logger.error(f"Failed to create element: {e!s}")
if not self.url and (not self.chainlit_key or self.updatable):
file_dict = await context.session.persist_file(
name=self.name,
Expand Down
6 changes: 3 additions & 3 deletions backend/chainlit/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def update(
except Exception as e:
if self.fail_on_persist_error:
raise e
logger.error(f"Failed to persist message update: {str(e)}")
logger.error(f"Failed to persist message update: {e!s}")

await context.emitter.update_step(step_dict)

Expand All @@ -134,7 +134,7 @@ async def remove(self):
except Exception as e:
if self.fail_on_persist_error:
raise e
logger.error(f"Failed to persist message deletion: {str(e)}")
logger.error(f"Failed to persist message deletion: {e!s}")

await context.emitter.delete_step(step_dict)

Expand All @@ -150,7 +150,7 @@ async def _create(self):
except Exception as e:
if self.fail_on_persist_error:
raise e
logger.error(f"Failed to persist message creation: {str(e)}")
logger.error(f"Failed to persist message creation: {e!s}")

return step_dict

Expand Down
6 changes: 3 additions & 3 deletions backend/chainlit/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ async def update(self):
except Exception as e:
if self.fail_on_persist_error:
raise e
logger.error(f"Failed to persist step update: {str(e)}")
logger.error(f"Failed to persist step update: {e!s}")

tasks = [el.send(for_id=self.id) for el in self.elements]
await asyncio.gather(*tasks)
Expand All @@ -345,7 +345,7 @@ async def remove(self):
except Exception as e:
if self.fail_on_persist_error:
raise e
logger.error(f"Failed to persist step deletion: {str(e)}")
logger.error(f"Failed to persist step deletion: {e!s}")

await context.emitter.delete_step(step_dict)

Expand All @@ -372,7 +372,7 @@ async def send(self):
except Exception as e:
if self.fail_on_persist_error:
raise e
logger.error(f"Failed to persist step creation: {str(e)}")
logger.error(f"Failed to persist step creation: {e!s}")

tasks = [el.send(for_id=self.id) for el in self.elements]
await asyncio.gather(*tasks)
Expand Down
4 changes: 2 additions & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ target-version = "py39"
line-length = 120

[tool.ruff.lint]
select = ["E", "F", "I", "LOG", "UP", "T10", "ISC", "ICN", "LOG", "G", "PIE", "PT", "Q", "RSE"]
ignore = ["E712", "E501", "UP006", "UP035","PIE790", "PT004"]
select = ["E", "F", "I", "LOG", "UP", "T10", "ISC", "ICN", "LOG", "G", "PIE", "PT", "Q", "RSE", "FURB", "RUF"]
ignore = ["E712", "E501", "UP006", "UP035","PIE790", "PT004", "RUF005", "RUF006", "RUF012"]

[tool.ruff.lint.isort]
combine-as-imports = true

0 comments on commit f356a42

Please sign in to comment.