|
37 | 37 | ALL_TAGS = frozenset(_ALL_TAGS) |
38 | 38 |
|
39 | 39 |
|
40 | | -def tags_from_path(path: str) -> set[str]: |
| 40 | +def tags_from_path(path: str | os.PathLike[str]) -> set[str]: |
41 | 41 | try: |
42 | 42 | sr = os.lstat(path) |
43 | 43 | except (OSError, ValueError): # same error-handling as `os.lexists()` |
@@ -83,7 +83,7 @@ def tags_from_path(path: str) -> set[str]: |
83 | 83 | return tags |
84 | 84 |
|
85 | 85 |
|
86 | | -def tags_from_filename(path: str) -> set[str]: |
| 86 | +def tags_from_filename(path: str | os.PathLike[str]) -> set[str]: |
87 | 87 | _, filename = os.path.split(path) |
88 | 88 | _, ext = os.path.splitext(filename) |
89 | 89 |
|
@@ -132,7 +132,7 @@ def is_text(bytesio: IO[bytes]) -> bool: |
132 | 132 | return not bool(bytesio.read(1024).translate(None, text_chars)) |
133 | 133 |
|
134 | 134 |
|
135 | | -def file_is_text(path: str) -> bool: |
| 135 | +def file_is_text(path: str | os.PathLike[str]) -> bool: |
136 | 136 | if not os.path.lexists(path): |
137 | 137 | raise ValueError(f'{path} does not exist.') |
138 | 138 | with open(path, 'rb') as f: |
@@ -202,7 +202,7 @@ def parse_shebang(bytesio: IO[bytes]) -> tuple[str, ...]: |
202 | 202 | return cmd |
203 | 203 |
|
204 | 204 |
|
205 | | -def parse_shebang_from_file(path: str) -> tuple[str, ...]: |
| 205 | +def parse_shebang_from_file(path: str | os.PathLike[str]) -> tuple[str, ...]: |
206 | 206 | """Parse the shebang given a file path.""" |
207 | 207 | if not os.path.lexists(path): |
208 | 208 | raise ValueError(f'{path} does not exist.') |
|
0 commit comments