Skip to content

Fix argparse conflict for duplicate TypedDict field short aliases#433

Open
wirjo wants to merge 1 commit intoeval-protocol:mainfrom
wirjo:fix/argparse-duplicate-short-flags
Open

Fix argparse conflict for duplicate TypedDict field short aliases#433
wirjo wants to merge 1 commit intoeval-protocol:mainfrom
wirjo:fix/argparse-duplicate-short-flags

Conversation

@wirjo
Copy link

@wirjo wirjo commented Mar 9, 2026

Summary

  • Fixes an argparse.ArgumentError when multiple TypedDicts in a function signature share the same field name (e.g. credentials_secret in both aws_s3_config and azure_blob_storage_config)
  • The CLI auto-generation in add_args_from_callable_signature creates a short alias --{field_kebab} for every TypedDict field. When two TypedDicts have the same field name, the short alias collides causing: ArgumentError: argument --azure-blob-storage-config-credentials-secret/--credentials-secret: conflicting option string: --credentials-secret
  • The fix tracks registered flags in a set and only adds the short alias if it hasn't already been claimed by a previous TypedDict field

Test plan

  • Verified eval-protocol create rft --help works without argparse errors
  • Verified eval-protocol create rft with full arguments runs through the complete flow (local test, evaluator upload, dataset transform)
  • Short aliases still work for the first TypedDict that registers them (e.g. --credentials-secret maps to aws_s3_config.credentials_secret)
  • The prefixed long form still works for all fields (e.g. --azure-blob-storage-config-credentials-secret)

🤖 Generated with Claude Code


Note

Low Risk
Small, localized change to CLI flag generation that reduces conflicts; main risk is subtle alias/precedence changes when duplicate field names exist.

Overview
Prevents argparse.ArgumentError when auto-generating CLI flags from callables whose signature includes multiple TypedDict parameters with overlapping field names.

add_args_from_callable_signature now tracks already-registered option strings and only adds the unprefixed short alias (e.g. --credentials-secret) for the first occurrence, while always registering the fully-prefixed flag (e.g. --azure-blob-storage-config-credentials-secret).

Written by Cursor Bugbot for commit db7f8bd. This will update automatically on new commits. Configure here.

When multiple TypedDicts in a function signature share the same field
name (e.g. credentials_secret in both aws_s3_config and
azure_blob_storage_config), the CLI auto-generation creates duplicate
short flags (--credentials-secret), causing an argparse error.

Track registered flags and only add the short alias if it hasn't
already been claimed by a previous TypedDict field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant