Skip to content

Commit cb822da

Browse files
authored
fix: allow broader type for toml file path value (#243)
* allow broader type for toml file path value Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com> * reuse strpath from typeshed Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com> Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
1 parent 86b61f2 commit cb822da

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tomlkit/toml_file.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
import os
22
import re
33

4+
from typing import TYPE_CHECKING
5+
46
from tomlkit.api import loads
57
from tomlkit.toml_document import TOMLDocument
68

79

10+
if TYPE_CHECKING:
11+
from _typeshed import StrPath as _StrPath
12+
else:
13+
from typing import Union
14+
15+
_StrPath = Union[str, os.PathLike]
16+
17+
818
class TOMLFile:
919
"""
1020
Represents a TOML file.
1121
1222
:param path: path to the TOML file
1323
"""
1424

15-
def __init__(self, path: str) -> None:
25+
def __init__(self, path: _StrPath) -> None:
1626
self._path = path
1727
self._linesep = os.linesep
1828

0 commit comments

Comments
 (0)