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

Problems with Python 3.12 #134

Closed
sneakyx opened this issue Oct 9, 2023 · 2 comments · Fixed by #135
Closed

Problems with Python 3.12 #134

sneakyx opened this issue Oct 9, 2023 · 2 comments · Fixed by #135

Comments

@sneakyx
Copy link

sneakyx commented Oct 9, 2023

Hello, thanks for the good package. With Python 3.11 it works like a charm, but with Python 3.12 we get the error
TypeError: constraints must be a tuple

Even when we only add the simple example from the docs in our code.
Traceback (most recent call last):

  File "/usr/local/bin/uvicorn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uvicorn/main.py", line 404, in main
    run(
  File "/usr/local/lib/python3.12/site-packages/uvicorn/main.py", line 569, in run
    server.run()
  File "/usr/local/lib/python3.12/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uvicorn/server.py", line 67, in serve
    config.load()
  File "/usr/local/lib/python3.12/site-packages/uvicorn/config.py", line 477, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/src/app/main.py", line 10, in <module>
    from core import eventing
  File "/usr/src/app/core/eventing.py", line 1, in <module>
    from pyee.base import EventEmitter
  File "/usr/local/lib/python3.12/site-packages/pyee/__init__.py", line 32, in <module>
    from pyee.base import EventEmitter as EventEmitter
  File "/usr/local/lib/python3.12/site-packages/pyee/base.py", line 23, in <module>
    Handler = TypeVar(name="Handler", bound=Callable)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: constraints must be a tuple
@jfhbrook
Copy link
Owner

jfhbrook commented Oct 9, 2023

At a glance it looks like 3.12 made the API for the bound argument to TypeVar more strict. I won't be able to look for at least a week, but can review/accept a PR in the meantime.

@mxschmitt
Copy link
Contributor

Thank you for the release @jfhbrook!

Embers-of-the-Fire added a commit to Embers-of-the-Fire/monad-std that referenced this issue Jan 16, 2024
python3.12.1 (till now) process typevar bound wrongly, and using `bound` argument will lead to an error. This is fixed now, but not yet released. See jfhbrook/pyee#134 for more information.
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

Successfully merging a pull request may close this issue.

3 participants