Title: argparse.parse_args should have a generic return type · Issue #2366 · python/typeshed · GitHub
Open Graph Title: argparse.parse_args should have a generic return type · Issue #2366 · python/typeshed
X Title: argparse.parse_args should have a generic return type · Issue #2366 · python/typeshed
Description: (sorry if generic is the wrong word to describe this) argparse.parse_args(namespace=MyNamespace()) returns an instance of MyNamespace, but it's annotated to always return an argparse.Namespace. This means that in order to have type-safet...
Open Graph Description: (sorry if generic is the wrong word to describe this) argparse.parse_args(namespace=MyNamespace()) returns an instance of MyNamespace, but it's annotated to always return an argparse.Namespace. Thi...
X Description: (sorry if generic is the wrong word to describe this) argparse.parse_args(namespace=MyNamespace()) returns an instance of MyNamespace, but it's annotated to always return an argparse.Namespace....
Opengraph URL: https://github.com/python/typeshed/issues/2366
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"argparse.parse_args should have a generic return type","articleBody":"(sorry if generic is the wrong word to describe this)\r\n\r\n`argparse.parse_args(namespace=MyNamespace())` returns an instance of `MyNamespace`, but it's annotated to always return an `argparse.Namespace`. This means that in order to have type-safety when accessing arguments by using a custom type-annotated class:\r\n\r\n```python\r\nclass Arguments:\r\n verbose: bool\r\n ...\r\nargs = argparse.parse_args(namespace=Arguments())\r\n```\r\n\r\nyou currently need to cast the return value of `argparse.parse_args`.\r\n\r\nAlso, the passed object doesn't actually have to be a (subclass of) `argparse.Namespace` – a simple subclass of object [is documented to work](https://docs.python.org/3/library/argparse.html#argparse.Namespace).","author":{"url":"https://github.com/keysmashes","@type":"Person","name":"keysmashes"},"datePublished":"2018-08-07T20:53:20Z","url":"https://github.com/python/typeshed/issues/2366"}
| 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:83457843-0c6f-5fc4-fae0-c7d79a8e1d27 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E26:1A12A9:28D6D1:368589:6B0024C1 |
| html-safe-nonce | eb3a2cf7b4ab0ce8811601ccc6112605fdddc668d8edf0250451a41e6c209d3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTI2OjFBMTJBOToyOEQ2RDE6MzY4NTg5OjZCMDAyNEMxIiwidmlzaXRvcl9pZCI6Ijg4NDc5NjgyMDE2NDQ5NzUyOTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0484b4b3e6b97e448e6c84ac531e2963e66b0cd74d00109e2ef814c36a2bcb5c |
| hovercard-subject-tag | issue:348483158 |
| 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/typeshed/2366/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df18dbf3eae3886d189b406eee3c77847a2fd61481157181c8d34efb6ea731f4/python/typeshed/issues/2366 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df18dbf3eae3886d189b406eee3c77847a2fd61481157181c8d34efb6ea731f4/python/typeshed/issues/2366 |
| og:image:alt | (sorry if generic is the wrong word to describe this) argparse.parse_args(namespace=MyNamespace()) returns an instance of MyNamespace, but it's annotated to always return an argparse.Namespace. Thi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | keysmashes |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width