Skip to content

Commit b7177b0

Browse files
committed
Restore trio.Path#as_uri
1 parent e6b3add commit b7177b0

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/trio/_path.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ def __repr__(self) -> str:
244244
if sys.version_info >= (3, 13):
245245
full_match = _wrap_method(pathlib.Path.full_match)
246246

247+
def as_uri(self) -> str:
248+
return pathlib.Path.as_uri(self)
249+
247250

248251
@final
249252
class PosixPath(Path, pathlib.PurePosixPath):

src/trio/_tests/test_path.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ def test_forward_methods_without_rewrap(path: trio.Path) -> None:
172172
assert "totally-unique-path" in str(path.joinpath("totally-unique-path"))
173173

174174

175-
async def test_path_methods_on_trio_path(path: trio.Path) -> None:
176-
path = await path.parent.resolve()
177-
178-
assert pathlib.Path.as_uri(path).startswith("file:///")
179-
180-
181175
def test_repr() -> None:
182176
path = trio.Path(".")
183177

@@ -236,6 +230,12 @@ async def test_globmethods(path: trio.Path) -> None:
236230
assert entries == {"_bar.txt", "bar.txt"}
237231

238232

233+
async def test_as_uri(path: trio.Path) -> None:
234+
path = await path.parent.resolve()
235+
236+
assert path.as_uri().startswith("file:///")
237+
238+
239239
async def test_iterdir(path: trio.Path) -> None:
240240
# Populate a directory
241241
await path.mkdir()

src/trio/_tests/type_tests/path.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def sync_attrs(path: trio.Path) -> None:
4646
assert_type(path.suffixes, list[str])
4747
assert_type(path.stem, str)
4848
assert_type(path.as_posix(), str)
49+
assert_type(path.as_uri(), str)
4950
assert_type(path.is_absolute(), bool)
5051
assert_type(path.is_relative_to(path), bool)
5152
assert_type(path.is_reserved(), bool)

0 commit comments

Comments
 (0)