Skip to content

Git.fetch / Git.pull: depth typed as str, inconsistent with Git.clone (int) #534

Description

@tony

Summary

depth is typed inconsistently across the git command wrappers. Git.clone and Git.submodule.update take depth: int | None and render str(depth), but Git.fetch and Git.pull take depth: str | None and pass the value straight into the argv:

# clone (L369): str() applied
local_flags.extend(["--depth", str(depth)])

# fetch (L505) / pull (L996): raw value, requires a str
local_flags.extend(["--depth", depth])

So git.clone(depth=2) works while git.fetch(depth=2) is a type error (and would place a non-str in the argv list at runtime). Callers must remember to pass "2" to fetch/pull but 2 to clone.

Suggested fix

Type depth: int | None on Git.fetch and Git.pull to match Git.clone, rendering str(depth) at the call site. --deepen could be reviewed for the same treatment.

Relevant to #532, where update_repo() would forward a numeric depth into fetch.

Acceptance

  • Git.fetch(depth=2) and Git.pull(depth=2) accept an int and emit --depth 2.
  • mypy passes with the unified int signature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions