diff --git a/tomlkit/toml_file.py b/tomlkit/toml_file.py index d05a62f..7459130 100644 --- a/tomlkit/toml_file.py +++ b/tomlkit/toml_file.py @@ -1,10 +1,20 @@ import os import re +from typing import TYPE_CHECKING + from tomlkit.api import loads from tomlkit.toml_document import TOMLDocument +if TYPE_CHECKING: + from _typeshed import StrPath as _StrPath +else: + from typing import Union + + _StrPath = Union[str, os.PathLike] + + class TOMLFile: """ Represents a TOML file. @@ -12,7 +22,7 @@ class TOMLFile: :param path: path to the TOML file """ - def __init__(self, path: str) -> None: + def __init__(self, path: _StrPath) -> None: self._path = path self._linesep = os.linesep