swagger-api / swagger-api/swagger-codegen-generators
Python 3.7 support in Python Flask generator
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I've found an error while trying to use the Python Flask generator with Python 3.7 (and 3.8). From the logs I saw a "AttributeError: module 'typing' has no attribute 'GenericMeta'".
The issue is the same described in https://github.com/zalando/connexion/issues/739.
I've changed util.py as for a workaround suggested in that bug, to support both Python 3.6 and 3.7:
elif hasattr(klass, '__origin__'):
if klass.__origin__ == list or klass.__origin__ == typing.List:
return _deserialize_list(data, klass.__args__[0])
if klass.__origin__ == dict:
return _deserialize_dict(data, klass.__args__[1])
I'm wondering if this (or a better solution) can be ported officially in https://github.com/swagger-api/swagger-codegen-generators/blob/781c5a407c831130285c16eac735d56c0f9edd76/src/main/resources/handlebars/pythonFlaskConnexion/util.mustache
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting src/main/resources/handlebars/pythonFlaskConnexion/util.mustache and reproduce the generator failure with Python 3.7. Compare the current typing handling with the reported workaround for Python 3.6 and 3.7. Done means the generated Flask code runs without the GenericMeta error on both versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100