Skip to content

Commit e62c972

Browse files
annotations: allow os.PathLike
1 parent a07859b commit e62c972

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

identify/identify.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
ALL_TAGS = frozenset(_ALL_TAGS)
3838

3939

40-
def tags_from_path(path: str) -> set[str]:
40+
def tags_from_path(path: str | os.PathLike[str]) -> set[str]:
4141
try:
4242
sr = os.lstat(path)
4343
except (OSError, ValueError): # same error-handling as `os.lexists()`
@@ -83,7 +83,7 @@ def tags_from_path(path: str) -> set[str]:
8383
return tags
8484

8585

86-
def tags_from_filename(path: str) -> set[str]:
86+
def tags_from_filename(path: str | os.PathLike[str]) -> set[str]:
8787
_, filename = os.path.split(path)
8888
_, ext = os.path.splitext(filename)
8989

@@ -132,7 +132,7 @@ def is_text(bytesio: IO[bytes]) -> bool:
132132
return not bool(bytesio.read(1024).translate(None, text_chars))
133133

134134

135-
def file_is_text(path: str) -> bool:
135+
def file_is_text(path: str | os.PathLike[str]) -> bool:
136136
if not os.path.lexists(path):
137137
raise ValueError(f'{path} does not exist.')
138138
with open(path, 'rb') as f:
@@ -202,7 +202,7 @@ def parse_shebang(bytesio: IO[bytes]) -> tuple[str, ...]:
202202
return cmd
203203

204204

205-
def parse_shebang_from_file(path: str) -> tuple[str, ...]:
205+
def parse_shebang_from_file(path: str | os.PathLike[str]) -> tuple[str, ...]:
206206
"""Parse the shebang given a file path."""
207207
if not os.path.lexists(path):
208208
raise ValueError(f'{path} does not exist.')

0 commit comments

Comments
 (0)