Skip to content

Conversation

@FriedrichtenHagen
Copy link

@FriedrichtenHagen FriedrichtenHagen commented Dec 13, 2024

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)

@FriedrichtenHagen FriedrichtenHagen marked this pull request as ready for review December 13, 2024 14:20
@kraktus kraktus requested a review from Copilot August 7, 2025 17:25
Copy link

Copilot AI left a comment

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 adds three new broadcast endpoints to the berserk library: get_top, get_by_user, and reset_round. These endpoints provide access to top broadcast listings, user-specific broadcasts, and broadcast round reset functionality respectively.

Key changes:

  • Added three new broadcast client methods with proper type annotations
  • Created comprehensive TypedDict definitions for broadcast-related data structures
  • Implemented comprehensive test coverage for the new endpoints

Reviewed Changes

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

Show a summary per file
File Description
berserk/clients/broadcasts.py Implements the three new broadcast endpoints with proper parameter validation and return types
berserk/types/broadcast.py Defines comprehensive TypedDict structures for broadcast data including pagination, tour info, and round details
berserk/types/__init__.py Exports the new PaginatedTopBroadcasts type for public API usage
berserk/__init__.py Adds the new type to the main package exports
tests/clients/test_broadcasts.py Provides comprehensive test coverage for all new endpoints including type validation and parameter passing
README.rst Documents the new endpoints in the API reference
CHANGELOG.rst Records the new features and contributor acknowledgments

from berserk import Client, PaginatedTopBroadcasts
from utils import validate, skip_if_older_3_dot_10

import requests_mock
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The requests_mock import is duplicated. It's already imported on line 2, so this duplicate import should be removed.

Suggested change
import requests_mock

Copilot uses AI. Check for mistakes.
:param page: page number. Defaults to 1
:param html: Convert the "description" field from markdown to HTML
"""
path = f"https://lichess.org/api/broadcast/by/{username}"
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The path should not include the full URL with domain. It should be a relative path like f"api/broadcast/by/{username}" to be consistent with other endpoints in the same class.

Suggested change
path = f"https://lichess.org/api/broadcast/by/{username}"
path = f"api/broadcast/by/{username}"

Copilot uses AI. Check for mistakes.

class BroadcastByUserCurrentPageResult(TypedDict, total=False):
round: BroadcastRoundInfo
tour: BroadcastTourInfo
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The type should be BroadcastTour instead of BroadcastTourInfo. Looking at the structure, this should match the same tour type used in BroadcastWithLastRound.

Suggested change
tour: BroadcastTourInfo
tour: BroadcastTour

Copilot uses AI. Check for mistakes.
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.

1 participant