-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix argparse error for BooleanArgument with % in documentation #10044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Python 3.14+ argparse treats % characters in help strings as format specifiers. When service model documentation contains % (e.g., IAM's UpdateAccountPasswordPolicy RequireSymbols parameter), argparse raises: ValueError: unsupported format character '^' (0x5e) at index 129 This was already fixed for CLIArgument in PR aws#9790 but BooleanArgument was missed. This commit adds the same .replace('%', '%%') escaping to BooleanArgument.add_to_parser() and adds a test to verify all service operations with % in documentation work correctly. Fixes compatibility with Python 3.14+
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10044 +/- ##
========================================
Coverage 93.39% 93.39%
========================================
Files 210 210
Lines 17052 17069 +17
========================================
+ Hits 15925 15941 +16
- Misses 1127 1128 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace expensive test that iterated through all services with focused unit tests that directly verify % character escaping behavior. The new tests use controlled test data to verify both CLIArgument and BooleanArgument properly escape % in symbols (% ^) and URL-encoded strings (%28%29) when passed to argparse.
kdaily
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the change is OK, and the testing idea for making sure strings with formatting-specific characters is appropriate. I left a comment about the specifics of how the test is implemented. Lets get that updated and this should be good to go.
|
Let's also update the description in this PR to clarify that the |
|
Can you also confirm that the HTML and |
Update tests to use AWS CLI's ArgTableArgParser instead of standard argparse.ArgumentParser to properly test the CLI's argument parser abstraction. Extract common test logic into helper method to reduce code duplication.


Python 3.14 is more strict with how argparse handles % characters in help strings. While Python 3 has always treated % as format specifiers, Python 3.14 enforces this more strictly. When service model documentation contains % (e.g., IAM's UpdateAccountPasswordPolicy RequireSymbols parameter), argparse raises: ValueError: unsupported format character '^' (0x5e) at index 129
A similar fix was applied for CLIArgument in PR #9790. This commit adds the same .replace('%', '%%') escaping to BooleanArgument.add_to_parser() and adds tests to verify the CLI's argument classes properly handle % characters.
Fixes compatibility with Python 3.14+ for CLI v1.
Addresses:
#10038