aboutsummaryrefslogtreecommitdiffstats
path: root/config_file/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'config_file/utils.py')
-rw-r--r--config_file/utils.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/config_file/utils.py b/config_file/utils.py
index 05c3a7a..9ed09b5 100644
--- a/config_file/utils.py
+++ b/config_file/utils.py
@@ -1,8 +1,8 @@
-from pathlib import Path
-from typing import Union
+from pathlib import PurePath
+from typing import Type, Union
-def split_on_dot(line: Union[str, Path], only_last_dot=False):
+def split_on_dot(line: Union[str, Type[PurePath]], only_last_dot=False):
"""
Split a string on the dot character (.).
@@ -11,17 +11,15 @@ def split_on_dot(line: Union[str, Path], only_last_dot=False):
:raises ValueError: if the line does not have a dot.
"""
- if isinstance(line, Path):
+ if isinstance(line, PurePath):
line = str(line)
if "." not in line:
- raise ValueError(
- "The given string does not have a dot to split on: {}".format(line)
- )
+ raise ValueError(f"The given string does not have a dot to split on: {line}")
return line.rsplit(".", 1) if only_last_dot else line.split(".")
-def read_file(path: Union[str, Path]):
+def read_file(path: Union[str, Type[PurePath]]):
with open(path, "r") as file:
return file.read()