swagger-api / swagger-api/swagger-codegen
[Python] AttributeError: module 'typing' has no attribute 'Type' in python 3.5.1
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
In python 3.5.1, type python -m swagger_server will get the following error:
File "/swagger-codegen/samples/server/petstore/flaskConnexion/swagger_server/models/base_model_.py", line 21, in Model
def from_dict(cls: typing.Type[T], dikt) -> T:
AttributeError: module 'typing' has no attribute 'Type'
Swagger-codegen version
2.3.0
Suggest a fix/enhancement
- edit
swagger_server/models/base_model_.py - add
from typing import TypeVar, Genericafterimport typing - replace the 22nd line as below
def from_dict(cls: typing.
Type[T], dikt) -> T:
def from_dict(cls: typing.Generic[T], dikt) -> T:
- type
python -m swagger_serverto start the service and you would see:
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
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 with swagger_server/models/base_model_.py, especially the from_dict annotation around line 22, and reproduce the failure with python -m swagger_server under Python 3.5.1. Verify the compatibility change against the generated Flask service; done means the service starts and reports that it is running on port 8080.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100