Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3547.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`trio.Path.full_match` is now a synchronous method, like `pathlib.PurePath.full_match` and `trio.Path.match`. It was previously wrapped to run in a worker thread, so calling it without ``await`` returned a coroutine, which is always truthy.
2 changes: 0 additions & 2 deletions src/trio/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ def __repr__(self) -> str:
write_text = _wrap_method(pathlib.Path.write_text)
if sys.version_info < (3, 12):
link_to = _wrap_method(pathlib.Path.link_to)
if sys.version_info >= (3, 13):
full_match = _wrap_method(pathlib.Path.full_match)

def as_uri(self) -> str:
return self._wrapped_cls(self).as_uri()
Expand Down
12 changes: 12 additions & 0 deletions src/trio/_tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import pathlib
import sys
from typing import TYPE_CHECKING

import pytest
Expand Down Expand Up @@ -230,6 +231,17 @@ async def test_globmethods(path: trio.Path) -> None:
assert entries == {"_bar.txt", "bar.txt"}


def test_full_match_is_sync() -> None:
if sys.version_info < (3, 13):
pytest.skip("PurePath.full_match is 3.13+")

# full_match() is a pure path method like match(), so it must not be async
path = trio.Path("foo/bar.py")
assert path.full_match("**/*.py") is True
assert path.full_match("*.py") is False
assert path.full_match("FOO/BAR.PY", case_sensitive=False) is True


async def test_as_uri(path: trio.Path) -> None:
path = await path.parent.resolve()

Expand Down
Loading