Skip to content

feat: improve peer list display#9440

Open
pjwerneck wants to merge 8 commits into
devfrom
pjwerneck/improve-peer-list-display
Open

feat: improve peer list display#9440
pjwerneck wants to merge 8 commits into
devfrom
pjwerneck/improve-peer-list-display

Conversation

@pjwerneck

Copy link
Copy Markdown
Collaborator

Summary

Improve peer list display with a clean summary when accessed in a notebook cell.

Changes

  • Add/modify __str__()_/_repr_html_ methods to PeerList that return a clean summary. __repr__'s current behavior is preserved.
  • Modify PeerList to use composition instead of inheriting from list (LSP violation corrected).

Testing

  • Test cases added to tests/unit/test_peer_list_repr.py
  • Visually confirmed on running notebook

Asana task

https://app.asana.com/1/1185126988600652/project/1210542925864934/task/1214408876227005?focus=true

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the notebook/terminal display of PeerList by adding a human-friendly summary via __str__ and _repr_html_, while keeping __repr__ as a technical/debug representation. It also refactors PeerList from inheriting list to using composition, aligning better with LSP and making the API surface more explicit.

Changes:

  • Refactor PeerList to store an internal list[Peer] and implement core sequence behaviors (__len__, __iter__, __getitem__).
  • Add a clean summary renderer (_summary_text), used by __str__ and _repr_html_ (with HTML escaping and an opt-out env var).
  • Add unit tests covering summary rendering, HTML escaping/disable flag, indexing semantics, and sorting stability.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
syft_client/sync/peers/peer_list.py Implements composition-based PeerList plus new human-friendly text/HTML summary rendering.
tests/unit/test_peer_list_repr.py Adds tests validating string/HTML representations and list-like behaviors (len/iter/getitem/sort).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread syft_client/sync/peers/peer_list.py Outdated
Comment thread syft_client/sync/peers/peer_list.py Outdated
Comment thread syft_client/sync/peers/peer_list.py
- Add __str__ and _repr_html_ that print a clean summary when accessed in a notebook cell.
- Preserve current __repr__ behavior.
There's no good reason for PeerList to inherit from list. It's a LSP
violation and no code relies on it being a list.
@pjwerneck pjwerneck force-pushed the pjwerneck/improve-peer-list-display branch from 06affa5 to 6a16cef Compare July 14, 2026 17:01
@pjwerneck pjwerneck requested a review from Copilot July 14, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread syft_client/sync/peers/peer_list.py Outdated
@pjwerneck pjwerneck requested a review from koenvanderveen July 14, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants