fix: correct --timeout type, replace asserts, add --style choices#51
Open
wenh06 wants to merge 2 commits into
Open
fix: correct --timeout type, replace asserts, add --style choices#51wenh06 wants to merge 2 commits into
wenh06 wants to merge 2 commits into
Conversation
…--style choices - Change --timeout from type=int to type=float to match DEFAULT_CONFIG (6.0) and BibLookup's float() cast, preventing silent truncation of values like 6.5 - Replace assert statements in _handle_config and main() with explicit error messages + sys.exit(1), so validation is not skipped under -O - Add choices=[...] to --style argument, populated from BibLookup._get_supported_styles(), so invalid styles are caught at argument-parse time
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #51 +/- ##
=========================================
Coverage ? 98.45%
=========================================
Files ? 13
Lines ? 1948
Branches ? 0
=========================================
Hits ? 1918
Misses ? 30
Partials ? 0 ☔ View full report in Codecov by Harness. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the bib-lookup command-line interface by tightening argument validation and aligning CLI argument types with the library/config expectations.
Changes:
- Change
--timeoutparsing frominttofloatto avoid truncating fractional timeouts. - Replace an
assertinmain()with an explicit error message +sys.exit(1)so validation isn’t skipped underpython -O. - Add
choices=[...]to--styleso invalid styles are rejected earlier by argparse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
308
to
311
| "--timeout", | ||
| type=int, | ||
| type=float, | ||
| default=6, | ||
| help="Timeout for the lookup request. Unit is seconds. Default is 6 seconds.", |
Comment on lines
+332
to
+336
| @@ -332,6 +333,7 @@ def main(): | |||
| type=str, | |||
| help="Style of the output, valid only when 'format' is 'text', optional.", | |||
| dest="style", | |||
| choices=list(BibLookup._get_supported_styles().keys()), | |||
- Change --timeout default from 6 to 6.0 so it stays float even when the flag is not provided (argparse doesn't apply type to defaults) - Change --style type from str to str.lower so uppercase style names like APA, GBT are accepted; sort choices for stable ordering - Add test coverage for: non-existent config file (--config), no identifiers (exit 1), invalid --style (argparse rejection), uppercase --style, float --timeout round-trip
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.
Summary
--timeoutfromtype=inttotype=floatto matchDEFAULT_CONFIG(6.0) andBibLookup'sfloat()cast, preventing silent truncation of values like6.5assertstatements in_handle_configandmain()with explicit error messages +sys.exit(1), so validation is not skipped underpython -Ochoices=[...]to--styleargument, populated fromBibLookup._get_supported_styles(), so invalid styles are caught at argument-parse time