| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b8ce990 commit 61273aa
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,7 +88,7 @@ jobs: | |||
| 88 | 88 | ||
| 89 | 89 | - name: Check types with mypy | |
| 90 | 90 | run: | | |
| 91 | - mypy --python-version=${{ matrix.python-version }} -p git | ||
| 91 | + mypy --python-version=${{ matrix.python-version }} | ||
| 92 | 92 | env: | |
| 93 | 93 | MYPY_FORCE_COLOR: "1" | |
| 94 | 94 | TERM: "xterm-256color" # For color: https://github.com/python/mypy/issues/13817 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,7 @@ This includes the linting and autoformatting done by Ruff, as well as some other | |||
| 167 | 167 | To typecheck, run: | |
| 168 | 168 | ||
| 169 | 169 | ```sh | |
| 170 | - mypy -p git | ||
| 170 | + mypy | ||
| 171 | 171 | ``` | |
| 172 | 172 | ||
| 173 | 173 | #### CI (and tox) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ testpaths = "test" # Space separated list of paths from root e.g test tests doc | |||
| 21 | 21 | ||
| 22 | 22 | [tool.mypy] | |
| 23 | 23 | python_version = "3.8" | |
| 24 | + files = ["git/", "test/deprecation/"] | ||
| 24 | 25 | disallow_untyped_defs = true | |
| 25 | 26 | no_implicit_optional = true | |
| 26 | 27 | warn_redundant_casts = true | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,21 @@ | |||
| 25 | 25 | from git.repo import Repo | |
| 26 | 26 | from git.util import Iterable as _Iterable, IterableObj | |
| 27 | 27 | ||
| 28 | + # typing ----------------------------------------------------------------- | ||
| 29 | + | ||
| 30 | + from typing import Generator, TYPE_CHECKING | ||
| 31 | + | ||
| 32 | + if TYPE_CHECKING: | ||
| 33 | + from pathlib import Path | ||
| 34 | + | ||
| 35 | + from git.diff import Diff | ||
| 36 | + from git.objects.commit import Commit | ||
| 37 | + | ||
| 38 | + # ------------------------------------------------------------------------ | ||
| 39 | + | ||
| 28 | 40 | ||
| 29 | 41 | @contextlib.contextmanager | |
| 30 | - def _assert_no_deprecation_warning(): | ||
| 42 | + def _assert_no_deprecation_warning() -> Generator[None, None, None]: | ||
| 31 | 43 | """Context manager to assert that code does not issue any deprecation warnings.""" | |
| 32 | 44 | with warnings.catch_warnings(): | |
| 33 | 45 | # FIXME: Refine this to filter for deprecation warnings from GitPython. | |
@@ -36,7 +48,7 @@ def _assert_no_deprecation_warning(): | |||
| 36 | 48 | ||
| 37 | 49 | ||
| 38 | 50 | @pytest.fixture | |
| 39 | - def commit(tmp_path): | ||
| 51 | + def commit(tmp_path: "Path") -> Generator["Commit", None, None]: | ||
| 40 | 52 | """Fixture to supply a one-commit repo's commit, enough for deprecation tests.""" | |
| 41 | 53 | (tmp_path / "a.txt").write_text("hello\n", encoding="utf-8") | |
| 42 | 54 | repo = Repo.init(tmp_path) | |
@@ -46,75 +58,75 @@ def commit(tmp_path): | |||
| 46 | 58 | ||
| 47 | 59 | ||
| 48 | 60 | @pytest.fixture | |
| 49 | - def diff(commit): | ||
| 61 | + def diff(commit: "Commit") -> Generator["Diff", None, None]: | ||
| 50 | 62 | """Fixture to supply a single-file diff.""" | |
| 51 | 63 | (diff,) = commit.diff(NULL_TREE) # Exactly one file in the diff. | |
| 52 | 64 | yield diff | |
| 53 | 65 | ||
| 54 | 66 | ||
| 55 | - def test_diff_renamed_warns(diff): | ||
| 67 | + def test_diff_renamed_warns(diff: "Diff") -> None: | ||
| 56 | 68 | """The deprecated Diff.renamed property issues a deprecation warning.""" | |
| 57 | 69 | with pytest.deprecated_call(): | |
| 58 | 70 | diff.renamed | |
| 59 | 71 | ||
| 60 | 72 | ||
| 61 | - def test_diff_renamed_file_does_not_warn(diff): | ||
| 73 | + def test_diff_renamed_file_does_not_warn(diff: "Diff") -> None: | ||
| 62 | 74 | """The preferred Diff.renamed_file property issues no deprecation warning.""" | |
| 63 | 75 | with _assert_no_deprecation_warning(): | |
| 64 | 76 | diff.renamed_file | |
| 65 | 77 | ||
| 66 | 78 | ||
| 67 | - def test_commit_trailers_warns(commit): | ||
| 79 | + def test_commit_trailers_warns(commit: "Commit") -> None: | ||
| 68 | 80 | """The deprecated Commit.trailers property issues a deprecation warning.""" | |
| 69 | 81 | with pytest.deprecated_call(): | |
| 70 | 82 | commit.trailers | |
| 71 | 83 | ||
| 72 | 84 | ||
| 73 | - def test_commit_trailers_list_does_not_warn(commit): | ||
| 85 | + def test_commit_trailers_list_does_not_warn(commit: "Commit") -> None: | ||
| 74 | 86 | """The nondeprecated Commit.trailers_list property issues no deprecation warning.""" | |
| 75 | 87 | with _assert_no_deprecation_warning(): | |
| 76 | 88 | commit.trailers_list | |
| 77 | 89 | ||
| 78 | 90 | ||
| 79 | - def test_commit_trailers_dict_does_not_warn(commit): | ||
| 91 | + def test_commit_trailers_dict_does_not_warn(commit: "Commit") -> None: | ||
| 80 | 92 | """The nondeprecated Commit.trailers_dict property issues no deprecation warning.""" | |
| 81 | 93 | with _assert_no_deprecation_warning(): | |
| 82 | 94 | commit.trailers_dict | |
| 83 | 95 | ||
| 84 | 96 | ||
| 85 | - def test_traverse_list_traverse_in_base_class_warns(commit): | ||
| 97 | + def test_traverse_list_traverse_in_base_class_warns(commit: "Commit") -> None: | ||
| 86 | 98 | """Traversable.list_traverse's base implementation issues a deprecation warning.""" | |
| 87 | 99 | with pytest.deprecated_call(): | |
| 88 | 100 | Traversable.list_traverse(commit) | |
| 89 | 101 | ||
| 90 | 102 | ||
| 91 | - def test_traversable_list_traverse_override_does_not_warn(commit): | ||
| 103 | + def test_traversable_list_traverse_override_does_not_warn(commit: "Commit") -> None: | ||
| 92 | 104 | """Calling list_traverse on concrete subclasses is not deprecated, does not warn.""" | |
| 93 | 105 | with _assert_no_deprecation_warning(): | |
| 94 | 106 | commit.list_traverse() | |
| 95 | 107 | ||
| 96 | 108 | ||
| 97 | - def test_traverse_traverse_in_base_class_warns(commit): | ||
| 109 | + def test_traverse_traverse_in_base_class_warns(commit: "Commit") -> None: | ||
| 98 | 110 | """Traversable.traverse's base implementation issues a deprecation warning.""" | |
| 99 | 111 | with pytest.deprecated_call(): | |
| 100 | 112 | Traversable.traverse(commit) | |
| 101 | 113 | ||
| 102 | 114 | ||
| 103 | - def test_traverse_traverse_override_does_not_warn(commit): | ||
| 115 | + def test_traverse_traverse_override_does_not_warn(commit: "Commit") -> None: | ||
| 104 | 116 | """Calling traverse on concrete subclasses is not deprecated, does not warn.""" | |
| 105 | 117 | with _assert_no_deprecation_warning(): | |
| 106 | 118 | commit.traverse() | |
| 107 | 119 | ||
| 108 | 120 | ||
| 109 | - def test_iterable_inheriting_warns(): | ||
| 121 | + def test_iterable_inheriting_warns() -> None: | ||
| 110 | 122 | """Subclassing the deprecated git.util.Iterable issues a deprecation warning.""" | |
| 111 | 123 | with pytest.deprecated_call(): | |
| 112 | 124 | ||
| 113 | 125 | class Derived(_Iterable): | |
| 114 | 126 | pass | |
| 115 | 127 | ||
| 116 | 128 | ||
| 117 | - def test_iterable_obj_inheriting_does_not_warn(): | ||
| 129 | + def test_iterable_obj_inheriting_does_not_warn() -> None: | ||
| 118 | 130 | """Subclassing git.util.IterableObj is not deprecated, does not warn.""" | |
| 119 | 131 | with _assert_no_deprecation_warning(): | |
| 120 | 132 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ description = Typecheck with mypy | |||
| 30 | 30 | base_python = py{39,310,311,312,38,37} | |
| 31 | 31 | set_env = | |
| 32 | 32 | MYPY_FORCE_COLOR = 1 | |
| 33 | - commands = mypy -p git | ||
| 33 | + commands = mypy | ||
| 34 | 34 | ignore_outcome = true | |
| 35 | 35 | ||
| 36 | 36 | [testenv:html] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments