Skip to content

Commit be23309

Browse files
authored
really really make sure that we don't make pyi hashes file if we don't need to (#5083)
* really really make sure that we don't make pyi hashes file if we don't need to * what if i added something that would cause my local precommit to fail * blz * what * potentially * bruh * potentially * only some * no clean * no sparse checkout * reset avatar * verbose * show diff on failure * write only on diff * woops * avatar test * YEA
1 parent 6afcaf6 commit be23309

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ jobs:
2323
with:
2424
python-version: 3.13.2
2525
run-uv-sync: true
26-
- run: uv run pre-commit run --all-files
26+
- uses: actions/checkout@v4
27+
with:
28+
clean: false
29+
- run: uv run pre-commit run --all-files --show-diff-on-failure

reflex/utils/pyi_generator.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,12 +1250,20 @@ def scan_all(
12501250
file_parent = file_parent.parent
12511251
top_dir = top_dir.parent
12521252

1253-
(top_dir.parent / "pyi_hashes.json").write_text(
1253+
pyi_hashes_file = top_dir / "pyi_hashes.json"
1254+
if not pyi_hashes_file.exists():
1255+
while top_dir.parent and not (top_dir / "pyi_hashes.json").exists():
1256+
top_dir = top_dir.parent
1257+
another_pyi_hashes_file = top_dir / "pyi_hashes.json"
1258+
if another_pyi_hashes_file.exists():
1259+
pyi_hashes_file = another_pyi_hashes_file
1260+
1261+
pyi_hashes_file.write_text(
12541262
json.dumps(
12551263
dict(
12561264
zip(
12571265
[
1258-
str(f.relative_to(top_dir.parent))
1266+
str(f.relative_to(pyi_hashes_file.parent))
12591267
for f in file_paths
12601268
],
12611269
hashes,
@@ -1271,11 +1279,8 @@ def scan_all(
12711279
file_paths = list(map(Path, file_paths))
12721280
pyi_hashes_parent = file_paths[0].parent
12731281
while (
1274-
not any(
1275-
subfile.name == "pyi_hashes.json"
1276-
for subfile in pyi_hashes_parent.iterdir()
1277-
)
1278-
and pyi_hashes_parent.parent
1282+
pyi_hashes_parent.parent
1283+
and not (pyi_hashes_parent / "pyi_hashes.json").exists()
12791284
):
12801285
pyi_hashes_parent = pyi_hashes_parent.parent
12811286

@@ -1288,6 +1293,7 @@ def scan_all(
12881293
pyi_hashes[str(file_path.relative_to(pyi_hashes_parent))] = (
12891294
hashed_content
12901295
)
1296+
12911297
pyi_hashes_file.write_text(
12921298
json.dumps(pyi_hashes, indent=2, sort_keys=True) + "\n"
12931299
)

0 commit comments

Comments
 (0)