Skip to content

Commit ab5687b

Browse files
committed
offline handler improvements
1 parent 682596d commit ab5687b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

flagsmith/offline_handlers.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ class EvaluationContextLocalFileHandler:
2121
"""
2222

2323
def __init__(self, file_path: str) -> None:
24-
with Path(file_path).open("r", encoding="utf-8") as f:
25-
self.evaluation_context: EvaluationContext = json.load(f)
24+
self.evaluation_context: EvaluationContext = json.loads(
25+
Path(file_path).read_text(),
26+
)
2627

2728
def get_evaluation_context(self) -> EvaluationContext:
2829
return self.evaluation_context
@@ -38,13 +39,18 @@ class EnvironmentDocumentLocalFileHandler:
3839
"""
3940

4041
def __init__(self, file_path: str) -> None:
41-
with Path(file_path).open("r", encoding="utf-8") as f:
42-
self.evaluation_context: EvaluationContext = (
43-
map_environment_document_to_context(json.load(f))
42+
self.evaluation_context: EvaluationContext = (
43+
map_environment_document_to_context(
44+
json.loads(
45+
Path(file_path).read_text(),
46+
),
4447
)
48+
)
4549

4650
def get_evaluation_context(self) -> EvaluationContext:
4751
return self.evaluation_context
4852

4953

54+
# For backward compatibility, use the old class name for
55+
# the local file handler implementation dependant on the environment document.
5056
LocalFileHandler = EnvironmentDocumentLocalFileHandler

0 commit comments

Comments
 (0)