Skip to content

[BUG] [PYTHON] Missing 'typing_extensions' in requirements.txt #13621

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

Closed
6 tasks
rickwporter opened this issue Oct 6, 2022 · 0 comments · Fixed by #13665
Closed
6 tasks

[BUG] [PYTHON] Missing 'typing_extensions' in requirements.txt #13621

rickwporter opened this issue Oct 6, 2022 · 0 comments · Fixed by #13665

Comments

@rickwporter
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The Python client requirements.txt file is missing the typing_extensions requirement. Not sure if this is required for all Python versions, but I'm running Python 3.8.14 due to organizational constraints.

openapi-generator version

I'm in the process of upgrading from v6.0.0 to v6.2.0.

OpenAPI declaration file content or url

None needed.

Generation Details

Here's a semi-cooked version of my make regen output that regenerates the code and install prerequisites and the code:

host % make regen
rm -rf openapi_gen_controller.log controller_client
docker run --rm -v /Users/rwporter/src/my_project:/local --user 501:20 openapitools/openapi-generator-cli:v6.2.0 generate \
        -i /local/schemas/my_service.yaml \
        -g python \
        -o /local/cli/controller_client \
        --additional-properties=packageName=my_service,packageVersion=1.0.2,enumUnknownDefaultCase=true,supportAsync=false \
        > openapi_gen_controller.log
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.github.jknack.handlebars.context.FieldValueResolver$FieldMember (file:/opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar) to field java.util.HashMap.table
WARNING: Please consider reporting this to the maintainers of com.github.jknack.handlebars.context.FieldValueResolver$FieldMember
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
cd controller_client && HTTP_PROXY=http://www-proxy-ash7.us.oracle.com:80 HTTPS_PROXY=http://www-proxy-ash7.us.oracle.com:80 python3 -m pip install --user --upgrade -r requirements.txt
Requirement already satisfied: certifi>=14.05.14 in /Users/rwporter/Library/Python/3.8/lib/python/site-packages (from -r requirements.txt (line 1)) (2022.9.24)
Requirement already satisfied: frozendict>=2.0.3 in /Users/rwporter/Library/Python/3.8/lib/python/site-packages (from -r requirements.txt (line 2)) (2.3.4)
Requirement already satisfied: python_dateutil>=2.5.3 in /Users/rwporter/Library/Python/3.8/lib/python/site-packages (from -r requirements.txt (line 3)) (2.8.2)
Requirement already satisfied: setuptools>=21.0.0 in /Users/rwporter/Library/Python/3.8/lib/python/site-packages (from -r requirements.txt (line 4)) (65.4.1)
Requirement already satisfied: urllib3>=1.15.1 in /Users/rwporter/Library/Python/3.8/lib/python/site-packages (from -r requirements.txt (line 5)) (1.26.12)
Requirement already satisfied: six>=1.5 in /Users/rwporter/Library/Python/3.8/lib/python/site-packages (from python_dateutil>=2.5.3->-r requirements.txt (line 3)) (1.16.0)
cd controller_client &&  python3 setup.py install --user --prefix= > ../install_controller.log
/Users/rwporter/Library/Python/3.8/lib/python/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/Users/rwporter/Library/Python/3.8/lib/python/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
zip_safe flag not set; analyzing archive contents...

After I do that, I try to run my main program that uses the generated Python client code, and I get:

host % ./cli.py
Traceback (most recent call last):
  File "./cli.py", line 10, in <module>
    from my_service import ApiClient
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/rwporter/Library/Python/3.8/lib/python/site-packages/my_service-1.0.2-py3.8.egg/my_service/__init__.py", line 17, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/rwporter/Library/Python/3.8/lib/python/site-packages/my_service-1.0.2-py3.8.egg/my_service/api_client.py", line 23, in <module>
ModuleNotFoundError: No module named 'typing_extensions'
host %
Steps to reproduce
  • Uninstall the typing_extensions module (initial state of my machine):
python3 -m pip uninstall -y typing_extensions
  • Generate your Python code with v6.2.0 (as shown above)
  • Install the generated prerequisites and generated code (as shown above)
  • Try running code that uses generated code, and see the typing_extensions are missing
Related issues/PRs

I did not see any related issues.

Suggest a fix

Add the following line to the templates that generate Python requirements files:

typing_extensions (~= 4.3.0)

I was able to work around this by adding it to a higher level requirements.txt file, but it seems appropriate to add it to the generated Python client code.

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

Successfully merging a pull request may close this issue.

2 participants