GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Return type mismatch in repo.submodule_update() · Issue #2077 · gitpython-developers/GitPython

Return type mismatch in repo.submodule_update() #2077

New issue
Copy link
New issue
Copy link
Closed
#2078
Closed
Return type mismatch in repo.submodule_update()#2077
#2078
Copy link
Labels
acknowledgedhelp wanted

Description

@extrwi
extrwi
opened on Oct 17, 2025
Issue body actions

Hello 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).

GitPython/git/repo/base.py

Lines 523 to 531 in ba5c10d

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):

GitPython/git/objects/submodule/root.py

Lines 79 to 90 in ba5c10d

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":

Activity

  1. Byron
    added
    help wanted
    on Oct 21, 2025
  2. Byron commented on Oct 21, 2025

    @Byron
    Byron
    on Oct 21, 2025
    Member
    More actions

    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.

  3. Byron
    added
    acknowledged
    on Oct 21, 2025
  4. extrwi commented on Oct 21, 2025

    @extrwi
    extrwi
    on Oct 21, 2025
    Author
    More actions

    To me it looks like the return type might have been introduced as a copy and paste bug from the method right above it:

    GitPython/git/repo/base.py

    Line 512 in ba5c10d

    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. :-)

  5. extrwi
    added a commit that references this issue on Oct 21, 2025

    Use actual return type in annotation for method submodule_update

    This issue will close once commit 9dd0081 is merged into the 'main' branch.
    9dd0081
  6. extrwi commented on Oct 21, 2025

    @extrwi
    extrwi
    on Oct 21, 2025
    Author
    More actions

    Please merge my PR if you agree or just close it otherwise. ;-)

  7. Byron
    closed this as completedin #2078on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.