mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Handle os.PathLike in is_path
This commit is contained in:
parent
e3932b7dba
commit
945253672a
|
@ -230,7 +230,7 @@ class FreeTypeFont:
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_path(font):
|
if is_path(font):
|
||||||
if isinstance(font, Path):
|
if isinstance(font, os.PathLike):
|
||||||
font = str(font)
|
font = str(font)
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
font_bytes_path = font if isinstance(font, bytes) else font.encode()
|
font_bytes_path = font if isinstance(font, bytes) else font.encode()
|
||||||
|
|
|
@ -8,7 +8,7 @@ from ._typing import StrOrBytesPath, TypeGuard
|
||||||
|
|
||||||
|
|
||||||
def is_path(f: Any) -> TypeGuard[StrOrBytesPath]:
|
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]:
|
def is_directory(f: Any) -> TypeGuard[bytes | str | Path]:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user