Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8a25df

Browse files
committed
Modify annotations to accommodate NULL_TREE
This finishes the main changes being done at this time to theannotations of diff-related methods that were started in0e1df29.As expected and noted in previous commits, having Diffable.diffpermit NULL_TREE entails a violation of the Liskov substitutionprinciple in the overridden method IndexFile.diff unless a similarchange were also made there, which could not be done correctlywithout modifying its behavior to actually accept NULL_TREE (itdoes not contain code to cover it, and raises ane exception if itis passed). I am unsure if that should ultimately be done, but evenif so, it seems to me to be beyond the scope of the typing changesbeing done here.This therefore applies a suppression there. The suppression isspecific to that one parameter. The long-standing comment atop theIndexFile.diff method, which reads as vague today, is replaced witha specific FIXME comment describing the situation where the methodrefers to the base-class docstring for documentation of itsparameters yet doesn't accept NULL_TREE (and notes the mypy error).In effect this is really restoring and fixing the suppression thatwas present before0e1df29 rather than adding a "new" one, but atthat time the base-class parameter type was much broader since itwas a union with object as one of its alternatives, so thesituation was much less clear.
1 parentc9952e1 commitb8a25df

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

‎git/diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _process_diff_args(
189189

190190
defdiff(
191191
self,
192-
other:Union[Literal[DiffConstants.INDEX],"Tree","Commit",str,None]=INDEX,
192+
other:Union[DiffConstants,"Tree","Commit",str,None]=INDEX,
193193
paths:Union[PathLike,List[PathLike],Tuple[PathLike, ...],None]=None,
194194
create_patch:bool=False,
195195
**kwargs:Any,

‎git/index/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,10 +1475,13 @@ def reset(
14751475

14761476
returnself
14771477

1478-
# @ default_index, breaks typing for some reason, copied into function
1478+
# FIXME: This is documented to accept the same parameters as Diffable.diff, but this
1479+
# does not handle NULL_TREE for `other`. (The suppressed mypy error is about this.)
14791480
defdiff(
14801481
self,
1481-
other:Union[Literal[git_diff.DiffConstants.INDEX],"Tree","Commit",str,None]=git_diff.INDEX,
1482+
other:Union[# type: ignore[override]
1483+
Literal[git_diff.DiffConstants.INDEX],"Tree","Commit",str,None
1484+
]=git_diff.INDEX,
14821485
paths:Union[PathLike,List[PathLike],Tuple[PathLike, ...],None]=None,
14831486
create_patch:bool=False,
14841487
**kwargs:Any,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp