Skip to content

[BUG][Python3.7][openapi-generator-cli] ImportError: cannot import name 'GenericMeta' from 'typing' #7010

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

Open
Song2017 opened this issue Jul 22, 2020 · 1 comment

Comments

@Song2017
Copy link

Description

When running python client package in python 3.7 runtime, it raised error ImportError: cannot import name 'GenericMeta' from 'typing'

openapi-generator version

  • openapitools/openapi-generator-cli:v4.3.1

Steps to reproduce

Traceback (most recent call last):
  File "/***/python37_lab/test.py", line 3, in <module>
    import nomad_envoy_cli
  File "/***/.virtualenvs/py37/lib/python3.7/site-packages/nomad_envoy_cli/__init__.py", line 21, in <module>
    from nomad_envoy_cli.api.customs_api import CustomsApi
  File "/***/.virtualenvs/py37/lib/python3.7/site-packages/nomad_envoy_cli/api/__init__.py", line 6, in <module>
    from nomad_envoy_cli.api.customs_api import CustomsApi
  File "/***/.virtualenvs/py37/lib/python3.7/site-packages/nomad_envoy_cli/api/customs_api.py", line 21, in <module>
    from nomad_envoy_cli.api_client import ApiClient
  File "/***/.virtualenvs/py37/lib/python3.7/site-packages/nomad_envoy_cli/api_client.py", line 681, in <module>
    from .swagger_validator import SwaggerValidator
  File "/***/.virtualenvs/py37/lib/python3.7/site-packages/nomad_envoy_cli/swagger_validator.py", line 4, in <module>
    from typing import List, AnyStr, Any, Type, GenericMeta, Dict
ImportError: cannot import name 'GenericMeta' from 'typing' (/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py)

Related issues/PRs

#2022

Suggest a fix

error version:

import importlib
import json
from datetime import date, datetime
from typing import List, AnyStr, Any, Type, GenericMeta, Dict

class SwaggerValidator(object):

fixed:

import importlib
import json
from datetime import date, datetime
from typing import List, AnyStr, Any, Type, GenericMeta, Dict
try:
    from typing import GenericMeta  # python 3.6
except ImportError:
    # in 3.7, genericmeta doesn't exist but we don't need it
    class GenericMeta(type): pass

class SwaggerValidator(object):
@spacether
Copy link
Contributor

This issue applies to:

  • python-flask
  • python-blueplanet
  • python-aiohttp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants