MCPcopy Create free account
hub / github.com/libgit2/pygit2 / diff_safeiter

Function diff_safeiter

test/utils.py:106–115  ·  view source on GitHub ↗

In rare cases, Diff.__iter__ may yield None (see diff_get_patch_byindex). To make mypy happy, use this iterator instead of Diff.__iter__ to ensure that all patches in a Diff are valid Patch objects, not None.

(diff: pygit2.Diff)

Source from the content-addressed store, hash-verified

104
105
106def diff_safeiter(diff: pygit2.Diff) -> Iterator[pygit2.Patch]:
107 """
108 In rare cases, Diff.__iter__ may yield None (see diff_get_patch_byindex).
109 To make mypy happy, use this iterator instead of Diff.__iter__ to ensure
110 that all patches in a Diff are valid Patch objects, not None.
111 """
112 for patch in diff:
113 if patch is None:
114 raise TypeError('patch is None')
115 yield patch
116
117
118class TemporaryRepository:

Callers 10

test_diff_empty_indexFunction · 0.85
test_workdir_to_treeFunction · 0.85
test_index_to_workdirFunction · 0.85
_testFunction · 0.85
get_context_for_linesFunction · 0.85
test_diff_empty_treeFunction · 0.85
test_diff_mergeFunction · 0.85
test_find_similarFunction · 0.85
test_deltasFunction · 0.85

Calls

no outgoing calls

Tested by 10

test_diff_empty_indexFunction · 0.68
test_workdir_to_treeFunction · 0.68
test_index_to_workdirFunction · 0.68
_testFunction · 0.68
get_context_for_linesFunction · 0.68
test_diff_empty_treeFunction · 0.68
test_diff_mergeFunction · 0.68
test_find_similarFunction · 0.68
test_deltasFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…