Skip to content

fix(make_pyi): also diff staged changes when scanning for pyi updates#6544

Merged
masenf merged 2 commits into
reflex-dev:mainfrom
FarhanAliRaza:pyi-fix
May 20, 2026
Merged

fix(make_pyi): also diff staged changes when scanning for pyi updates#6544
masenf merged 2 commits into
reflex-dev:mainfrom
FarhanAliRaza:pyi-fix

Conversation

@FarhanAliRaza
Copy link
Copy Markdown
Contributor

pre-commit aligns the worktree with the index, so staged-but-uncommitted edits don't appear in the unstaged diff and their .pyi files were never regenerated.

Why?

For me VS Code commit does not work because it does not detect the uv venv beause i dont activate it.

To commit code i have to stage the files and then run the git commit command, which causes the pre-commit hook to miss files.

Then i come back and regenerate the hashes from scratch and push again.

pre-commit aligns the worktree with the index, so staged-but-uncommitted
edits don't appear in the unstaged diff and their .pyi files were never
regenerated.
@FarhanAliRaza FarhanAliRaza requested a review from a team as a code owner May 20, 2026 19:55
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR extends _get_changed_files() in scripts/make_pyi.py to also consult git diff --cached, so that files staged for commit but not yet written to the worktree are included when pre-commit runs and aligns the tree with the index.

  • Adds a third _git_changed_files([\"--cached\"]) call alongside the existing commit-range and unstaged-diff calls, with an explanatory comment.
  • The fix correctly addresses the main scenario (staged component .py files missing .pyi regeneration), but the follow-on make_pyi.py-change check on line 89 still only reads the unstaged diff \u2014 which is empty when the generator script itself is staged \u2014 potentially skipping a full regeneration in that edge case.

Confidence Score: 3/5

Safe for the common case, but the generator-file self-change detection on line 89 can silently produce the wrong outcome when make_pyi.py is itself staged.

The core fix works correctly for staged component files. However, the make_pyi.py diff-comparison path (line 89) still calls git diff (unstaged only), which returns empty when the file is staged. If GENERATOR_DIFF_FILE also holds an empty string from a prior run, the check falsely concludes the generator has not changed and skips the full regeneration that should have been triggered.

scripts/make_pyi.py — specifically the diff-comparison logic for the generator file itself around line 89.

Important Files Changed

Filename Overview
scripts/make_pyi.py Adds git diff --cached to pick up staged files; fixes the core pre-commit scenario, but the subsequent make_pyi.py-diff check still only reads the unstaged diff, which is empty when the generator script itself is staged.

Comments Outside Diff (1)

  1. scripts/make_pyi.py, line 89 (link)

    P1 Staged make_pyi.py produces an empty diff here

    When make_pyi.py itself is staged (the exact scenario this PR targets), git diff --no-color make_pyi.py (unstaged) returns nothing because pre-commit has aligned the worktree with the index. So diff becomes "". If GENERATOR_DIFF_FILE also holds "" from a prior run where the generator had no unstaged changes, the two strings compare equal, the code logs "has not changed", and only the staged source files get .pyi updates — not a full regeneration. The fix should also consult git diff --cached for this file: _git_diff([GENERATOR_FILE.as_posix()]) or _git_diff(["--cached", GENERATOR_FILE.as_posix()]).

Reviews (1): Last reviewed commit: "fix(make_pyi): also diff staged changes ..." | Re-trigger Greptile

Comment thread scripts/make_pyi.py
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 20, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing FarhanAliRaza:pyi-fix (3945169) with main (9bada16)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (6288dfe) during the generation of this report, so 9bada16 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@masenf masenf merged commit ad043c9 into reflex-dev:main May 20, 2026
70 checks passed
@FarhanAliRaza FarhanAliRaza deleted the pyi-fix branch May 21, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants