ezmsg-org / ezmsg-rerun

Rerun integration and examples with ezmsg
MIT License
0 stars 0 forks source link

or operator (`|`) in type annotations requires python 3.10 #1

Open cboulay opened 3 weeks ago

cboulay commented 3 weeks ago

or from __future__ import annotations, yet this project has 3.9 as the lower limit of python.

pperanich commented 2 weeks ago

Noted. Thanks.

pperanich commented 2 weeks ago

Oddly enough, adding from future__ import annotations breaks this code in some way that is not immediately obvious to me. Error log from running the example below.

2024-09-18 18:47:40.377 - pid: 4956 - MainThread - INFO - run: Running in 2 processes.
2024-09-18 18:47:40.381 - pid: 4956 - MainThread - ERROR - process: Traceback (most recent call last):
  File ".../ezmsg-rerun/.venv/lib/python3.11/site-packages/ezmsg/core/backendprocess.py", line 111, in process
    asyncio.runcoroutinethreadsafe(setup_state(), loop).result()
  File ".../python3.11/concurrent/futures/base.py", line 456, in result
    return self.get_result()
           ^^^^^^^^^^^^^^^^^^^
  File ".../python3.11/concurrent/futures/base.py", line 401, in _get_result
    raise self.exception
  File ".../ezmsg-rerun/.venv/lib/python3.11/site-packages/ezmsg/core/backendprocess.py", line 109, in setupstate
    await unit.setup()
  File ".../ezmsg-rerun/.venv/lib/python3.11/site-packages/ezmsg/core/unit.py", line 78, in setup
    self.instantiatestate()
  File ".../ezmsg-rerun/.venv/lib/python3.11/site-packages/ezmsg/core/component.py", line 125, in instantiatestate
    self.STATE = self.class__.__state_type__()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object is not callable
cboulay commented 1 week ago

Maybe replace the annotation with typing.Union[..., ...] then? Or change the Python limitation to >= 3.10.