Skip to content

Conversation

@srachmiletter
Copy link

Implements /api/timeline endpoint documented here.

Checklist when adding a new endpoint
  • Added new endpoint to the README.md
  • Ensure 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
  • Tested 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)

Comment on lines +100 to +102
class TimelineEvents(TypedDict):
entries: list[dict[str, Any]]
users: dict[str, Any]
Copy link
Member

Choose a reason for hiding this comment

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

Good day, the idea is not to have any Any in the response type.

Copy link

Choose a reason for hiding this comment

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

Something like this?

class TimelineEvent(TypedDict):
  type: str
  data: dict[str, str | bool]
  date: int
 
class TimelineUser(TypedDict):  
  id: str
  name: str
  title: str
  patron: NotRequired[bool]

lass TimelineEvents(TypedDict):
    entries: list[TimelineEvent]
    users: dict[str, TimelineUser]

Defining all the different event-data dicts seems quite unproductive

This is not tested, just trying to get this PR implemented faster...

Comment on lines +70 to +71
:param int since: timestamp to show events since, default 1356998400070
:param int nb: max number of events to fetch, default 15
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:param int since: timestamp to show events since, default 1356998400070
:param int nb: max number of events to fetch, default 15
:param since: only show events after this timestamp, default 1356998400070 (the earliest allowed by Lichess)
:param nb: max number of events to fetch, default 15

We generally leave out the types here since they are already given via the type hints.

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.

4 participants