From f3e5a36b4705430870e3532655181a5aa7e237d7 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Wed, 18 Oct 2023 18:35:44 -0500 Subject: [PATCH] Fix not callable issue I just created with the last fix --- trio/_core/_tests/test_guest_mode.py | 2 +- trio/_core/_tests/test_thread_cache.py | 8 ++++---- trio/_tests/test_threads.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/trio/_core/_tests/test_guest_mode.py b/trio/_core/_tests/test_guest_mode.py index d53048b067..bd0ef9ce69 100644 --- a/trio/_core/_tests/test_guest_mode.py +++ b/trio/_core/_tests/test_guest_mode.py @@ -459,7 +459,7 @@ async def trio_main() -> str: print("trio_main!") to_trio, from_aio = trio.open_memory_channel[int](float("inf")) - from_trio = cast("asyncio.Queue[int]", asyncio.Queue)() + from_trio = cast("asyncio.Queue[int]", asyncio.Queue()) aio_task = asyncio.ensure_future(aio_pingpong(from_trio, to_trio)) diff --git a/trio/_core/_tests/test_thread_cache.py b/trio/_core/_tests/test_thread_cache.py index 8f9be0d23f..e5b4902d8d 100644 --- a/trio/_core/_tests/test_thread_cache.py +++ b/trio/_core/_tests/test_thread_cache.py @@ -16,7 +16,7 @@ def test_thread_cache_basics() -> None: - q = cast("Queue[Outcome]", Queue)() + q = cast("Queue[Outcome]", Queue()) def fn() -> NoReturn: raise RuntimeError("hi") @@ -41,7 +41,7 @@ def __call__(self) -> int: def __del__(self) -> None: res[0] = True - q = cast("Queue[Outcome]", Queue)() + q = cast("Queue[Outcome]", Queue()) def deliver(outcome: Outcome) -> None: q.put(outcome) @@ -64,7 +64,7 @@ def test_spawning_new_thread_from_deliver_reuses_starting_thread() -> None: # Make sure there are a few threads running, so if we weren't LIFO then we # could grab the wrong one. - q = cast("Queue[Outcome]", Queue)() + q = cast("Queue[Outcome]", Queue()) COUNT = 5 for _ in range(COUNT): start_thread_soon(lambda: time.sleep(1), lambda result: q.put(result)) @@ -96,7 +96,7 @@ def test_idle_threads_exit(monkeypatch: MonkeyPatch) -> None: # CPU.) monkeypatch.setattr(_thread_cache, "IDLE_TIMEOUT", 0.0001) - q = cast("Queue[threading.Thread]", Queue)() + q = cast("Queue[threading.Thread]", Queue()) start_thread_soon(lambda: None, lambda _: q.put(threading.current_thread())) seen_thread = q.get() # Since the idle timeout is 0, after sleeping for 1 second, the thread diff --git a/trio/_tests/test_threads.py b/trio/_tests/test_threads.py index 866448dac8..4fa1e4bedf 100644 --- a/trio/_tests/test_threads.py +++ b/trio/_tests/test_threads.py @@ -347,7 +347,7 @@ async def child(q: stdlib_queue.Queue[None], cancellable: bool) -> None: record.append("exit") record: list[str] = [] - q = cast("stdlib_queue.Queue[None]", stdlib_queue.Queue)() + q = cast("stdlib_queue.Queue[None]", stdlib_queue.Queue()) async with _core.open_nursery() as nursery: nursery.start_soon(child, q, True) # Give it a chance to get started. (This is important because @@ -395,8 +395,8 @@ def test_run_in_worker_thread_abandoned( ) -> None: monkeypatch.setattr(_core._thread_cache, "IDLE_TIMEOUT", 0.01) - q1 = cast("stdlib_queue.Queue[None]", stdlib_queue.Queue)() - q2 = cast("stdlib_queue.Queue[threading.Thread]", stdlib_queue.Queue)() + q1 = cast("stdlib_queue.Queue[None]", stdlib_queue.Queue()) + q2 = cast("stdlib_queue.Queue[threading.Thread]", stdlib_queue.Queue()) def thread_fn() -> None: q1.get() @@ -919,7 +919,7 @@ def get_tid_then_reenter() -> int: async def test_from_thread_host_cancelled() -> None: - queue = cast("stdlib_queue.Queue[bool]", stdlib_queue.Queue)() + queue = cast("stdlib_queue.Queue[bool]", stdlib_queue.Queue()) def sync_check() -> None: from_thread_run_sync(cancel_scope.cancel) @@ -978,7 +978,7 @@ async def async_time_bomb() -> None: async def test_from_thread_check_cancelled() -> None: - q = cast("stdlib_queue.Queue[str]", stdlib_queue.Queue)() + q = cast("stdlib_queue.Queue[str]", stdlib_queue.Queue()) async def child(cancellable: bool, scope: CancelScope) -> None: with scope: @@ -1058,7 +1058,7 @@ def f() -> None: # type: ignore[no-redef] # noqa: F811 async def test_from_thread_check_cancelled_raises_in_foreign_threads() -> None: with pytest.raises(RuntimeError): from_thread_check_cancelled() - q = cast("stdlib_queue.Queue[Outcome]", stdlib_queue.Queue)() + q = cast("stdlib_queue.Queue[Outcome]", stdlib_queue.Queue()) _core.start_thread_soon(from_thread_check_cancelled, lambda _: q.put(_)) with pytest.raises(RuntimeError): q.get(timeout=1).unwrap()