Skip to content

Commit

Permalink
Fix not callable issue I just created with the last fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Oct 18, 2023
1 parent 97eba76 commit f3e5a36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion trio/_core/_tests/test_guest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
8 changes: 4 additions & 4 deletions trio/_core/_tests/test_thread_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def test_thread_cache_basics() -> None:
q = cast("Queue[Outcome]", Queue)()
q = cast("Queue[Outcome]", Queue())

Check failure on line 19 in trio/_core/_tests/test_thread_cache.py

View workflow job for this annotation

GitHub Actions / Ubuntu (3.8, check formatting)

Mypy-Linux+Mac+Windows

trio/_core/_tests/test_thread_cache.py:(19:9 - 19:9): Redundant cast to "Queue[Any]" [redundant-cast]

def fn() -> NoReturn:
raise RuntimeError("hi")
Expand All @@ -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())

Check failure on line 44 in trio/_core/_tests/test_thread_cache.py

View workflow job for this annotation

GitHub Actions / Ubuntu (3.8, check formatting)

Mypy-Linux+Mac+Windows

trio/_core/_tests/test_thread_cache.py:(44:9 - 44:9): Redundant cast to "Queue[Any]" [redundant-cast]

def deliver(outcome: Outcome) -> None:
q.put(outcome)
Expand All @@ -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())

Check failure on line 67 in trio/_core/_tests/test_thread_cache.py

View workflow job for this annotation

GitHub Actions / Ubuntu (3.8, check formatting)

Mypy-Linux+Mac+Windows

trio/_core/_tests/test_thread_cache.py:(67:9 - 67:9): Redundant cast to "Queue[Any]" [redundant-cast]
COUNT = 5
for _ in range(COUNT):
start_thread_soon(lambda: time.sleep(1), lambda result: q.put(result))
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions trio/_tests/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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())

Check failure on line 1061 in trio/_tests/test_threads.py

View workflow job for this annotation

GitHub Actions / Ubuntu (3.8, check formatting)

Mypy-Linux+Mac+Windows

trio/_tests/test_threads.py:(1061:9 - 1061:9): Redundant cast to "Queue[Any]" [redundant-cast]
_core.start_thread_soon(from_thread_check_cancelled, lambda _: q.put(_))
with pytest.raises(RuntimeError):
q.get(timeout=1).unwrap()

0 comments on commit f3e5a36

Please sign in to comment.