From 091e0dbf79255219384bba7e6941c855ada28f7a Mon Sep 17 00:00:00 2001 From: Boris Smidt Date: Thu, 6 Jul 2023 14:50:30 +0200 Subject: [PATCH] #88: Fix unrelated failing test of powershell autocomplete --- tests/test_completion/test_completion_install.py | 12 ++---------- typer/main.py | 7 ++----- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/tests/test_completion/test_completion_install.py b/tests/test_completion/test_completion_install.py index 0856b9b565..830f5901c9 100644 --- a/tests/test_completion/test_completion_install.py +++ b/tests/test_completion/test_completion_install.py @@ -5,14 +5,12 @@ from unittest import mock import shellingham -import typer -from typer.testing import CliRunner from docs_src.commands.index import tutorial001 as mod +from typer.testing import CliRunner runner = CliRunner() -app = typer.Typer() -app.command()(mod.main) +app = mod.app def test_completion_install_no_shell(): @@ -144,12 +142,6 @@ def test_completion_install_fish(): assert "completion installed in" in result.stdout assert "Completion will take effect once you restart the terminal" in result.stdout - -runner = CliRunner() -app = typer.Typer() -app.command()(mod.main) - - def test_completion_install_powershell(): completion_path: Path = ( Path.home() / f".config/powershell/Microsoft.PowerShell_profile.ps1" diff --git a/typer/main.py b/typer/main.py index 2e644ccc4e..e0895bc722 100644 --- a/typer/main.py +++ b/typer/main.py @@ -47,10 +47,7 @@ except ImportError: # pragma: nocover rich = None # type: ignore -try: - from asyncio import Loop -except ImportError: # pragma: nocover - Loop = Any # type: ignore +from asyncio import AbstractEventLoop _original_except_hook = sys.excepthook _typer_developer_exception_attr_name = "__typer_developer_exception__" @@ -145,7 +142,7 @@ def __init__( pretty_exceptions_enable: bool = True, pretty_exceptions_show_locals: bool = True, pretty_exceptions_short: bool = True, - loop_factory: Optional[Callable[[], Loop]] = None, + loop_factory: Optional[Callable[[], AbstractEventLoop]] = None, ): self._add_completion = add_completion self.rich_markup_mode: MarkupMode = rich_markup_mode