opendatacube / odc-stac

Load STAC items into xarray Datasets.
Apache License 2.0
140 stars 20 forks source link

Python 3.8: Compatibility needs __future__ annotations #154

Closed Eksoss closed 5 months ago

Eksoss commented 5 months ago

With a python 3.8 importing 'load' as from odc.stac import load generated this error:

Traceback (most recent call last):
  File "download_sentinel.py", line 5, in <module>
    from odc.stac import load as odc_load
  File "/home/myuser/.local/lib/python3.8/site-packages/odc/stac/__init__.py", line 4, in <module>
    from ._load import load
  File "/home/myuser/.local/lib/python3.8/site-packages/odc/stac/_load.py", line 39, in <module>
    from odc.geo.xr import xr_coords
  File "/home/myuser/.local/lib/python3.8/site-packages/odc/geo/xr.py", line 15, in <module>
    from ._xr_interop import (
  File "/home/myuser/.local/lib/python3.8/site-packages/odc/geo/_xr_interop.py", line 54, in <module>
    from .cog import to_cog, write_cog
  File "/home/myuser/.local/lib/python3.8/site-packages/odc/geo/cog/__init__.py", line 1, in <module>
    from ._rio import to_cog, write_cog, write_cog_layers
  File "/home/myuser/.local/lib/python3.8/site-packages/odc/geo/cog/_rio.py", line 87, in <module>
    xx: xr.DataArray | list[xr.DataArray],
TypeError: 'type' object is not subscriptable

Going into the file _rio.py I added from __future__ import annotations in the start and it solved this problem.

Kirill888 commented 5 months ago

see: https://github.com/opendatacube/odc-geo/pull/154

in the shortest term you can downgrade to previous version of odc-geo!=0.4.5.