-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Python] Python 3.7 typing module change breaks util.py #8921
[Python] Python 3.7 typing module change breaks util.py #8921
Comments
Hi,
As far as I understand, GenericMeta does not exist anymore in python 3.7 All valid requests to the generated server will result in this error. Thanks |
This is affecting our development as well--we love the codegen and use it throughout numerous apps, but because of this issue we're either forced to use python 3.6 or have to modify the generated code programmatically. |
Hi, I've just came across this issue as well. Any progress on this? Should it be closed as fixed? I'm just asking. I haven't tried running latest codegen — only using what Swagger hub has to offer. |
Same here, I had this issue when generating with swagger-codegen-cli-3.0.20.jar. I dealt with it by pasting in the fix from https://github.com/OpenAPITools/openapi-generator/pull/2884/files and adding util.py to my .swagger-codegen-ignore. |
Hey there, is there any news on this? I'm affected by the same problem using the Python-Flask generated stubs by Swaggerhub. |
@HugoMario I just had this issue again. |
It seems this was fixed with #11742 for codegen v2 On codegen v3, i tried to reproduce this issue but everything worked fine for me. @becothas if you are familiar with codegen cli. Can you please check with this codegen v2 snapshot or check using codegen v3 snapshot in case you work with an OpenAPI 3.0.X definition |
Description
Thanks for the nice tool =)
Despite the requirements showing Python 3.5.2+, running swagger generated flask+connexion code with python 3.7 will break
util.py
.Here's a stack trace:
This is because the typing module does not have a GenericMeta anymore. I got across this as I tried to serialize some typed generated models as part of trying to parallelize a specific task. This got me here:
python/typing#511, where I learned that I needed to upgrade to python 3.7 in order to pickle these objects. The pickle part started working just fine. However, the error above appeared.
After some google-fu I found this answer in stack overflow and worked around it for my project changing
In
util.py
, toUnfortunately, this fix is not backwards compatible with < 3.7.
The guys from sphinx used a more generic solution where they checked for python version before acessing
GenericMeta
or__origin__
. See commit tk0miya/sphinx@e2389b4, fixing issue sphinx-doc/sphinx#4490.I first sent this to the connexion guys given that someone had already opened a similar issue there spec-first/connexion#739, but I think this is the correct place.
I will gladly send a PR if someone guide me through it. As per gvanrossum (python/typing#136), we should not be using
__extra__
anyway.Edit: In a second read, it seems that we are not supposed to do runtime type checks with the typing module (????), and that we should not be using private APIs for this, even though there is no public APIs (????).
Swagger-codegen version
2.3.1
Steps to reproduce
Run any code (including sample) with python 3.7
The text was updated successfully, but these errors were encountered: