Repository: prompt-toolkit/python-prompt-toolkit (branch: master)
Commit date: 2023-12-07T13:48:18Z

Workflow file: .github/workflows/test.yaml (test)
name: test

on:
  push: # any branch
  pull_request:
    branches: [master]

env:
  FORCE_COLOR: '1'
  PIP_INDEX_URL: http://localhost:8629/2023-12-07
  UV_INDEX_URL: http://localhost:8629/2023-12-07

jobs:
  test-ubuntu:
    runs-on: ubuntu-latest
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

    steps:
      - uses: actions/checkout@v4
      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true
      - name: Install Dependencies
        run: |
          sudo apt remove python3-pip
          python -m pip install --upgrade pip
          python -m pip install . ruff typos coverage codecov mypy pytest readme_renderer types-contextvars asyncssh
          pip list
      - name: Ruff
        run: |
          ruff .
          ruff format --check .
          typos .
      - name: Tests
        run: |
          coverage run -m pytest
      - if: "matrix.python-version != '3.7'"
        name: Mypy
        # Check whether the imports were sorted correctly.
        # When this fails, please run ./tools/sort-imports.sh
        run: |
          mypy --strict src/prompt_toolkit --platform win32
          mypy --strict src/prompt_toolkit --platform linux
          mypy --strict src/prompt_toolkit --platform darwin
      - name: Validate README.md
        # Ensure that the README renders correctly (required for uploading to PyPI).
        run: |
          python -m readme_renderer README.rst > /dev/null
      - name: Run codecov
        run: |
          codecov


Failed build logs:
step_name: test-ubuntu (3.7)/5_Ruff.txt
log: ##[group]Run ruff .
[36;1mruff .[0m
[36;1mruff format --check .[0m
[36;1mtypos .[0m
shell: /usr/bin/bash -e {0}
env:
  FORCE_COLOR: 1
  pythonLocation: /opt/hostedtoolcache/Python/3.7.17/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.7.17/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.17/x64/lib
##[endgroup]
Would reformat: src/prompt_toolkit/application/application.py
Would reformat: src/prompt_toolkit/eventloop/inputhook.py
2 files would be reformatted, 284 files left unchanged
##[error]Process completed with exit code 1.

step_name: test-ubuntu (3.8)/5_Ruff.txt
log: ##[group]Run ruff .
[36;1mruff .[0m
[36;1mruff format --check .[0m
[36;1mtypos .[0m
shell: /usr/bin/bash -e {0}
env:
  FORCE_COLOR: 1
  pythonLocation: /opt/hostedtoolcache/Python/3.8.18/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.8.18/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.8.18/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.8.18/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.8.18/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.18/x64/lib
##[endgroup]
Would reformat: src/prompt_toolkit/application/application.py
Would reformat: src/prompt_toolkit/eventloop/inputhook.py
2 files would be reformatted, 284 files left unchanged
##[error]Process completed with exit code 1.

step_name: test-ubuntu (3.9)/5_Ruff.txt
log: ##[group]Run ruff .
[36;1mruff .[0m
[36;1mruff format --check .[0m
[36;1mtypos .[0m
shell: /usr/bin/bash -e {0}
env:
  FORCE_COLOR: 1
  pythonLocation: /opt/hostedtoolcache/Python/3.9.18/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib
##[endgroup]
Would reformat: src/prompt_toolkit/application/application.py
Would reformat: src/prompt_toolkit/eventloop/inputhook.py
2 files would be reformatted, 284 files left unchanged
##[error]Process completed with exit code 1.

step_name: test-ubuntu (3.10)/5_Ruff.txt
log: ##[group]Run ruff .
[36;1mruff .[0m
[36;1mruff format --check .[0m
[36;1mtypos .[0m
shell: /usr/bin/bash -e {0}
env:
  FORCE_COLOR: 1
  pythonLocation: /opt/hostedtoolcache/Python/3.10.13/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.13/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.13/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.13/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.13/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.13/x64/lib
##[endgroup]
Would reformat: src/prompt_toolkit/application/application.py
Would reformat: src/prompt_toolkit/eventloop/inputhook.py
2 files would be reformatted, 284 files left unchanged
##[error]Process completed with exit code 1.

step_name: test-ubuntu (3.11)/5_Ruff.txt
log: ##[group]Run ruff .
[36;1mruff .[0m
[36;1mruff format --check .[0m
[36;1mtypos .[0m
shell: /usr/bin/bash -e {0}
env:
  FORCE_COLOR: 1
  pythonLocation: /opt/hostedtoolcache/Python/3.11.6/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.6/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.6/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.6/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.6/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.6/x64/lib
##[endgroup]
Would reformat: src/prompt_toolkit/application/application.py
Would reformat: src/prompt_toolkit/eventloop/inputhook.py
2 files would be reformatted, 284 files left unchanged
##[error]Process completed with exit code 1.

step_name: test-ubuntu (3.12)/5_Ruff.txt
log: ##[group]Run ruff .
[36;1mruff .[0m
[36;1mruff format --check .[0m
[36;1mtypos .[0m
shell: /usr/bin/bash -e {0}
env:
  FORCE_COLOR: 1
  pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib
##[endgroup]
Would reformat: src/prompt_toolkit/application/application.py
Would reformat: src/prompt_toolkit/eventloop/inputhook.py
2 files would be reformatted, 284 files left unchanged
##[error]Process completed with exit code 1.


Changed files:
src/prompt_toolkit/application/application.py
src/prompt_toolkit/eventloop/inputhook.py
src/prompt_toolkit/patch_stdout.py

Fix diff:
diff --git a/src/prompt_toolkit/application/application.py b/src/prompt_toolkit/application/application.py
index 6a8f0290..2dcb3130 100644
--- a/src/prompt_toolkit/application/application.py
+++ b/src/prompt_toolkit/application/application.py
@@ -985,7 +985,7 @@ class Application(Generic[_AppResult]):
                 # See whether a loop was installed already. If so, use that.
                 # That's required for the input hooks to work, they are
                 # installed using `set_event_loop`.
-                loop = asyncio.get_running_loop()
+                loop = asyncio.get_event_loop()
             except RuntimeError:
                 # No loop installed. Run like usual.
                 return asyncio.run(coro)
@@ -1545,7 +1545,7 @@ async def _do_wait_for_enter(wait_text: AnyFormattedText) -> None:
 
 @contextmanager
 def attach_winch_signal_handler(
-    handler: Callable[[], None]
+    handler: Callable[[], None],
 ) -> Generator[None, None, None]:
     """
     Attach the given callback as a WINCH signal handler within the context
diff --git a/src/prompt_toolkit/eventloop/inputhook.py b/src/prompt_toolkit/eventloop/inputhook.py
index 5731573f..a4c0eee6 100644
--- a/src/prompt_toolkit/eventloop/inputhook.py
+++ b/src/prompt_toolkit/eventloop/inputhook.py
@@ -66,7 +66,7 @@ InputHook: TypeAlias = Callable[[InputHookContext], None]
 
 
 def new_eventloop_with_inputhook(
-    inputhook: Callable[[InputHookContext], None]
+    inputhook: Callable[[InputHookContext], None],
 ) -> AbstractEventLoop:
     """
     Create a new event loop with the given inputhook.
@@ -77,7 +77,7 @@ def new_eventloop_with_inputhook(
 
 
 def set_eventloop_with_inputhook(
-    inputhook: Callable[[InputHookContext], None]
+    inputhook: Callable[[InputHookContext], None],
 ) -> AbstractEventLoop:
     """
     Create a new event loop with the given inputhook, and activate it.
diff --git a/src/prompt_toolkit/patch_stdout.py b/src/prompt_toolkit/patch_stdout.py
index 46619cac..528bec7f 100644
--- a/src/prompt_toolkit/patch_stdout.py
+++ b/src/prompt_toolkit/patch_stdout.py
@@ -203,6 +203,13 @@ class StdoutProxy:
         """
 
         def write_and_flush() -> None:
+            # Ensure that autowrap is enabled before calling `write`.
+            # XXX: On Windows, the `Windows10_Output` enables/disables VT
+            #      terminal processing for every flush. It turns out that this
+            #      causes autowrap to be reset (disabled) after each flush. So,
+            #      we have to enable it again before writing text.
+            self._output.enable_autowrap()
+
             if self.raw:
                 self._output.write_raw(text)
             else: