Title: [BUG] Python 3.9 has Subscripted Generics error in generated Union.py code · Issue #967 · openapi-generators/openapi-python-client · GitHub
Open Graph Title: [BUG] Python 3.9 has Subscripted Generics error in generated Union.py code · Issue #967 · openapi-generators/openapi-python-client
X Title: [BUG] Python 3.9 has Subscripted Generics error in generated Union.py code · Issue #967 · openapi-generators/openapi-python-client
Description: Describe the bug Python 3.9.18 has an error with the to_dict() function generated for a Union[] Python 3.10 does not have an issue. The generated code that errors out is: def to_dict(self) -> Dict[str, Any]: task_id: Union[None, Union[in...
Open Graph Description: Describe the bug Python 3.9.18 has an error with the to_dict() function generated for a Union[] Python 3.10 does not have an issue. The generated code that errors out is: def to_dict(self) -> Dict[...
X Description: Describe the bug Python 3.9.18 has an error with the to_dict() function generated for a Union[] Python 3.10 does not have an issue. The generated code that errors out is: def to_dict(self) -> Di...
Opengraph URL: https://github.com/openapi-generators/openapi-python-client/issues/967
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Python 3.9 has Subscripted Generics error in generated Union.py code","articleBody":"**Describe the bug**\r\nPython 3.9.18 has an error with the `to_dict()` function generated for a Union[]\r\nPython 3.10 does not have an issue.\r\n\r\nThe generated code that errors out is:\r\n\r\n```python\r\ndef to_dict(self) -\u003e Dict[str, Any]:\r\n task_id: Union[None, Union[int, str], Unset]\r\n if isinstance(self.task_id, Unset):\r\n task_id = UNSET\r\n elif isinstance(self.task_id, Union[int, str]):\r\n task_id = self.task_id\r\n else:\r\n task_id = self.task_id\r\n```\r\n\r\nThe following code can be run with the openapi spec:\r\n\r\n```python\r\nfrom todo_client.models.listable import Listable\r\nx = Listable(task_id=1)\r\nx.to_dict()\r\n```\r\n\r\nThis is the error that shows in Python 3.9\r\n```TypeError: Subscripted generics cannot be used with class and instance checks```\r\n\r\nAt the very least, the pyproject.toml should be updated to show that Python 3.9 is no longer completely supported. Ideally, we'd have a patch since 3.9 is not EOL yet.\r\n\r\n**OpenAPI Spec File**\r\n[bad-openapi.json](https://github.com/openapi-generators/openapi-python-client/files/14325474/bad-openapi.json)\r\n\r\n**Desktop (please complete the following information):**\r\n - OS: MacOS M1 14.3\r\n - Python Version: 3.9.18 (originally seen on 3.9.6)\r\n - openapi-python-client version 0.17.2\r\n\r\n**Additional Context**\r\nThis does not happen in openapi-python-client version 0.13.2, which I was upgrading from.","author":{"url":"https://github.com/wallagib","@type":"Person","name":"wallagib"},"datePublished":"2024-02-19T02:02:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/967/openapi-python-client/issues/967"}
| 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:3d3276c2-411f-5985-cc3f-681b50e0286a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DEE4:3F5F3:217D8B:2A4503:697F884A |
| html-safe-nonce | c804574f666cb9cbaa876a97ec878cfcdf4dd6c9304600d98b1470ee6d515335 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUU0OjNGNUYzOjIxN0Q4QjoyQTQ1MDM6Njk3Rjg4NEEiLCJ2aXNpdG9yX2lkIjoiMzQ3MTQwMzM1ODgwMjExODczMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bd729266394374e1466f8d3aa51f6cc98ceff53175a825a29574243288234567 |
| hovercard-subject-tag | issue:2141343965 |
| 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/openapi-generators/openapi-python-client/967/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b6bdc985f9126067d27a1e3deb069c0adbde3cd2fc15dda4e0a14e2dabb1ae81/openapi-generators/openapi-python-client/issues/967 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b6bdc985f9126067d27a1e3deb069c0adbde3cd2fc15dda4e0a14e2dabb1ae81/openapi-generators/openapi-python-client/issues/967 |
| og:image:alt | Describe the bug Python 3.9.18 has an error with the to_dict() function generated for a Union[] Python 3.10 does not have an issue. The generated code that errors out is: def to_dict(self) -> Dict[... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wallagib |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/openapi-generators/openapi-python-client git https://github.com/openapi-generators/openapi-python-client.git |
| octolytics-dimension-user_id | 84925606 |
| octolytics-dimension-user_login | openapi-generators |
| octolytics-dimension-repository_id | 240776275 |
| octolytics-dimension-repository_nwo | openapi-generators/openapi-python-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 240776275 |
| octolytics-dimension-repository_network_root_nwo | openapi-generators/openapi-python-client |
| 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 | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width