Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commit70ef69a
committed
Include TagObject in git.types.Tree_ish
The Tree_ish union omitted TagObject, whose instances are onlysometimes tree-ish, and unlike Commit_ish before#1859, it is notinherently a bug to define Tree_ish this way.However, this Tree_ish type actually has only one use in GitPython(which was also the case before the changes in#1859): as, itself,an alternative in the union used to annotate the rev parameter ofthe Repo.tree method (whose other alternatives are str and None).A TagObject may be passed, and if it points to a tree or committhen that will be resolved. Just to avoid a mypy error, code doingthat would (before this change) have to convert it to str first.That annotation should be improved, and the best way to do it is tokeep it written the same way but change the definition of Tree_ishin git.types to include TagObject. The reason is that doing soalleviates a major unintuitive aspect of the relationship betweenthe Commit_ish and Tree_ish types: Commit_ish was broader thaneverything commit-ish, while Tree_ish was narrower than everythingtree-ish.I had not considered making this change in#1859 because I didn'twant to modify Tree_ish unnecessarily, and its definition was notinherently a bug. However, the change to Commit_ish is sufficientlylarge (though it only affects static typing) that a change toTree_ish to make them coherent and intuitive may be justified.This commit changes Tree_ish so that, in addition to its Commit andTree alternatives, it also includes TagObject. This also updatesand simplifies its docstring accordingly, bringing it in line withthat of Commit_ish which is already defined with the same kind ofbreadth, and further revises both docstrings to more explicitlyclarify when tags are tree-ish or commit-ish and when they are not.This does not change the separate nonpublic Treeish type defined ingit.index.base (and named with no underscore), which omitsTagObject but includes bytes and str, and which is used to annotateparameters of the IndexFile.from_tree and IndexFile.merge_treemethods. Changes there may be valuable, but the goal here is justto build narrowly on#1859 to address a shortcoming of therevisions to git.types.1 parentbcea9a8 commit70ef69a
1 file changed
+10
-15
lines changedLines changed: 10 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
73 | 73 |
| |
74 | 74 |
| |
75 | 75 |
| |
76 |
| - | |
77 |
| - | |
| 76 | + | |
| 77 | + | |
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
82 |
| - | |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
89 | 88 |
| |
90 | 89 |
| |
91 | 90 |
| |
| |||
102 | 101 |
| |
103 | 102 |
| |
104 | 103 |
| |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
| 104 | + | |
| 105 | + | |
111 | 106 |
| |
112 | 107 |
| |
113 | 108 |
| |
|
0 commit comments
Comments
(0)