fixup 2202 by Byron · Pull Request #2206 · gitpython-developers/GitPython
Repository navigation
fixup 2202 - #2206
Merged
Byron merged 2 commits into main from fixup-2202 Aug 4, 2026
Merged
fixup 2202 #2206 Byron merged 2 commits into main from fixup-2202
Conversation
Byron commented Aug 4, 2026
Copy link Copy Markdown
Member
Fixup #2205 , which missed 2 commits when accidentally merged.
Handle uninitialized submodule and commit streams
e0e5918
<!-- agent --> RootModule.update could swallow setup failures with keep_going and then iterate sms before assignment. Start with an empty submodule list so the handled failure safely skips updates. Commit iteration could likewise read stream before assignment for processes without stdout or unsupported inputs. Raise explicit input errors instead. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>Copilot PR reviewer Copilot
AI
lite review requested due to automatic review settings August 4, 2026 10:57 Copilot started reviewing on behalf of Byron August 4, 2026 10:59
View session
Copilot PR reviewer Copilot
AI
reviewed Aug 4, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Pull request overview
Fixup follow-up to #2205 to address missed commits by hardening a few code paths against "possibly unbound" locals (including keep_going handling in recursive submodule updates) and adding regression tests for the corrected behaviors.
Changes:
- Add regression coverage for
RootModule.update(keep_going=True)whenlist_itemsfails, and forCommit._iter_from_process_or_streaminvalid inputs. - Initialize sentinel locals (
sms,line_str,line,is_detached,rref, etc.) to avoid unbound-variable crashes and satisfy static analysis. - Update basedpyright baseline to remove now-unnecessary
reportPossiblyUnboundVariablesuppressions.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| test/test_submodule.py | Adds regression test ensuring keep_going=True swallows a list_items failure without later unbound-local errors. |
| test/test_commit.py | Adds regression test for explicit exceptions when _iter_from_process_or_stream receives invalid sources. |
| git/repo/base.py | Tightens a few flows to avoid unbound locals (blame parsing, rebasing check) and changes daemon export helpers. |
| git/refs/log.py | Initializes line to avoid unbound-local reports in entry_at. |
| git/objects/submodule/root.py | Ensures sms is always initialized so keep_going paths don't trip unbound locals; imports IterableList at runtime. |
| git/objects/submodule/base.py | Initializes variables (is_detached, rref) to avoid unbound locals in update/remove flows. |
| git/objects/commit.py | Raises explicit ValueError/TypeError instead of hitting unbound-local errors for invalid process/stream inputs. |
| git/index/base.py | Avoids unbound local for key; asserts working tree presence when rewriting paths. |
| .basedpyright/baseline.json | Removes baseline entries for unbound-variable warnings that are now fixed. |
git/repo/base.py:943
- Avoid using
assertfor runtime validation in library code. Ifgit_diris unexpectedly missing, raise an explicit exception rather than relying on an assertion (which can be optimized away) and risking a laterTypeErrorfromosp.join.
def _set_daemon_export(self, value: object) -> None:
assert self.git_dir is not None, "Daemon export requires a Git directory"
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
fileexists = osp.exists(filename)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started .
Byron force-pushed the fixup-2202 branch fromb7f85a8 to
9f135c2
Compare
August 4, 2026 11:08 Copilot PR reviewer Copilot
AI
review requested due to automatic review settings August 4, 2026 11:08 Copilot started reviewing on behalf of Byron August 4, 2026 11:12
View session
Copilot PR reviewer Copilot
AI
reviewed Aug 4, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Copilot PR reviewer CopilotAI
review requested due to automatic review settings August 4, 2026 11:24 Byron force-pushed the fixup-2202 branch from
9f135c2 to
2e3b876
Compare
August 4, 2026 11:24
Remove possibly-unbound type suppressions
afe3ac9
<!-- agent --> Make established repository invariants explicit, initialize loop-only locals, and move assignments ahead of exception handling so basedpyright can follow the existing control flow. Regenerate the baseline to remove all 19 reportPossiblyUnboundVariable suppressions, including the two runtime fixes from the preceding commit. Validation: basedpyright --warnings; unbaselined possibly-unbound count 0; eight focused subsystem tests passed. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>Byron force-pushed the fixup-2202 branch from
2e3b876 to
afe3ac9
Compare
August 4, 2026 11:25 Copilot started reviewing on behalf of Byron August 4, 2026 11:25
View session
Copilot PR reviewer Copilot
AI
reviewed Aug 4, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (2)git/repo/base.py:947
_set_daemon_exporthas the same empty-stringgit_dirbehavior as_get_daemon_exportand may create/removegit-daemon-export-okin the current working directory ifgit_diris "". Treat falsy values consistently as "no git_dir".
def _set_daemon_export(self, value: object) -> None:
git_dir = getattr(self, "git_dir", None)
if git_dir is None:
return
filename = osp.join(git_dir, self.DAEMON_EXPORT_FILE)
fileexists = osp.exists(filename)
git/repo/base.py:940
_get_daemon_exportnow treats an empty stringgit_diras a valid directory and will probe forgit-daemon-export-okrelative to the current working directory. This differs from the previous truthiness check and fromcurrently_rebasing_on()(which treats falsygit_diras absent) and can lead to reading the wrong path whengit_diris "".
This issue also appears on line 942 of the same file.
git_dir = getattr(self, "git_dir", None)
if git_dir is None:
return False
filename = osp.join(git_dir, self.DAEMON_EXPORT_FILE)
return osp.exists(filename)
Byron
merged commit 974e38b
into
main
Aug 4, 2026
53 checks passed
Byron
deleted the
fixup-2202
branch
October 5, 2026 03:24
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment