feat: improve peer list display#9440
Open
pjwerneck wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
PeerListto store an internallist[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.
- 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.
06affa5 to
6a16cef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improve peer list display with a clean summary when accessed in a notebook cell.
Changes
__str__()_/_repr_html_methods toPeerListthat return a clean summary.__repr__'s current behavior is preserved.PeerListto use composition instead of inheriting fromlist(LSP violation corrected).Testing
tests/unit/test_peer_list_repr.pyAsana task
https://app.asana.com/1/1185126988600652/project/1210542925864934/task/1214408876227005?focus=true