Skip to content

Commit 56462f8

Browse files
better pathlib api
1 parent 091d8d9 commit 56462f8

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

reflex/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,7 @@ def get_compilation_time() -> str:
11701170
if not dry_run and not should_compile and backend_dir.exists():
11711171
stateful_pages_marker = backend_dir / constants.Dirs.STATEFUL_PAGES
11721172
if stateful_pages_marker.exists():
1173-
with stateful_pages_marker.open("rb") as f:
1174-
stateful_pages = format.orjson_loads(f.read())
1173+
stateful_pages = format.orjson_loads(stateful_pages_marker.read_bytes())
11751174
for route in stateful_pages:
11761175
console.debug(f"BE Evaluating stateful page: {route}")
11771176
self._compile_page(route, save_page=False)

reflex/utils/exec.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def get_package_json_and_hash(package_json_path: Path) -> tuple[PackageJson, str
3737
Returns:
3838
A tuple containing the content of package.json as a dictionary and its SHA-256 hash.
3939
"""
40-
with package_json_path.open("rb") as file:
41-
json_data = orjson_loads(file.read())
40+
json_data = orjson_loads(package_json_path.read_bytes())
4241

4342
# Calculate the hash
4443
json_string = orjson_dumps(json_data, sort_keys=True)

reflex/utils/path_ops.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]):
245245
# Read the existing json object from the file.
246246
json_object = {}
247247
if fp.stat().st_size:
248-
with fp.open("rb") as f:
249-
json_object = orjson_loads(f.read())
248+
json_object = orjson_loads(fp.read_bytes())
250249

251250
# Update the json object with the new data.
252251
json_object.update(update_dict)

0 commit comments

Comments
 (0)