From f1a0a74782799bd350bf476e8bf31a44b48602aa Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 3 Nov 2023 17:40:38 +0200 Subject: [PATCH] Add support for Python 3.12 (#1782) * Add support for Python 3.12 * Add colour to test logs for readability * Remove redundant code for Python <= 3.6 * Fix Black warning --- .github/workflows/test.yaml | 11 ++++++++--- setup.py | 2 ++ src/prompt_toolkit/application/application.py | 2 +- src/prompt_toolkit/application/current.py | 4 +--- tests/test_cli.py | 2 +- tox.ini | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 511c14bac5..82ed05d432 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,19 +5,24 @@ on: pull_request: branches: [master] +env: + FORCE_COLOR: 1 + jobs: test-ubuntu: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Install Dependencies run: | sudo apt remove python3-pip diff --git a/setup.py b/setup.py index 61975989ff..ca2170ce44 100755 --- a/setup.py +++ b/setup.py @@ -44,6 +44,8 @@ def get_version(package): "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python", "Topic :: Software Development", diff --git a/src/prompt_toolkit/application/application.py b/src/prompt_toolkit/application/application.py index 8683705bf7..c6e67ab9f9 100644 --- a/src/prompt_toolkit/application/application.py +++ b/src/prompt_toolkit/application/application.py @@ -1005,7 +1005,7 @@ def _enable_breakpointhook(self) -> Generator[None, None, None]: manager. (We will only install the hook if no other custom hook was set.) """ - if sys.version_info >= (3, 7) and sys.breakpointhook == sys.__breakpointhook__: + if sys.breakpointhook == sys.__breakpointhook__: sys.breakpointhook = self._breakpointhook try: diff --git a/src/prompt_toolkit/application/current.py b/src/prompt_toolkit/application/current.py index 736cb064f4..908141a476 100644 --- a/src/prompt_toolkit/application/current.py +++ b/src/prompt_toolkit/application/current.py @@ -144,10 +144,8 @@ def create_app_session( Create a separate AppSession. This is useful if there can be multiple individual `AppSession`s going on. - Like in the case of an Telnet/SSH server. This functionality uses - contextvars and requires at least Python 3.7. + Like in the case of an Telnet/SSH server. """ - # If no input/output is specified, fall back to the current input/output, # whatever that is. if input is None: diff --git a/tests/test_cli.py b/tests/test_cli.py index 39aeedd45d..3a16e9fbd3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -190,7 +190,7 @@ def test_emacs_cursor_movements(): def test_emacs_kill_multiple_words_and_paste(): # Using control-w twice should place both words on the clipboard. result, cli = _feed_cli_with_input( - "hello world test" "\x17\x17" "--\x19\x19\r" # Twice c-w. # Twice c-y. + "hello world test\x17\x17--\x19\x19\r" # Twice c-w. Twice c-y. ) assert result.text == "hello --world testworld test" assert cli.clipboard.get_data().text == "world test" diff --git a/tox.ini b/tox.ini index 016beedb91..310f0761ec 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,10 @@ # and then run "tox" from this directory. [tox] -envlist = py26, py27, py33, py34, py35, pypy, pypy3 +envlist = py{37, 38, 39, 310, 311, 312, py3} [testenv] -commands = py.test [] +commands = pytest [] deps= pytest