GeezerVison is showing github.com — Return type mismatch in repo.submodule_update() · Issue #2077 · gitpython-developers/GitPython
Return type mismatch in repo.submodule_update() #2077DescriptionHello everyone! repo.submodule_update is annotated to return an Iterator[Submodule] (and I hoped it might return an iterator of modified modules or something similar).
|
def submodule_update(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]: |
|
"""Update the submodules, keeping the repository consistent as it will |
|
take the previous state into consideration. |
|
|
|
:note: |
|
For more information, please see the documentation of |
|
:meth:`RootModule.update <git.objects.submodule.root.RootModule.update>`. |
|
""" |
|
return RootModule(self).update(*args, **kwargs) |
However, RootModule.update just returns self (type RootModule):
|
def update( # type: ignore[override] |
|
self, |
|
previous_commit: Union[Commit_ish, str, None] = None, |
|
recursive: bool = True, |
|
force_remove: bool = False, |
|
init: bool = True, |
|
to_latest_revision: bool = False, |
|
progress: Union[None, "RootUpdateProgress"] = None, |
|
dry_run: bool = False, |
|
force_reset: bool = False, |
|
keep_going: bool = False, |
|
) -> "RootModule": |
ActivityByron commented on Oct 21, 2025 Thanks for reporting.
Unfortunately the implementation uses a strange and unnecessary OOM abstraction which makes everything harder to understand. This is probably also the reason the type is off here.
The best fix would certainly be if there was no RootSubmodule at all. But maybe there is also a simple type-based fix that already helps. extrwi commented on Oct 21, 2025 To me it looks like the return type might have been introduced as a copy and paste bug from the method right above it:
|
def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]: |
The most important problem with the type mismatch is that the value returned by update is not iterable at all. :-) added a commit that references this issue on Oct 21, 2025This issue will close once commit 9dd0081 is merged into the 'main' branch.9dd0081 extrwi commented on Oct 21, 2025 Please merge my PR if you agree or just close it otherwise. ;-)
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|