Skip to content

Drop Python 3.6. #1721

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

Merged
merged 9 commits into from
Feb 14, 2023
1 change: 0 additions & 1 deletion examples/prompts/asyncio-prompt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
"""
(Python >= 3.6)
This is an example of how to prompt inside an application that uses the asyncio
eventloop. The ``prompt_toolkit`` library will make sure that when other
coroutines are writing to stdout, they write above the prompt, not destroying
Expand Down
23 changes: 11 additions & 12 deletions examples/ssh/asyncssh-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"""
import asyncio
import logging
from asyncio import run

import asyncssh
from pygments.lexers.html import HtmlLexer

from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.contrib.ssh import PromptToolkitSSHServer, PromptToolkitSSHSession
from prompt_toolkit.eventloop import get_event_loop
from prompt_toolkit.lexers import PygmentsLexer
from prompt_toolkit.shortcuts import ProgressBar, print_formatted_text
from prompt_toolkit.shortcuts.dialogs import input_dialog, yes_no_dialog
Expand Down Expand Up @@ -101,22 +101,21 @@ async def interact(ssh_session: PromptToolkitSSHSession) -> None:
await input_dialog("Input dialog", "Running over asyncssh").run_async()


def main(port=8222):
async def main(port=8222):
# Set up logging.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)

loop = get_event_loop()
loop.run_until_complete(
asyncssh.create_server(
lambda: PromptToolkitSSHServer(interact),
"",
port,
server_host_keys=["/etc/ssh/ssh_host_ecdsa_key"],
)
await asyncssh.create_server(
lambda: PromptToolkitSSHServer(interact),
"",
port,
server_host_keys=["/etc/ssh/ssh_host_ecdsa_key"],
)
loop.run_forever()

# Run forever.
await asyncio.Future()


if __name__ == "__main__":
main()
asyncio.run(main())
10 changes: 6 additions & 4 deletions examples/telnet/chat-app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"""
import logging
import random
from asyncio import Future, run

from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.eventloop import get_event_loop
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import PromptSession, clear

Expand Down Expand Up @@ -91,11 +91,13 @@ def _send_to_everyone(sender_connection, name, message, color):
)


def main():
async def main():
server = TelnetServer(interact=interact, port=2323)
server.start()
get_event_loop().run_forever()

# Run forever.
await Future()


if __name__ == "__main__":
main()
run(main())
10 changes: 6 additions & 4 deletions examples/telnet/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Example of a telnet application that displays a dialog window.
"""
import logging
from asyncio import Future, run

from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.eventloop import get_event_loop
from prompt_toolkit.shortcuts.dialogs import yes_no_dialog

# Set up logging
Expand All @@ -22,11 +22,13 @@ async def interact(connection):
connection.send("Bye.\n")


def main():
async def main():
server = TelnetServer(interact=interact, port=2323)
server.start()
get_event_loop().run_forever()

# Run forever.
await Future()


if __name__ == "__main__":
main()
run(main())
9 changes: 4 additions & 5 deletions examples/telnet/hello-world.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
That is probably the preferred way if you only need Python 3 support.
"""
import logging
from asyncio import Future, run

from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.eventloop import get_event_loop
from prompt_toolkit.shortcuts import PromptSession, clear

# Set up logging
Expand All @@ -30,11 +30,10 @@ async def interact(connection):
connection.send("Bye.\n")


def main():
async def main():
server = TelnetServer(interact=interact, port=2323)
server.start()
get_event_loop().run_forever()
await server.run()


if __name__ == "__main__":
main()
run(main())
9 changes: 4 additions & 5 deletions examples/telnet/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
in the prompt.
"""
import logging
from asyncio import Future, run

from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.eventloop import get_event_loop
from prompt_toolkit.shortcuts import PromptSession

# Set up logging
Expand Down Expand Up @@ -35,11 +35,10 @@ def get_toolbar():
connection.send("Bye.\n")


def main():
async def main():
server = TelnetServer(interact=interact, port=2323)
server.start()
get_event_loop().run_forever()
await server.run()


if __name__ == "__main__":
main()
run(main())
16 changes: 3 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,16 @@ def get_version(package):
package_dir={"": "src"},
package_data={"prompt_toolkit": ["py.typed"]},
install_requires=["wcwidth"],
# We require Python 3.6.2 for three reasons:
# - Syntax for variable annotations - PEP 526.
# - Asynchronous generators - PEP 525.
# - New type annotations in 3.6.2 (i.e. NoReturn)
# Also, 3.6.0 doesn't have `typing.AsyncGenerator` yet. 3.6.1 does.
# Python 3.7 is suggested, because:
# We require Python 3.7, because we need:
# - Context variables - PEP 567
# (The current application is derived from a context variable.)
# There is no intension to support Python 3.5, because prompt_toolkit 2.0
# does run fine on any older Python version starting from Python 2.6, and
# it is possible to write code that runs both against prompt_toolkit
# version 2 and 3.
python_requires=">=3.6.2",
# - `asyncio.run()`
python_requires=">=3.7.0",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
2 changes: 2 additions & 0 deletions src/prompt_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Probably, to get started, you might also want to have a look at
`prompt_toolkit.shortcuts.prompt`.
"""
from __future__ import annotations

import re

# note: this is a bit more lax than the actual pep 440 to allow for a/b/rc/dev without a number
Expand Down
2 changes: 2 additions & 0 deletions src/prompt_toolkit/application/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .application import Application
from .current import (
AppSession,
Expand Down
Loading