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

Commitaee7078

Browse files
committed
Test resolution into git.index.util using git.util
1 parentf39bbb5 commitaee7078

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

‎test/deprecation/test_attributes.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for dynamic and static attribute errors."""
22

33
importimportlib
4+
fromtypingimportType
45

56
importpytest
67

@@ -28,6 +29,23 @@ def test_util_alias_import_resolves() -> None:
2829
assertutilisgit.index.util
2930

3031

32+
deftest_util_alias_members_resolve()->None:
33+
"""git.index.util members can be accessed via git.util, and mypy recognizes it."""
34+
# TODO: When typing_extensions is made a test dependency, use assert_type for this.
35+
gu_tfs=git.util.TemporaryFileSwap
36+
fromgit.index.utilimportTemporaryFileSwap
37+
38+
defaccepts_tfs_type(t:Type[TemporaryFileSwap])->None:
39+
pass
40+
41+
defrejects_tfs_type(t:Type[git.Git])->None:
42+
pass
43+
44+
accepts_tfs_type(gu_tfs)
45+
rejects_tfs_type(gu_tfs)# type: ignore[arg-type]
46+
assertgu_tfsisTemporaryFileSwap
47+
48+
3149
deftest_util_alias_access_warns()->None:
3250
withpytest.deprecated_call()asctx:
3351
git.util
@@ -103,14 +121,3 @@ def test_private_module_alias_import_warns(self, name: str, fullname: str) -> No
103121
exec(f"from git import{name}")
104122

105123
assertctx[0].message.args[0].endswith(f"Use{fullname} instead.")
106-
107-
108-
reveal_type(git.util.git_working_dir)
109-
110-
# FIXME: Add one or more test cases that access something like git.util.git_working_dir
111-
# to verify that it is available, and also use assert_type on it to ensure mypy knows
112-
# that accesses to expressions of the form git.util.XYZ resolve to git.index.util.XYZ.
113-
#
114-
# It may be necessary for GitPython, in git/__init__.py, to import util from git.index
115-
# explicitly before (still) deleting the util global, in order for mypy to know what is
116-
# going on. Also check pyright.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp