feat: `Activity` dataclass
and ci: dependency group instead of optional dependency for linting
I've had some troubles pleasing mypy, so please check if I've made a mistake before considering to merge. :)
Also: your Data class is focused on there being one of "it" per day. I'm not sure how to best reconcile it with activities.
Summary by CodeRabbit
-
New Features
- Added
Activityclass to data module, enabling retrieval and management of activity information - Introduced new utility functions for processing dictionary keys
- Added
-
Chores
- Updated linting configuration with specific dependency versions
- Refined project dependency management
-
Refactor
- Improved type checking and code organization
- Enhanced data handling utilities
Walkthrough
This pull request introduces enhancements to the project's data handling and utility functions, focusing on activity tracking and dependency management. The changes include adding a new Activity class in the data module, introducing utility functions for processing dictionary keys, and updating the project's configuration. The Makefile is modified to use a specific linting group, and the project's dependency management is refined with a new dependency group for linting tools.
Changes
| File | Change Summary |
|---|---|
Makefile |
Modified lint target to use uv run --group linting mypy $(sources) |
garth/data/__init__.py |
Added Activity to __all__ and imported from .activity |
garth/data/activity.py |
Added new data classes: ActivityType, Summary, and ActivityImplemented methods for activity data retrieval and processing |
garth/utils.py |
Added remove_dto and remove_dto_from_dict utility functions |
pyproject.toml |
Added [dependency-groups] section with linting dependencies |
Sequence Diagram
sequenceDiagram
participant Client
participant Activity
participant HTTPClient
Client->>Activity: list() or get(id)
alt list activities
Activity->>HTTPClient: Fetch activities
HTTPClient-->>Activity: Return activity data
Activity->>Activity: Sort activities
else get specific activity
Activity->>HTTPClient: Fetch activity by ID
HTTPClient-->>Activity: Return activity details
Activity->>Activity: Process and convert data
end
Activity-->>Client: Return Activity instance(s)
This sequence diagram illustrates the high-level interaction for retrieving activity data, showing how the Activity class interacts with an HTTP client to fetch and process activity information.
[!TIP] CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command
@coderabbitai generate docstringsto have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@juvilius I apologize for not getting around to reviewing earlier. do you want to rebase, add tests and submit the changes?
adding this endpoint makes sense, especially to make available in garth-mcp-server
Hi, @juvilius, Is there anything I could help you with in order to get this PR ready? I could use this feature for my personal project as well.
Hi @matin,
sorry for the holdup. Let me explain.
I had modified garth enough to be able to generate a map of my running tracks. To not have to rely on Garmin, I stored everything in a postgres DB. I therefore had to create a data model, which turned out to be a bother with Activities coming in all different shapes and sizes depending on the type of activity and even on the device/watch. This lead me to lazily store everything as JSON and hardcode only a handful of fields.
Long story short, I don't know how to easily collect every possible field for all types of activity in a dataclass.
If anybody has an idea, go ahead :)