feat: add uv support and modernize CLI#18
Conversation
- Add fit_tool/cli.py as the new CLI entry point - Update pyproject.toml: rename command from 'fittool' to 'fit-tool' - Remove legacy bin/fittool and setup.py - Update README.md with uv installation and usage instructions Amp-Thread-ID: https://ampcode.com/threads/T-019c16e3-e389-71f9-9c5e-8d7fa2bdd176 Co-authored-by: Amp <amp@ampcode.com>
Summary of ChangesHello @shaonianche, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request modernizes the project's packaging and command-line interface. It integrates Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request modernizes the project's command-line interface and packaging by migrating from setup.py to pyproject.toml, introducing a new CLI entry point, and adding support for the uv package manager. The changes are well-structured and improve the project's maintainability. I've identified a critical issue in the new CLI script where a binary file is incorrectly opened in text mode, which could lead to data corruption. I've provided suggestions to fix this, along with a minor improvement for logging consistency.
| parser.add_argument( | ||
| 'fitfile', | ||
| metavar='FILE', | ||
| type=argparse.FileType('r'), | ||
| help='FIT file to process' | ||
| ) |
There was a problem hiding this comment.
Using argparse.FileType('r') opens the file in text mode, which can corrupt binary FIT files due to newline translation. It also causes the file to be opened twice: once by argparse and again by FitFile.from_file. It's better to pass the filename as a string and let FitFile.from_file handle all file operations in the correct mode.
parser.add_argument(
'fitfile',
metavar='FILE',
help='FIT file to process'
)
fit_tool/cli.py
Outdated
| logger.info(f'Loading fit file {args.fitfile.name}...') | ||
| fit_filename = args.fitfile.name |
There was a problem hiding this comment.
Following the change to accept the filename as a string from argparse, args.fitfile will be the path string itself, not a file object. Therefore, you should use args.fitfile directly instead of accessing the .name attribute.
logger.info(f'Loading fit file {args.fitfile}...')
fit_filename = args.fitfile| if args.verbose: | ||
| handler = logging.StreamHandler() | ||
| logger.addHandler(handler) |
There was a problem hiding this comment.
The StreamHandler for verbose output currently uses the default logging format, which is inconsistent with the FileHandler. You should add a formatter to ensure log messages have the same structure, whether they are displayed on the console or written to a file.
if args.verbose:
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(fmt="%(asctime)s %(levelname)s %(message)s"))
logger.addHandler(handler)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
+ Coverage 89.02% 89.69% +0.67%
==========================================
Files 20 21 +1
Lines 1358 1398 +40
==========================================
+ Hits 1209 1254 +45
+ Misses 149 144 -5 ☔ View full report in Codecov by Sentry. |
argparse.FileType('r') opens files in text mode which can corrupt
binary FIT files due to newline translation. Now passing the filename
as a string and letting FitFile.from_file handle file operations.
Amp-Thread-ID: https://ampcode.com/threads/T-019c16e3-e389-71f9-9c5e-8d7fa2bdd176
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c16e3-e389-71f9-9c5e-8d7fa2bdd176 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c16e3-e389-71f9-9c5e-8d7fa2bdd176 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c16e3-e389-71f9-9c5e-8d7fa2bdd176 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c16e3-e389-71f9-9c5e-8d7fa2bdd176