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)
| 104 | |
| 105 | |
| 106 | def 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 | |
| 118 | class TemporaryRepository: |
no outgoing calls
searching dependent graphs…