Skip to content

Commit d3d3fd1

Browse files
committed
Fix mypy
1 parent 26132f7 commit d3d3fd1

File tree

1 file changed

+7
-1
lines changed
  • python/jupyterlab-chat/jupyterlab_chat

1 file changed

+7
-1
lines changed

python/jupyterlab-chat/jupyterlab_chat/ychat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,13 @@ async def _set_timestamp(self, msg_idx: int, timestamp: float):
370370
# should be the last one.
371371
# The next() function below return the index of the first message with a timestamp inferior of the
372372
# current one, starting from the end of the list.
373-
new_idx = len(self._ymessages) - next((i for i, v in enumerate(self._get_messages()[::-1]) if v.get("time") < timestamp), len(self._ymessages))
373+
new_idx = len(self._ymessages) - 1
374+
for i, v in enumerate(self._get_messages()[::-1]):
375+
new_idx = len(self._ymessages) - i
376+
t = v.get("time")
377+
if t is not None and (t < timestamp):
378+
break
379+
374380
if msg_idx != new_idx:
375381
message = self._ymessages.pop(msg_idx)
376382
self._ymessages.insert(new_idx, message)

0 commit comments

Comments
 (0)