Skip to content

Commit 1fc9ea7

Browse files
committed
Handle typing changes
1 parent 428cef0 commit 1fc9ea7

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

src/trio/_core/_local.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ def get(self, default: T | type[_NoValue] = _NoValue) -> T:
4949
raise RuntimeError("Cannot be used outside of a run context") from None
5050
except KeyError:
5151
# contextvars consistency
52-
# `type: ignore` awaiting https://github.com/python/mypy/issues/15553 to be fixed & released
5352
if default is not _NoValue:
54-
return default # type: ignore[return-value]
53+
return default
5554

5655
if self._default is not _NoValue:
57-
return self._default # type: ignore[return-value]
56+
return self._default
5857

5958
raise LookupError(self) from None
6059

src/trio/_core/_tests/test_asyncgen.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ def test_delegation_to_existing_hooks() -> None:
306306

307307
def my_firstiter(agen: AsyncGenerator[object, NoReturn]) -> None:
308308
assert isinstance(agen, AsyncGeneratorType)
309+
assert agen.ag_frame is not None
309310
record.append("firstiter " + agen.ag_frame.f_locals["arg"])
310311

311312
def my_finalizer(agen: AsyncGenerator[object, NoReturn]) -> None:
312313
assert isinstance(agen, AsyncGeneratorType)
314+
assert agen.ag_frame is not None
313315
record.append("finalizer " + agen.ag_frame.f_locals["arg"])
314316

315317
async def example(arg: str) -> AsyncGenerator[int, None]:

src/trio/_path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ def __repr__(self) -> str:
263263
if sys.version_info >= (3, 13):
264264
full_match = _wrap_method(pathlib.Path.full_match)
265265

266+
# TODO: only allow this for Python <3.19.
266267
def as_uri(self) -> str:
267-
return pathlib.Path.as_uri(self)
268+
return pathlib.PurePath.as_uri(self)
268269

269270

270271
if Path.relative_to.__doc__: # pragma: no branch

src/trio/_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def fromshare(info: bytes) -> SocketType:
338338
else:
339339
FamilyDefault: None = None
340340
FamilyT: TypeAlias = int | AddressFamily | None
341-
TypeT: TypeAlias = _stdlib_socket.socket | int
341+
TypeT: TypeAlias = _stdlib_socket.SocketKind | int
342342

343343

344344
@_wraps(_stdlib_socket.socketpair, assigned=(), updated=())

src/trio/_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ def name_asyncgen(agen: AsyncGeneratorType[object, NoReturn]) -> str:
298298
if not hasattr(agen, "ag_code"): # pragma: no cover
299299
return repr(agen)
300300
try:
301-
module = agen.ag_frame.f_globals["__name__"]
301+
# `agen.ag_frame` can be None, but we catch AttributeError.
302+
module = agen.ag_frame.f_globals["__name__"] # type: ignore[union-attr]
302303
except (AttributeError, KeyError):
303304
module = f"<{agen.ag_code.co_filename}>"
304305
try:

0 commit comments

Comments
 (0)