Skip to content

Commit a2df3a8

Browse files
committed
Test static typing of private module aliases
This tests that mypy considers them not to be present. That mypy is configured with `warn_unused_ignores = true` is key, since that is what verifies that the type errors really do occur, based on the suppressions written for them.
1 parent 46a739d commit a2df3a8

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/deprecation/test_attributes.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
def test_cannot_get_undefined() -> None:
1111
with pytest.raises(AttributeError):
12-
git.foo
12+
git.foo # type: ignore[attr-defined]
1313

1414

1515
def test_cannot_import_undefined() -> None:
1616
with pytest.raises(ImportError):
17-
from git import foo # noqa: F401
17+
from git import foo # type: ignore[attr-defined] # noqa: F401
1818

1919

2020
def test_util_alias_access_resolves() -> None:
@@ -49,6 +49,21 @@ def test_util_alias_import_warns() -> None:
4949
assert "should not be relied on" in message
5050

5151

52+
def test_private_module_aliases() -> None:
53+
"""These exist dynamically but mypy will show them as absent (intentionally).
54+
55+
More detailed dynamic behavior is examined in the subsequent test cases.
56+
"""
57+
git.head # type: ignore[attr-defined]
58+
git.log # type: ignore[attr-defined]
59+
git.reference # type: ignore[attr-defined]
60+
git.symbolic # type: ignore[attr-defined]
61+
git.tag # type: ignore[attr-defined]
62+
git.base # type: ignore[attr-defined]
63+
git.fun # type: ignore[attr-defined]
64+
git.typ # type: ignore[attr-defined]
65+
66+
5267
_parametrize_by_private_alias = pytest.mark.parametrize(
5368
"name, fullname",
5469
[

0 commit comments

Comments
 (0)