feat: use dataclass instead of plain dict for responses#17
Open
jrester wants to merge 1 commit intomondbaron:mainfrom
Open
feat: use dataclass instead of plain dict for responses#17jrester wants to merge 1 commit intomondbaron:mainfrom
dataclass instead of plain dict for responses#17jrester wants to merge 1 commit intomondbaron:mainfrom
Conversation
61b2f4a to
f8f3dd0
Compare
mondbaron
reviewed
Oct 25, 2025
Owner
mondbaron
left a comment
There was a problem hiding this comment.
Thx for the proposal. As this is a breaking change, I won't immediatly merge it. For now I rebased on merged #15 and #16, some tests I introduced in earlier PR are failing.
If we introduce a breaking change in returned data format, I'd be in favor of keeping all old tests, and adding new for the new dataformat. An additional paramter can be added to request a dataclass result. If we want to default this behavior in future releases, I'd suggest to add a future deprecation warning, when this parameter is not set by the user.
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.
This is a proposal to change the responses of all API calls to use
dataclassinstead of plaindict. In my opinion this makes it easier to work with the API in third party applications and libraries since the responses are now typed. Additionally, it enables the relative accessors for departure time and makes it easier to de-duplicate response objects (e.g., lines), becausedictis not hashable but a frozendataclassis.For backwards compatibility I kept the
dictstyle key access for all response objects. This means thatstation["id"]is still valid and existing code should not break completely.This is already based on #15, but I wanted to split this into a separate MR since this is a quite significant change. It also includes the changes from #16.
What do you think about the proposal?