Title: argparse incorrectly says arguments are required · Issue #103219 · python/cpython · GitHub
Open Graph Title: argparse incorrectly says arguments are required · Issue #103219 · python/cpython
X Title: argparse incorrectly says arguments are required · Issue #103219 · python/cpython
Description: When using nargs='*' with other required arguments, argparse incorrectly says the optional argument is required. Output (with no arguments) usage: example [-h] foo [bar ...] example: error: the following arguments are required: foo, bar ...
Open Graph Description: When using nargs='*' with other required arguments, argparse incorrectly says the optional argument is required. Output (with no arguments) usage: example [-h] foo [bar ...] example: error: the fol...
X Description: When using nargs='*' with other required arguments, argparse incorrectly says the optional argument is required. Output (with no arguments) usage: example [-h] foo [bar ...] example: error:...
Opengraph URL: https://github.com/python/cpython/issues/103219
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"argparse incorrectly says arguments are required","articleBody":"When using `nargs='*'` with other required arguments, argparse incorrectly says the optional argument is required.\r\n\r\n### Output (with no arguments)\r\n```\r\nusage: example [-h] foo [bar ...]\r\nexample: error: the following arguments are required: foo, bar\r\n```\r\n### Code\r\n```python\r\nimport argparse\r\n\r\nparser = argparse.ArgumentParser(prog='example')\r\nparser.add_argument('foo')\r\nparser.add_argument('bar', nargs='*')\r\nargs = parser.parse_args()\r\n```\r\nPython 3.9.16\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-123931\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/eslindsey","@type":"Person","name":"eslindsey"},"datePublished":"2023-04-03T18:34:35Z","url":"https://github.com/python/cpython/issues/103219"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4d05b42f-485d-9ca3-a17b-2e41911df768 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A480:30263F:2B6F329:3B5C925:6B0058A4 |
| html-safe-nonce | cd5133740691ebeb7d3ff21311837e7f49c5a24e59bd42de750e80cd5028a1cc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDgwOjMwMjYzRjoyQjZGMzI5OjNCNUM5MjU6NkIwMDU4QTQiLCJ2aXNpdG9yX2lkIjoiNjM0ODM2NDE5MzkxMzEzMzIyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 643b97f4c2df1d6a103dc96875b13bd15724fc97fbdc4a8754add1fe34267bc8 |
| hovercard-subject-tag | issue:1652570574 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/103219/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b2ab53fe11ac40058b92d9417b19732f4c3709c3fc1d00aa2a27d8e9e971c730/python/cpython/issues/103219 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b2ab53fe11ac40058b92d9417b19732f4c3709c3fc1d00aa2a27d8e9e971c730/python/cpython/issues/103219 |
| og:image:alt | When using nargs='*' with other required arguments, argparse incorrectly says the optional argument is required. Output (with no arguments) usage: example [-h] foo [bar ...] example: error: the fol... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eslindsey |
| hostname | github.com |
| expected-hostname | github.com |
| None | 29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | eacd927ba6112e3b01ba99c762bd699a4a4f5df7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width