Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ plugins = [
[tool.pyrefly]
search_path = [ "." ]
errors.non-exhaustive-match = "error"
preset = "strict"

[tool.pyright]
typeCheckingMode = "strict"
Expand Down
3 changes: 2 additions & 1 deletion src/coderpad/screen_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Types for the CoderPad Screen API."""

from typing import ClassVar, Self, TypeGuard
from typing import ClassVar, Self, TypeGuard, override

from beartype import beartype
from pydantic import BaseModel, ConfigDict, Field, model_validator
Expand Down Expand Up @@ -366,6 +366,7 @@ def from_dict(cls, data: dict[str, object]) -> Self:
else None,
)

@override
def __repr__(self) -> str:
"""Return a concise debug representation."""
return (
Expand Down
13 changes: 12 additions & 1 deletion src/coderpad/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ def apply(self, *, contents: str) -> str:
return "".join(updated)


def _history_sort_key(
item: tuple[str, PadHistoryEntryDict],
/,
) -> tuple[int, str]:
"""Return the sort key for a Firebase history entry: timestamp, then
ID.
"""
entry_id, entry = item
return (entry["t"], entry_id)


@beartype
class PadHistory(list[PadHistoryEntry]):
"""Chronologically ordered editor history for a pad file."""
Expand All @@ -442,7 +453,7 @@ def from_dict(
"""
ordered_entries = sorted(
data.items(),
key=lambda item: (item[1]["t"], item[0]),
key=_history_sort_key,
)
history = cls()
for entry_id, entry in ordered_entries:
Expand Down
Loading