import-resolve
Auto-resolve Git merge conflicts in Python
importblocks. Deterministic, zero dependencies, zero config, no AI.
Before / after (from a real git merge)
Two branches each added one import. Git conflicted. import-resolve kept both.
Before (docs/examples/app.before.py):
import json
<<<<<<< HEAD
import os
=======
import math
>>>>>>> feature-a
print(json.dumps({'ok': True}))
Terminal:
$ import-resolve
[ok] app.py: resolved 1 import conflict
After (docs/examples/app.after.py):
import json
import math
import os
print(json.dumps({'ok': True}))
Both branches survive. Duplicates removed. Sorted. Conflict markers gone.
Install
From PyPI (once published):
pip install import-resolve-cli
From this GitHub repo (works today):
pip install git+https://github.com/ikrame-ih/import-resolve.git
That installs the import-resolve command. The PyPI package is named
import-resolve-cli because import-resolve
is already taken by an unrelated project from 2017.
Requires Python 3.9+. No runtime dependencies — a few hundred lines of standard library.
Usage
import-resolve # fix every conflicted .py file Git reports
import-resolve app.py utils.py # fix specific files
import-resolve --dry-run # show the diff, write nothing
import-resolve --check # exit 1 if any conflict markers are found (CI)
Exit codes: 0 all import conflicts resolved (or none existed), 1
conflicts remain for a human, 2 usage error.
Optional: fully automatic mode
Register a merge driver in the current repository only:
import-resolve --install-hook # .git/config + .git/info/attributes
import-resolve --uninstall-hook
After that, git merge / rebase / cherry-pick clear pure-import conflicts
quietly and only stop for conflicts that need a person. Nothing goes into
global Git config or into the versioned tree — teammates opt in themselves.
Safety model
If a conflict block contains one line that is not an import, a comment, or a blank line, the block is left untouched and you get a reason:
[skip] app.py:14: left untouched for safety (non-import line: 'value = compute()')
Also refused (on purpose):
- multiline imports (
from typing import (…)) - backslash line continuations
- indented imports (inside functions /
try)
Extra guards:
- merged block must pass
ast.parseor nothing is written - atomic write (temp file +
os.replace) - LF/CRLF and UTF-8 BOM preserved
- binary / non-UTF-8 / files over 5 MB refused
- no network, no AI, no telemetry — code never leaves your machine
Logic conflicts further down the same file stay exactly as Git left them.
What it does NOT do
| Out of scope | Why |
|---|---|
| Business-logic conflicts | That needs a human |
| Multiline import blocks | Too easy to corrupt; skipped with a warning |
| Full isort/ruff style | Run your formatter after; we sort simply |
| JS/TS imports | Possible v2 |
| Config files | Zero config is the point |
Why this exists (short case study)
Import conflicts are mechanical: two people added different import lines to
the same header. Current options are weak for that case:
- GitHub's CLI guide — open the editor and delete markers by hand
- StackOverflow
--ours/--theirs— destructive; one side's imports vanish - isort / ruff / Black — fail with a syntax error while markers are present
- AI resolvers — need API keys, send code off-machine, non-deterministic
- Mergiraf — excellent structural merge driver; if you want that full pipeline and can install a Rust binary + Git config, use it
import-resolve is the remaining gap: the file is already broken in front of
you, and you want one local command, right now, with nothing configured.
Roadmap
- JS/TS import blocks (v2, if there's demand)
-
--stagetogit addfully resolved files
Development
pip install -e ".[dev]"
pytest
mypy
ruff check .
License
MIT © Ikrame Ih
Metadata
Release files for import-resolve-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| import_resolve_cli-0.1.0.tar.gz | 17.1 kB | Without provenance | Details for import_resolve_cli-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| import_resolve_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for import_resolve_cli-0.1.0-py3-none-any.whl |
Total release size: 32.9 kB
Release files / import_resolve_cli-0.1.0.tar.gz
| Download URL | import_resolve_cli-0.1.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd18af7e8d176c0c8fa913ddfd9bea89452809c6eaf766408047e2ac90db9d1a
|
|
BLAKE2b-256 checksum How to use checksums |
9eab0364249550bd3a1522aa90ddad1718a8ae85599366084a4fc79a830b0f2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / import_resolve_cli-0.1.0-py3-none-any.whl
| Download URL | import_resolve_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5c573201dce79860ce90454c18d214787d0ecd548a3c423e9654ba33e12dd36
|
|
BLAKE2b-256 checksum How to use checksums |
b6d771d51b858dba1ec58327f4760af2d44799932c105f457be1c3e198853df8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for import-resolve-cli 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.