Skip to content

Commit

Permalink
Retracted the TaskInfo type annotation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Nov 30, 2024
1 parent dfd79ae commit f58bef4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 1 addition & 5 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ This library adheres to `Semantic Versioning 2.0 <http://semver.org/>`_.

**UNRELEASED**

- Improved compatibility with asyncio's eager task factories:

* Updated the annotation of ``TaskInfo.coro`` to allow it to be ``None``
* Updated ``TaskGroup`` to work with asyncio eager task factories

- Updated ``TaskGroup`` to work with asyncio's eager task factories
(`#764 <https://github.com/agronholm/anyio/issues/764>`_)
- Fixed a misleading ``ValueError`` in the context of DNS failures
(`#815 <https://github.com/agronholm/anyio/issues/815>`_; PR by @graingert)
Expand Down
4 changes: 3 additions & 1 deletion src/anyio/_backends/_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,9 @@ def __init__(self, task: asyncio.Task):
else:
parent_id = task_state.parent_id

super().__init__(id(task), parent_id, task.get_name(), task.get_coro())
coro = task.get_coro()
assert coro is not None, "created TaskInfo from a completed Task"
super().__init__(id(task), parent_id, task.get_name(), coro)
self._task = weakref.ref(task)

def has_pending_cancellation(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions src/anyio/_core/_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def __init__(
id: int,
parent_id: int | None,
name: str | None,
coro: Generator[Any, Any, Any] | Awaitable[Any] | None,
coro: Generator[Any, Any, Any] | Awaitable[Any],
):
func = get_current_task
self._name = f"{func.__module__}.{func.__qualname__}"
self.id: int = id
self.parent_id: int | None = parent_id
self.name: str | None = name
self.coro: Generator[Any, Any, Any] | Awaitable[Any] | None = coro
self.coro: Generator[Any, Any, Any] | Awaitable[Any] = coro

def __eq__(self, other: object) -> bool:
if isinstance(other, TaskInfo):
Expand Down

0 comments on commit f58bef4

Please sign in to comment.