fix(git): correct merge()/rebase() return annotations to str | Literal[False]
Why
InfrahubRepository.merge() and rebase() were annotated -> bool, but they actually return the new commit-hash str on a successful merge and False on a no-op. The bool annotation is a lie that defeats static type-checking for callers — a legitimate isinstance(result, str) check looks dead, and code that assumes a plain boolean goes unchecked.
Goal: make the declared return type match the real contract so callers and the type checker are no longer misled.
Non-goals: no behavior change; not removing the module's mypy return-value suppression (a separate follow-up); not touching pull()'s annotation or the broader git-module SOLID refactor.
Tracked in Jira: INBOX-20 (from the "Infrahub Git refactoring 26Q2" SOLID analysis §4.2 / §9, High priority).
What changed
Behavioral changes: none — annotation-only.
merge()andrebase()return annotations:-> bool→-> str | Literal[False](commit-hash string on success,Falseon no-op).- Added
Literalto thetypingimport inbackend/infrahub/git/repository.py. - Added a
housekeepingchangelog fragment.
What stayed the same: no DB schema/migration changes, API contract unchanged, no auth changes, no new dependencies, no CI changes, no generated files. Runtime behavior and control flow are unchanged — the existing return False / return str(commit_after) statements are untouched.
The diff also includes a spec-kit design record under dev/specs/inbox-20-merge-return-type/ (spec / plan / critique / tasks / report) produced by the workflow that generated this change. It is documentation only.
How to review
- The entire behavioral change is 2 return annotations + 1 import in
backend/infrahub/git/repository.py. Everything else is docs/metadata. - Callers: the sole production
merge()caller (backend/infrahub/git/tasks.py) discards the result, andrebase()has no production callers — so no caller changes were required (mypy confirms).
How to test
uv run ruff check . --exclude python_sdk
uv run mypy backend/infrahub/git/repository.py backend/infrahub/git/tasks.py
uv run pytest backend/tests/component/git/test_git_repository.py
Expected: ruff clean, mypy reports no issues, git component tests pass. (A pre-existing, unrelated test_pull_branch_conflict failure can appear locally on some git versions — it lives in pull(), not merge/rebase, and is unaffected by this change.)
🤖 Generated with Claude Code
Summary by cubic
Corrected the return types of internal Git InfrahubRepository.merge() and rebase() to str | Literal[False] so callers and type checkers see the real contract. No behavior change.
- Refactors
- Updated annotations:
-> bool→-> str | Literal[False]. - Imported
Literalfromtyping.
- Updated annotations: