Skip to content

Commit 0c95a61

Browse files
committed
converting paths to string
1 parent c14642a commit 0c95a61

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

supervision/utils/file.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def read_txt_file(file_path: Union[str, Path], skip_empty: bool = False) -> List
7070
Returns:
7171
List[str]: A list of strings representing the lines in the text file.
7272
"""
73-
with open(file_path.as_posix(), "r") as file:
73+
with open(str(file_path), "r") as file:
7474
if skip_empty:
7575
lines = [line.rstrip("\n") for line in file if line.strip()]
7676
else:
@@ -87,7 +87,7 @@ def save_text_file(lines: List[str], file_path: Union[str, Path]):
8787
lines (List[str]): The list of strings to be written to the file.
8888
file_path (Union[str, Path]): The file path as a string or Path object.
8989
"""
90-
with open(file_path.as_posix(), "w") as file:
90+
with open(str(file_path), "w") as file:
9191
for line in lines:
9292
file.write(line + "\n")
9393

@@ -102,7 +102,7 @@ def read_json_file(file_path: Union[str, Path]) -> dict:
102102
Returns:
103103
dict: A dict of annotations information
104104
"""
105-
with open(file_path.as_posix(), "r") as file:
105+
with open(str(file_path), "r") as file:
106106
data = json.load(file)
107107
return data
108108

@@ -116,7 +116,7 @@ def save_json_file(data: dict, file_path: Union[str, Path], indent: int = 3) ->
116116
data (dict): dict with unique keys and value as pair.
117117
file_path (Union[str, Path]): The file path as a string or Path object.
118118
"""
119-
with open(file_path.as_posix(), "w") as fp:
119+
with open(str(file_path), "w") as fp:
120120
json.dump(data, fp, cls=NumpyJsonEncoder, indent=indent)
121121

122122

@@ -130,7 +130,7 @@ def read_yaml_file(file_path: Union[str, Path]) -> dict:
130130
Returns:
131131
dict: A dict of content information
132132
"""
133-
with open(file_path.as_posix(), "r") as file:
133+
with open(str(file_path), "r") as file:
134134
data = yaml.safe_load(file)
135135
return data
136136

@@ -145,5 +145,5 @@ def save_yaml_file(data: dict, file_path: Union[str, Path]) -> None:
145145
file_path (Union[str, Path]): The file path as a string or Path object.
146146
"""
147147

148-
with open(file_path.as_posix(), "w") as outfile:
148+
with open(str(file_path), "w") as outfile:
149149
yaml.dump(data, outfile, sort_keys=False, default_flow_style=None)

0 commit comments

Comments
 (0)