Handle os.PathLike in is_path

This commit is contained in:
Hugo van Kemenade 2024-01-26 19:11:18 +02:00
parent e3932b7dba
commit 945253672a
2 changed files with 2 additions and 2 deletions

View File

@ -230,7 +230,7 @@ class FreeTypeFont:
)
if is_path(font):
if isinstance(font, Path):
if isinstance(font, os.PathLike):
font = str(font)
if sys.platform == "win32":
font_bytes_path = font if isinstance(font, bytes) else font.encode()

View File

@ -8,7 +8,7 @@ from ._typing import StrOrBytesPath, TypeGuard
def is_path(f: Any) -> TypeGuard[StrOrBytesPath]:
return isinstance(f, (bytes, str, Path))
return isinstance(f, (bytes, str, os.PathLike))
def is_directory(f: Any) -> TypeGuard[bytes | str | Path]: