We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b1db31e commit 8ce238fCopy full SHA for 8ce238f
1 file changed
pkg/src/fileex/typing.py
@@ -0,0 +1,21 @@
1
+"""FileEx type-hint definitions.
2
+
3
+This module defines type-hints used throughout the package.
4
+"""
5
6
+from pathlib import Path
7
+from typing import TypeAlias
8
9
10
+PathLike: TypeAlias = Path | str
11
+"""A file path, either as a string or a `pathlib.Path` object."""
12
13
14
+FileLike: TypeAlias = PathLike | str | bytes
15
+"""A file-like input.
16
17
+- If a `pathlib.Path` is provided, it is interpreted as the path to a file.
18
+- If `bytes` are provided, they are interpreted as the content of the file.
19
+- If a `str` is provided, it is interpreted as the content of the file
20
+ unless it is a valid existing file path, in which case it is treated as the path to a file.
21
0 commit comments