René's URL Explorer Experiment


Title: Fix short flags being swallowed by **kwargs (fixes #454) by shivamtiwari3 · Pull Request #652 · google/python-fire · GitHub

Open Graph Title: Fix short flags being swallowed by **kwargs (fixes #454) by shivamtiwari3 · Pull Request #652 · google/python-fire

X Title: Fix short flags being swallowed by **kwargs (fixes #454) by shivamtiwari3 · Pull Request #652 · google/python-fire

Description: Summary Fixes #454. Short flags like -f and -s were being stored directly in **kwargs (as {'f': 'hello', 's': 'world'}) instead of being expanded to their matching positional argument names (first_arg, second_arg) when a function accepts **kwargs. Problem In _ParseKeywordArgs (core.py:887), the condition was: if (key in fn_args or (is_bool_syntax and key.startswith('no') and key[2:] in fn_args) or fn_keywords): keyword = key elif len(key) == 1: # single-char shortcut lookup ... When fn_keywords is truthy (i.e. the function has **kwargs), the first branch fires immediately, setting keyword = key (the raw single character). The shortcut lookup in the elif branch is never reached. Solution Restructured the conditions so single-char shortcut expansion against fn_args is always attempted first. fn_keywords is only used as a fallback when no fn_arg matches the single character: if key in fn_args or (...noXxx... in fn_args): keyword = key elif len(key) == 1: matching_fn_args = [arg for arg in fn_args if arg[0] == key] if len(matching_fn_args) == 1: keyword = matching_fn_args[0] elif len(matching_fn_args) > 1: raise FireError(...) elif fn_keywords: # ← fallback: no fn_arg match, accept into **kwargs keyword = key elif fn_keywords: keyword = key Multi-character unrecognised flags still fall through to **kwargs as before. Testing Added fn_with_defaults_and_kwargs to test_components.py Added testSingleCharFlagParsingWithKwargs to fire_test.py covering: -f=hello -s=world → ('hello', 'world', {}) -f hello -s world → ('hello', 'world', {}) unrecognised --unknown_key=42 → still forwarded to **kwargs Command: python3 -m pytest fire/ --ignore=fire/docstrings_fuzz_test.py --ignore=fire/parser_fuzz_test.py 261 tests pass, 0 failures Checklist Fixes the reported issue Existing behaviour unchanged (no regressions) Tests added All 261 tests pass Code style matches project conventions

Open Graph Description: Summary Fixes #454. Short flags like -f and -s were being stored directly in **kwargs (as {'f': 'hello', 's': 'world'}) instead of being expanded to their matching p...

X Description: Summary Fixes #454. Short flags like -f and -s were being stored directly in **kwargs (as {'f': 'hello', 's': 'world'}) instead of be...

Opengraph URL: https://github.com/google/python-fire/pull/652

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:f7bee21b-c147-5e67-58f3-e3460f3f6d1d
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD54E:A825:E6D1B9:14FB538:6A4E2D73
html-safe-nonce834bcbcdb7f0fc5740c6a9adcdbe0ed73ad136ef5cbfabcd6becefbcc8de0b2a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTRFOkE4MjU6RTZEMUI5OjE0RkI1Mzg6NkE0RTJENzMiLCJ2aXNpdG9yX2lkIjoiNDc4NDg5MTEzMzQ1MTcwOTgxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1bded75d8b2f89291d1997178c9df25b6ab41aabae8e2fbaa21cc41dfbf73113
hovercard-subject-tagpull_request:3376775717
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/google/python-fire/pull/652/files
twitter:imagehttps://avatars.githubusercontent.com/u/33183708?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/33183708?s=400&v=4
og:image:altSummary Fixes #454. Short flags like -f and -s were being stored directly in **kwargs (as {'f': 'hello', 's': 'world'}) instead of being expanded to their matching p...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/google/python-fire git https://github.com/google/python-fire.git
octolytics-dimension-user_id1342004
octolytics-dimension-user_logingoogle
octolytics-dimension-repository_id82729529
octolytics-dimension-repository_nwogoogle/python-fire
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id82729529
octolytics-dimension-repository_network_root_nwogoogle/python-fire
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released9dd20d38f8ae3c4cb6b597807431db300d0bd2a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/google/python-fire/pull/652/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogle%2Fpython-fire%2Fpull%2F652%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogle%2Fpython-fire%2Fpull%2F652%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=google%2Fpython-fire
Reloadhttps://github.com/google/python-fire/pull/652/files
Reloadhttps://github.com/google/python-fire/pull/652/files
Reloadhttps://github.com/google/python-fire/pull/652/files
Please reload this pagehttps://github.com/google/python-fire/pull/652/files
google https://github.com/google
python-firehttps://github.com/google/python-fire
Notifications https://github.com/login?return_to=%2Fgoogle%2Fpython-fire
Fork 1.5k https://github.com/login?return_to=%2Fgoogle%2Fpython-fire
Star 28.2k https://github.com/login?return_to=%2Fgoogle%2Fpython-fire
Code https://github.com/google/python-fire
Issues 131 https://github.com/google/python-fire/issues
Pull requests 52 https://github.com/google/python-fire/pulls
Actions https://github.com/google/python-fire/actions
Projects https://github.com/google/python-fire/projects
Security and quality 0 https://github.com/google/python-fire/security
Insights https://github.com/google/python-fire/pulse
Code https://github.com/google/python-fire
Issues https://github.com/google/python-fire/issues
Pull requests https://github.com/google/python-fire/pulls
Actions https://github.com/google/python-fire/actions
Projects https://github.com/google/python-fire/projects
Security and quality https://github.com/google/python-fire/security
Insights https://github.com/google/python-fire/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fgoogle%2Fpython-fire%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgoogle%2Fpython-fire%2Fissues%2Fnew%2Fchoose
shivamtiwari3https://github.com/shivamtiwari3
google:masterhttps://github.com/google/python-fire/tree/master
shivamtiwari3:fix/short-flags-kwargshttps://github.com/shivamtiwari3/python-fire/tree/fix/short-flags-kwargs
Conversation 1 https://github.com/google/python-fire/pull/652
Commits 1 https://github.com/google/python-fire/pull/652/commits
Checks 1 https://github.com/google/python-fire/pull/652/checks
Files changed 3 https://github.com/google/python-fire/pull/652/files
Fix short flags being swallowed by **kwargs (fixes #454) https://github.com/google/python-fire/pull/652/files#top
Show all changes 1 commit https://github.com/google/python-fire/pull/652/files
7e1dfe5 Fix short flags being swallowed by **kwargs instead of expanding to f… shivamtiwari3 Mar 10, 2026 https://github.com/google/python-fire/pull/652/commits/7e1dfe555f9f3a2f6a6c3d4a12c281a32c45a773
Clear filters https://github.com/google/python-fire/pull/652/files
Please reload this pagehttps://github.com/google/python-fire/pull/652/files
Please reload this pagehttps://github.com/google/python-fire/pull/652/files
core.py https://github.com/google/python-fire/pull/652/files#diff-6e71ec955d67ac88066d77413af38a8043e03fbb28835c40e70c8d804e61f403
fire_test.py https://github.com/google/python-fire/pull/652/files#diff-aa3f37ac40e6fda833b29b147fa77596dfa57b394ef6ccfc6a13b48797b363c1
test_components.py https://github.com/google/python-fire/pull/652/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
fire/core.pyhttps://github.com/google/python-fire/pull/652/files#diff-6e71ec955d67ac88066d77413af38a8043e03fbb28835c40e70c8d804e61f403
View file https://github.com/google/python-fire/blob/7e1dfe555f9f3a2f6a6c3d4a12c281a32c45a773/fire/core.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/google/python-fire/pull/652/{{ revealButtonHref }}
https://github.com/google/python-fire/pull/652/files#diff-6e71ec955d67ac88066d77413af38a8043e03fbb28835c40e70c8d804e61f403
https://github.com/google/python-fire/pull/652/files#diff-6e71ec955d67ac88066d77413af38a8043e03fbb28835c40e70c8d804e61f403
https://github.com/google/python-fire/pull/652/files#diff-6e71ec955d67ac88066d77413af38a8043e03fbb28835c40e70c8d804e61f403
fire/fire_test.pyhttps://github.com/google/python-fire/pull/652/files#diff-aa3f37ac40e6fda833b29b147fa77596dfa57b394ef6ccfc6a13b48797b363c1
View file https://github.com/google/python-fire/blob/7e1dfe555f9f3a2f6a6c3d4a12c281a32c45a773/fire/fire_test.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/google/python-fire/pull/652/{{ revealButtonHref }}
https://github.com/google/python-fire/pull/652/files#diff-aa3f37ac40e6fda833b29b147fa77596dfa57b394ef6ccfc6a13b48797b363c1
https://github.com/google/python-fire/pull/652/files#diff-aa3f37ac40e6fda833b29b147fa77596dfa57b394ef6ccfc6a13b48797b363c1
fire/test_components.pyhttps://github.com/google/python-fire/pull/652/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
View file https://github.com/google/python-fire/blob/7e1dfe555f9f3a2f6a6c3d4a12c281a32c45a773/fire/test_components.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/google/python-fire/pull/652/{{ revealButtonHref }}
https://github.com/google/python-fire/pull/652/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
https://github.com/google/python-fire/pull/652/files#diff-0a85d0cc80b635d47959579569b4f7aac45d66fcf5a61261d02e2ce943fe94a4
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.