File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 11import ast
2- from pathlib import PurePath
2+ from pathlib import Path , PurePath
33from typing import Any , TypeVar
44
55import yaml
@@ -19,7 +19,7 @@ class LuxonisConfig(BaseModelExtraForbid):
1919 @classmethod
2020 def get_config (
2121 cls ,
22- cfg : str | Params | None = None ,
22+ cfg : PathType | Params | None = None ,
2323 overrides : Params | list [str ] | tuple [str , ...] | None = None ,
2424 ) -> Self :
2525 """Loads config from a yaml file or a dictionary.
@@ -50,7 +50,9 @@ def get_config(
5050 overrides = overrides or {}
5151 cfg = cfg or {}
5252
53- if isinstance (cfg , str ):
53+ if isinstance (cfg , Path ):
54+ data = yaml .safe_load (cfg .read_text (encoding = "utf-8" ))
55+ elif isinstance (cfg , str ):
5456 fs = LuxonisFileSystem (cfg )
5557 buffer = fs .read_to_byte_buffer ()
5658 data = yaml .safe_load (buffer )
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def test_invalid_config_path():
8282
8383
8484def test_config_simple (config_file : str ):
85- cfg = Config .get_config (config_file )
85+ cfg = Config .get_config (Path ( config_file ) )
8686 assert (
8787 cfg .sub_config .str_sub_param
8888 == CONFIG_DATA ["sub_config" ]["str_sub_param" ]
You can’t perform that action at this time.
0 commit comments