-
-
Notifications
You must be signed in to change notification settings - Fork 230
[BUG] Python 3.9 has Subscripted Generics error in generated Union.py code #967
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
Comments
I'm not sure, but I think this is the template that gets expanded to provide the if/else. In the generated code, the |
I think this is a duplicate of #958 which I'm about to merge a fix for, so this will get closed with that. If there's a slightly different issue, though, please reopen! |
This PR was created by Knope. Merging it will create a new release ### Fixes #### Remove spurious field_dict.update({}) for types without properties (#969) #### Fix invalid type check for nested unions Nested union types (unions of unions) were generating `isinstance()` checks that were not valid (at least for Python 3.9). Thanks to @codebutler for PR #959 which fixes #958 and #967. Co-authored-by: GitHub <[email protected]>
Yes, confirmed that 0.17.3 fixes this bug. Thank @codebutler and @dbanty ! |
Uh oh!
There was an error while loading. Please reload this page.
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:
The following code can be run with the openapi spec:
This is the error that shows in Python 3.9
TypeError: Subscripted generics cannot be used with class and instance checks
At 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.
OpenAPI Spec File
bad-openapi.json
Desktop (please complete the following information):
Additional Context
This does not happen in openapi-python-client version 0.13.2, which I was upgrading from.
The text was updated successfully, but these errors were encountered: