Skip to content

fix: correct --timeout type, replace asserts, add --style choices#51

Open
wenh06 wants to merge 2 commits into
masterfrom
fix/cli-and-config-improvements
Open

fix: correct --timeout type, replace asserts, add --style choices#51
wenh06 wants to merge 2 commits into
masterfrom
fix/cli-and-config-improvements

Conversation

@wenh06

@wenh06 wenh06 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • P0: 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
  • P1: Replace assert statements in _handle_config and main() with explicit error messages + sys.exit(1), so validation is not skipped under python -O
  • P2: Add choices=[...] to --style argument, populated from BibLookup._get_supported_styles(), so invalid styles are caught at argument-parse time

…--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
Copilot AI review requested due to automatic review settings July 4, 2026 14:22
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@edf0925). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 --timeout parsing from int to float to avoid truncating fractional timeouts.
  • Replace an assert in main() with an explicit error message + sys.exit(1) so validation isn’t skipped under python -O.
  • Add choices=[...] to --style so invalid styles are rejected earlier by argparse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bib_lookup/cli.py
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 thread bib_lookup/cli.py Outdated
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
@wenh06 wenh06 enabled auto-merge July 6, 2026 08:53
@wenh06 wenh06 self-assigned this Jul 6, 2026
@wenh06 wenh06 added the bug Something isn't working label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants