Skip to content

Conversation

@DoraFgr
Copy link

@DoraFgr DoraFgr commented Oct 22, 2025

This PR is a small part of #6 and implements the broadcasts.get_top endpoint

Summary:

  • Implement client.broadcasts.get_top (supports page and html).
  • Add BroadcastTopResponse TypedDict, tests, README and changelog updates.
  • Add test_broadcasts.py

Validation:

  • make test (51 passed)
  • make typecheck (pyright: 0 errors)
  • make format (black/docformatter: no changes)
Checklist when adding a new endpoint
  • Added new endpoint to the README.md
  • Ensured that my endpoint name does not repeat the name of the client. Wrong: client.users.get_user(), Correct: client.users.get()
  • Typed the returned JSON using TypedDicts in berserk/types/, example
  • Written tests for GET endpoints not requiring authentification. Documentation, example
  • Added the endpoint and your name to CHANGELOG.md in the To be released section (to be created if necessary)

Copy link
Member

@kraktus kraktus left a comment

Choose a reason for hiding this comment

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

Hey, thanks for the work! Generally remember to review your LLM-generated work before posting. It frequently add runtimes checks were types are enough.

Left a couple comments, keep it up!



@skip_if_older_3_dot_10
def test_get_top_valid(requests_mock):
Copy link
Member

Choose a reason for hiding this comment

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

This test does not test anything. There’s no logic in the code, so no need to test that. We actually want to check these server’s response, so it needs to be a VCR test, see CONTRIBUTING.

Copy link
Author

Choose a reason for hiding this comment

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

I removed the mock test and added a VCR test as documented in CONTRIBUTING.

class BroadcastTopResponse(TypedDict):
"""Minimal TypedDict for /api/broadcast/top response."""

# List of active broadcasts
Copy link
Member

Choose a reason for hiding this comment

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

Needs to be more precise to be useful

Copy link
Author

Choose a reason for hiding this comment

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

I added the Type as shows in the lichess API/Docs/Specs/Schema

@DoraFgr
Copy link
Author

DoraFgr commented Oct 22, 2025

Thanks for the swift review. I didn't knew to avoid instance validation at runtime if using typechecking. I will work on these change to make sure the code is on par with the standard. I will set the PR back to draft while I work on this issue.

@DoraFgr DoraFgr marked this pull request as draft October 22, 2025 22:06
@DoraFgr
Copy link
Author

DoraFgr commented Oct 23, 2025

@kraktus Thanks again for the review.

I have adressed the feedback:

  • Removed runtime type validation
  • Replaced Mock test for a VCR test
  • Defined a complete BroadcastTop Type object using the Lichess API/Docs/Specs/Schema

I have also taken the liberty of renaming the Type Object BroadcastTopResponse into BroadcastTop to be align with the API documentation.

The PR should now be ready for another look.
Thank you!

@DoraFgr DoraFgr marked this pull request as ready for review October 23, 2025 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants