vxgmichel / aiostream

Generator-based operators for asynchronous iteration
http://aiostream.readthedocs.io
GNU General Public License v3.0
793 stars 34 forks source link

Aiostream fails to import with a TypeError #90

Open jmizgajski opened 11 months ago

jmizgajski commented 11 months ago
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/__init__.py", line 18, in <module>
    from . import stream, pipe
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/stream/__init__.py", line 3, in <module>
    from .create import *
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/stream/create.py", line 21, in <module>
    from ..stream import time
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/stream/time.py", line 6, in <module>
    from ..core import streamcontext, pipable_operator
  File "/home/jan/.virtualenvs/ml-for-research-39/lib/python3.9/site-packages/aiostream/core.py", line 260, in <module>
    class OperatorType(Protocol[P, T]):
  File "/usr/lib/python3.9/typing.py", line 277, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3.9/typing.py", line 997, in __class_getitem__
    raise TypeError(
TypeError: Parameters to Protocol[...] must all be type variables

Python: 3.9.16

This is the lowest level failure of importing a class from llama_index that depends on import from aiostream somwhere down the call stack. The offending line is class OperatorType(Protocol[P, T]): where P and T are ParamSpecs

I tried installing the different versions of typing-extentions but that does not change anything.

Expected behavior: imports without TypeError

vxgmichel commented 11 months ago

Hi @jmizgajski and thanks for the report!

I managed to reproduce the issue using typing-extensions==3.10.0.0.

However, this issue seems fixed for typing-extensions==3.10.0.1 and after, thanks to this line: https://github.com/python/typing_extensions/commit/5b9fd03f46569bbd1429e20086656ee89001e63a#diff-ef000e6d11123c56dea195e0961413aa6947f5f6e21c85b08f3d47e1f8e97452R2333

Could you check the following: