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

Commita2df3a8

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 parent46a739d commita2df3a8

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

‎test/deprecation/test_attributes.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
deftest_cannot_get_undefined()->None:
1111
withpytest.raises(AttributeError):
12-
git.foo
12+
git.foo# type: ignore[attr-defined]
1313

1414

1515
deftest_cannot_import_undefined()->None:
1616
withpytest.raises(ImportError):
17-
fromgitimportfoo# noqa: F401
17+
fromgitimportfoo#type: ignore[attr-defined] #noqa: F401
1818

1919

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

5151

52+
deftest_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)

[8]ページ先頭

©2009-2025 Movatter.jp