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

Commitb51b080

Browse files
committed
Explain the approach in test.deprecation to static checking
And why this increases the importance of the warn_unused_ignoredmypy configuration option.
1 parentbdabb21 commitb51b080

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

‎pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ files = ["git/", "test/deprecation/"]
2525
disallow_untyped_defs =true
2626
no_implicit_optional =true
2727
warn_redundant_casts =true
28-
warn_unused_ignores =true
28+
warn_unused_ignores =true# Useful in general, but especially in test/deprecation.
2929
warn_unreachable =true
3030
implicit_reexport =true
3131
# strict = true

‎test/deprecation/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
# This module is part of GitPython and is released under the
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
3+
4+
"""Tests of deprecation warnings and possible related attribute bugs.
5+
6+
Most deprecation warnings are "basic" in the sense that there is no special complexity
7+
to consider, in introducing them. However, to issue deprecation warnings on mere
8+
attribute access can involve adding new dynamic behavior. This can lead to subtle bugs
9+
or less useful dynamic metadata. It can also weaken static typing, as happens if a type
10+
checker sees a method like ``__getattr__`` in a module or class whose attributes it did
11+
not already judge to be dynamic. This test.deprecation submodule covers all three cases:
12+
the basic cases, subtle dynamic behavior, and subtle static type checking issues.
13+
14+
Static type checking is "tested" by a combination of code that should not be treated as
15+
a type error but would be in the presence of particular bugs, and code that *should* be
16+
treated as a type error and is accordingly marked ``# type: ignore[REASON]`` (for
17+
specific ``REASON``. The latter will only produce mypy errors when the expectation is
18+
not met if it is configured with ``warn_unused_ignores = true``.
19+
"""

‎test/deprecation/test_cmd_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This module is part of GitPython and is released under the
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

4-
"""Tests forstatic anddynamic characteristics of Git class and instance attributes.
4+
"""Tests fordynamic andstatic characteristics of Git class and instance attributes.
55
66
Currently this all relates to the deprecated :attr:`Git.USE_SHELL` class attribute,
77
which can also be accessed through instances. Some tests directly verify its behavior,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp