Skip to content

deprecation warning with Python 3.10 #1440

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

Closed
jnoortheen opened this issue Jun 6, 2021 · 7 comments
Closed

deprecation warning with Python 3.10 #1440

jnoortheen opened this issue Jun 6, 2021 · 7 comments

Comments

@jnoortheen
Copy link
Contributor

Python 3.10 is still beta. This is just a heads up. Here is the full warning

xsh-rVZlQJi1-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py:878: DeprecationWarning: There is no current event loop
  loop = get_event_loop()
@jonathanslenders
Copy link
Member

Thanks for bringing this to my attention!

Given that we are still supporting Python 3.6, I think we need a wrapper (in prompt_toolkit/eventloop/utils.py) that uses get_running_loop if available and otherwise get_event_loop. Is this something you're interested in contributing?

There are various places where it's used:

./shortcuts/prompt.py
./shortcuts/dialogs.py
./shortcuts/progress_bar/base.py
./shortcuts/utils.py
./input/vt100.py
./input/win32.py
./history.py
./application/application.py
./contrib/telnet/server.py
./contrib/ssh/server.py
./eventloop/inputhook.py
./eventloop/async_generator.py
./eventloop/utils.py

@jnoortheen
Copy link
Contributor Author

@jonathanslenders yes I am. This means updating the github actions as well right?

jnoortheen added a commit to jnoortheen/python-prompt-toolkit that referenced this issue Jun 27, 2021
@jaraco
Copy link

jaraco commented Aug 5, 2021

Python 3.10 is no longer beta and this issue still exists, affecting all xonsh environments that use ptk.

@mattmc3
Copy link
Contributor

mattmc3 commented Oct 6, 2021

Any updates on this issue? A fresh install of Xonsh will emit this deprecation error on every command since Python 3.10 is now out.

Instead of adding something to prompt_toolkit/eventloop/utils.py, would it preferable to do a simple conditional import in the relevant files? I'm willing to attempt a PR:

try:
    from asyncio import get_running_loop
except ImportError:
    from asyncio import get_event_loop as get_running_loop

Or, you can add get_running_loop to asyncio for Python 3.6:

import asyncio
if not hasattr(asyncio, 'get_running_loop'):
    asyncio.get_running_loop = asyncio.get_event_loop

@mattmc3
Copy link
Contributor

mattmc3 commented Oct 6, 2021

I opened a PR. See above.

@henryiii
Copy link
Contributor

henryiii commented Oct 8, 2021

FYI, brew has now switched the xonsh recipe to Python 3.10, so this pops up all the time on any brew installed xonsh. Brew has migrated over 150 formula, and is migrating the other 450, so this will pop up on anything that moves to Python 3.10 and uses prompt-toolkit.

@mattmc3
Copy link
Contributor

mattmc3 commented Nov 7, 2021

Vote to close this issue. Can confirm that prompt-toolkit 3.0.22 works great in Xonsh on Python 3.10 with my merged PR. For Xonsh users, you can simply xpip install prompt-toolkit --upgrade if you are on an earlier version and still seeing the deprecation warning.

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

5 participants