Skip to content

Commit b7f85a8

Browse files
codexByron
authored andcommitted
Remove possibly-unbound type suppressions
<!-- 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>
1 parent e0e5918 commit b7f85a8

5 files changed

Lines changed: 14 additions & 147 deletions

File tree

.basedpyright/baseline.json

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@
183183
"lineCount": 1
184184
}
185185
},
186-
{
187-
"code": "reportPossiblyUnboundVariable",
188-
"range": {
189-
"startColumn": 52,
190-
"endColumn": 59,
191-
"lineCount": 1
192-
}
193-
},
194186
{
195187
"code": "reportSelfClsParameterName",
196188
"range": {
@@ -207,14 +199,6 @@
207199
"lineCount": 1
208200
}
209201
},
210-
{
211-
"code": "reportPossiblyUnboundVariable",
212-
"range": {
213-
"startColumn": 41,
214-
"endColumn": 44,
215-
"lineCount": 1
216-
}
217-
},
218202
{
219203
"code": "reportArgumentType",
220204
"range": {
@@ -393,14 +377,6 @@
393377
"lineCount": 1
394378
}
395379
},
396-
{
397-
"code": "reportPossiblyUnboundVariable",
398-
"range": {
399-
"startColumn": 19,
400-
"endColumn": 25,
401-
"lineCount": 1
402-
}
403-
},
404380
{
405381
"code": "reportArgumentType",
406382
"range": {
@@ -467,30 +443,6 @@
467443
"lineCount": 1
468444
}
469445
},
470-
{
471-
"code": "reportPossiblyUnboundVariable",
472-
"range": {
473-
"startColumn": 23,
474-
"endColumn": 34,
475-
"lineCount": 1
476-
}
477-
},
478-
{
479-
"code": "reportPossiblyUnboundVariable",
480-
"range": {
481-
"startColumn": 32,
482-
"endColumn": 43,
483-
"lineCount": 1
484-
}
485-
},
486-
{
487-
"code": "reportPossiblyUnboundVariable",
488-
"range": {
489-
"startColumn": 23,
490-
"endColumn": 34,
491-
"lineCount": 1
492-
}
493-
},
494446
{
495447
"code": "reportArgumentType",
496448
"range": {
@@ -499,14 +451,6 @@
499451
"lineCount": 1
500452
}
501453
},
502-
{
503-
"code": "reportPossiblyUnboundVariable",
504-
"range": {
505-
"startColumn": 28,
506-
"endColumn": 32,
507-
"lineCount": 1
508-
}
509-
},
510454
{
511455
"code": "reportAttributeAccessIssue",
512456
"range": {
@@ -588,16 +532,6 @@
588532
}
589533
}
590534
],
591-
"./git/objects/submodule/root.py": [
592-
{
593-
"code": "reportPossiblyUnboundVariable",
594-
"range": {
595-
"startColumn": 18,
596-
"endColumn": 21,
597-
"lineCount": 1
598-
}
599-
}
600-
],
601535
"./git/objects/tag.py": [
602536
{
603537
"code": "reportIncompatibleVariableOverride",
@@ -701,14 +635,6 @@
701635
"lineCount": 1
702636
}
703637
},
704-
{
705-
"code": "reportPossiblyUnboundVariable",
706-
"range": {
707-
"startColumn": 41,
708-
"endColumn": 45,
709-
"lineCount": 1
710-
}
711-
},
712638
{
713639
"code": "reportArgumentType",
714640
"range": {
@@ -855,38 +781,6 @@
855781
"lineCount": 1
856782
}
857783
},
858-
{
859-
"code": "reportPossiblyUnboundVariable",
860-
"range": {
861-
"startColumn": 26,
862-
"endColumn": 34,
863-
"lineCount": 1
864-
}
865-
},
866-
{
867-
"code": "reportPossiblyUnboundVariable",
868-
"range": {
869-
"startColumn": 32,
870-
"endColumn": 40,
871-
"lineCount": 1
872-
}
873-
},
874-
{
875-
"code": "reportPossiblyUnboundVariable",
876-
"range": {
877-
"startColumn": 18,
878-
"endColumn": 26,
879-
"lineCount": 1
880-
}
881-
},
882-
{
883-
"code": "reportPossiblyUnboundVariable",
884-
"range": {
885-
"startColumn": 22,
886-
"endColumn": 30,
887-
"lineCount": 1
888-
}
889-
},
890784
{
891785
"code": "reportReturnType",
892786
"range": {
@@ -967,22 +861,6 @@
967861
"lineCount": 1
968862
}
969863
},
970-
{
971-
"code": "reportPossiblyUnboundVariable",
972-
"range": {
973-
"startColumn": 39,
974-
"endColumn": 47,
975-
"lineCount": 1
976-
}
977-
},
978-
{
979-
"code": "reportPossiblyUnboundVariable",
980-
"range": {
981-
"startColumn": 43,
982-
"endColumn": 51,
983-
"lineCount": 1
984-
}
985-
},
986864
{
987865
"code": "reportArgumentType",
988866
"range": {
@@ -998,22 +876,6 @@
998876
"endColumn": 38,
999877
"lineCount": 1
1000878
}
1001-
},
1002-
{
1003-
"code": "reportPossiblyUnboundVariable",
1004-
"range": {
1005-
"startColumn": 26,
1006-
"endColumn": 42,
1007-
"lineCount": 1
1008-
}
1009-
},
1010-
{
1011-
"code": "reportPossiblyUnboundVariable",
1012-
"range": {
1013-
"startColumn": 18,
1014-
"endColumn": 34,
1015-
"lineCount": 1
1016-
}
1017879
}
1018880
],
1019881
"./git/repo/fun.py": [

git/index/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,14 @@ def _entries_for_paths(
730730
) -> List[BaseIndexEntry]:
731731
entries_added: List[BaseIndexEntry] = []
732732
if path_rewriter:
733+
assert self.repo.working_tree_dir is not None, "Cannot rewrite paths without a working tree"
733734
for path in paths:
734735
if osp.isabs(path):
735736
abspath = path
736737
gitrelative_path = path[len(str(self.repo.working_tree_dir)) + 1 :]
737738
else:
738739
gitrelative_path = path
739-
if self.repo.working_tree_dir:
740-
abspath = osp.join(self.repo.working_tree_dir, gitrelative_path)
740+
abspath = osp.join(self.repo.working_tree_dir, gitrelative_path)
741741
# END obtain relative and absolute paths
742742

743743
blob = Blob(
@@ -1467,8 +1467,8 @@ def reset(
14671467
nie = new_inst.entries
14681468
for path in paths:
14691469
path = self._to_relative_path(path)
1470+
key = entry_key(path, 0)
14701471
try:
1471-
key = entry_key(path, 0)
14721472
self.entries[key] = nie[key]
14731473
except KeyError:
14741474
# If key is not in theirs, it mustn't be in ours.

git/objects/submodule/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ def fetch_remotes(module_repo: "Repo") -> None:
877877
#############################
878878
binsha = self.binsha
879879
hexsha = self.hexsha
880+
is_detached = False
880881
if mrepo is not None:
881882
# mrepo is only set if we are not in dry-run mode or if the module
882883
# existed.
@@ -1221,6 +1222,7 @@ def remove(
12211222
for remote in mod.remotes:
12221223
num_branches_with_new_commits = 0
12231224
rrefs = remote.refs
1225+
rref = None
12241226
for rref in rrefs:
12251227
num_branches_with_new_commits += len(mod.git.cherry(rref)) != 0
12261228
# END for each remote ref

git/refs/log.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def entry_at(cls, filepath: PathLike, index: int) -> "RefLogEntry":
269269
return RefLogEntry.from_line(fp.readlines()[index].strip())
270270
# Read until index is reached.
271271

272+
line = b""
272273
for i in range(index + 1):
273274
line = fp.readline()
274275
if not line:

git/repo/base.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -933,13 +933,13 @@ def is_valid_object(self, sha: str, object_type: Union[str, None] = None) -> boo
933933
return False
934934

935935
def _get_daemon_export(self) -> bool:
936-
if self.git_dir:
937-
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
936+
assert self.git_dir is not None, "Daemon export requires a Git directory"
937+
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
938938
return osp.exists(filename)
939939

940940
def _set_daemon_export(self, value: object) -> None:
941-
if self.git_dir:
942-
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
941+
assert self.git_dir is not None, "Daemon export requires a Git directory"
942+
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
943943
fileexists = osp.exists(filename)
944944
if value and not fileexists:
945945
touch(filename)
@@ -1279,6 +1279,7 @@ class InfoTD(TypedDict, total=False):
12791279

12801280
keepends = True
12811281
for line_bytes in data.splitlines(keepends):
1282+
line_str = ""
12821283
try:
12831284
line_str = line_bytes.rstrip().decode(defenc)
12841285
except UnicodeDecodeError:
@@ -1737,8 +1738,9 @@ def currently_rebasing_on(self) -> Commit | None:
17371738
17381739
``None`` if we are not currently rebasing.
17391740
"""
1740-
if self.git_dir:
1741-
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD")
1741+
if not self.git_dir:
1742+
return None
1743+
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD")
17421744
if not osp.isfile(rebase_head_file):
17431745
return None
17441746
with open(rebase_head_file, "rt") as f:

0 commit comments

Comments
 (0)