spotinst / spotinst-sdk-python

Spotinst SDK for the Python programming language.
Apache License 2.0
17 stars 18 forks source link

cannot import `SpotinstSession` #139

Closed pmoranga closed 1 year ago

pmoranga commented 1 year ago

After 2.1.40 it fails to import SpotinstSession, the same works perfectly until 2.1.39.

The main error message is:

TypeError: 'type' object is not subscriptable

To reproduce use a simple command as this:

docker run --rm -it  python:3.8  bash -c 'pip install -q  spotinst-sdk2==2.1.40; python -  <<< "from spotinst_sdk2 import SpotinstSession"'
[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/spotinst_sdk2/__init__.py", line 4, in <module>
    from spotinst_sdk2.clients.elastigroup import *
  File "/usr/local/lib/python3.8/site-packages/spotinst_sdk2/clients/elastigroup/__init__.py", line 14, in <module>
    import spotinst_sdk2.models.elastigroup.gcp as gcp_elastigroup
  File "/usr/local/lib/python3.8/site-packages/spotinst_sdk2/models/elastigroup/gcp/__init__.py", line 109, in <module>
    class ScalingPolicy:
  File "/usr/local/lib/python3.8/site-packages/spotinst_sdk2/models/elastigroup/gcp/__init__.py", line 131, in ScalingPolicy
    dimensions: list[ScalingPolicyDimension] = none,
TypeError: 'type' object is not subscriptable

While on 2.1.39 it works ok:

docker run --rm -it  python:3.8  bash -c 'pip install -q  spotinst-sdk2==2.1.39; python -  <<< "from spotinst_sdk2 import SpotinstSession"'
[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
anuragsharma-123 commented 1 year ago

Hello @pmoranga - Thanks for catching this. It was a issue for python version 3.8 or below. It has been fix in spotinst-sdk2 release 2.1.41. Please try and let us know if it works or not.