WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Closed
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
8 changes: 4 additions & 4 deletions identify/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.')
Expand Down