From e62c9722e8323f24039e30b0644728a02a2e0943 Mon Sep 17 00:00:00 2001 From: Randolf Scholz Date: Sun, 19 Oct 2025 18:15:57 +0200 Subject: [PATCH] annotations: allow os.PathLike --- identify/identify.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/identify/identify.py b/identify/identify.py index 0279ba8e..49c27008 100644 --- a/identify/identify.py +++ b/identify/identify.py @@ -37,7 +37,7 @@ ALL_TAGS = frozenset(_ALL_TAGS) -def tags_from_path(path: str) -> set[str]: +def tags_from_path(path: str | os.PathLike[str]) -> set[str]: try: sr = os.lstat(path) except (OSError, ValueError): # same error-handling as `os.lexists()` @@ -83,7 +83,7 @@ def tags_from_path(path: str) -> set[str]: return tags -def tags_from_filename(path: str) -> set[str]: +def tags_from_filename(path: str | os.PathLike[str]) -> set[str]: _, filename = os.path.split(path) _, ext = os.path.splitext(filename) @@ -132,7 +132,7 @@ def is_text(bytesio: IO[bytes]) -> bool: return not bool(bytesio.read(1024).translate(None, text_chars)) -def file_is_text(path: str) -> bool: +def file_is_text(path: str | os.PathLike[str]) -> bool: if not os.path.lexists(path): raise ValueError(f'{path} does not exist.') with open(path, 'rb') as f: @@ -202,7 +202,7 @@ def parse_shebang(bytesio: IO[bytes]) -> tuple[str, ...]: return cmd -def parse_shebang_from_file(path: str) -> tuple[str, ...]: +def parse_shebang_from_file(path: str | os.PathLike[str]) -> tuple[str, ...]: """Parse the shebang given a file path.""" if not os.path.lexists(path): raise ValueError(f'{path} does not exist.')