Skip to content

Commit 8ce238f

Browse files
committed
Create typing.py
1 parent b1db31e commit 8ce238f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

pkg/src/fileex/typing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)