Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commitfc86a23
committed
Incompletely change git.index imports to test modattrs.py
This also checks if the regression tests in test_imports.py work.This replaces wildcard imports in git.index with explicit imports,and adds git.index.__all__. But this temporarily omits from it thepublic attributes of git.index that name its Python submodules andare thus are present as an indirect effect of importing names*from* them (since doing so also imports them).This partial change, until it is completed in the next commit,represents the kind of bug that modattrs.py seeks to safeguardagainst, and verifies that a diff between old and current output ofmodattrs.py clearly shows it. This diff is temporarily included asab.diff, which will be deleted in the next commit.The key problem that diff reveals is the changed value of the utilattribute of the top-level git module. Due to the way wildcardimports have been used within GitPython for its own modules,expressions like `git.util` (where `git` is the top-level gitmodule) and imports like `from git import util` are actuallyreferring to git.index.util, rather than the util Python submoduleof the git module (conceptually git.util), which can only beaccessed via `from git.util import ...` or in `sys.modules`.Although this is not an inherently good situation, in practice ithas to be maintained at least until the next major version, becausereasonable code that uses GitPython would be broken if thesituation were changed to be more intuitive.But the more intuitive behavior automatically happens if wildcardimports are replaced with explicit imports of the names they hadoriginally intended to import (in this case, in the top-level gitmodule, which has not yet been done but will be), or if __all__ isadded where helpful (in this case, in git.index, which this does).Adding the names explicitly is sufficient to restore the oldbehavior that is needed for backward compatibility, and has thefurther advantage that the unintuitive behavior will be explicitonce all wildcard imports are replaced and __all__ is added to eachmodule where it would be helpful. The modattrs.py script serves toensure incompatible changes are not made; this commit checks it.The tests in test_imports.py also cover this specific anticipatedincompatibility in git.util, but not all breakages that may arisewhen refactoring imports and that diff-ing modattrs.py output wouldhelp catch.1 parent5b2771d commitfc86a23
4 files changed
+45
-8
lines changedLines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + |
Lines changed: 11 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + |
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
| 9 | + | |
| 10 | + | |
9 | 11 |
| |
10 | 12 |
| |
11 | 13 |
| |
| |||
81 | 83 |
| |
82 | 84 |
| |
83 | 85 |
| |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 | 86 |
| |
88 | 87 |
| |
89 | 88 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
| 7 | + | |
6 | 8 |
| |
7 | 9 |
| |
8 | 10 |
| |
9 | 11 |
| |
10 | 12 |
| |
11 | 13 |
| |
12 |
| - | |
13 | 14 |
| |
14 | 15 |
| |
15 | 16 |
| |
| |||
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
26 |
| - | |
27 |
| - | |
28 | 27 |
| |
29 | 28 |
| |
30 | 29 |
| |
|
0 commit comments
Comments
(0)