Skip to content
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

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

Open
cboulay opened this issue Sep 13, 2024 · 3 comments
Open

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

cboulay opened this issue Sep 13, 2024 · 3 comments

Comments

@cboulay
Copy link

cboulay commented Sep 13, 2024

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

@pperanich
Copy link
Contributor

Noted. Thanks.

@pperanich pperanich reopened this Sep 18, 2024
@pperanich
Copy link
Contributor

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
Copy link
Author

cboulay commented Sep 27, 2024

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

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

No branches or pull requests

2 participants