22from collections import defaultdict
33from logging import Logger , getLogger
44from pathlib import Path
5- from typing import TypeVar
5+ from typing import Any , TypeVar
66
77import requests
88from cachetools import TTLCache , cachedmethod
1414
1515from .constants import ENDPOINTS
1616
17- T = TypeVar ("T" , str , bytes , dict ) # type: ignore - to allow any type of dict
17+ T = TypeVar ("T" , str , bytes , dict [ Any , Any ])
1818
1919
2020return_type_to_mime_type : dict [type , ValidAcceptHeaders ] = defaultdict (
2121 lambda : ValidAcceptHeaders .PLAIN_TEXT ,
2222 {
23- dict : ValidAcceptHeaders .JSON ,
23+ dict [ Any , Any ] : ValidAcceptHeaders .JSON ,
2424 str : ValidAcceptHeaders .PLAIN_TEXT ,
2525 bytes : ValidAcceptHeaders .RAW_BYTES ,
2626 },
@@ -135,7 +135,7 @@ def _get(
135135
136136 def get_file_contents (
137137 self ,
138- file_path : Path ,
138+ file_path : Path | str ,
139139 desired_return_type : type [T ] = str ,
140140 reset_cached_result : bool = False ,
141141 ) -> T :
@@ -155,7 +155,7 @@ def get_file_contents(
155155 Returns:
156156 The file contents, in the format specified.
157157 """
158-
158+ file_path = Path ( file_path )
159159 accept_header = return_type_to_mime_type [desired_return_type ]
160160
161161 return TypeAdapter (desired_return_type ).validate_python ( # type: ignore - to allow any dict
@@ -166,3 +166,8 @@ def get_file_contents(
166166 reset_cached_result = reset_cached_result ,
167167 )
168168 )
169+
170+
171+ # thing = ConfigServer("url")
172+ # h = thing.get_file_contents("path", dict)
173+ # print(h)
0 commit comments