Matchify
Converts eligible Python if/elif/else chains into match statements.
Tested on Linux
Use it
Linux x86_64
install matchify via uv tool
uv tool install matchify
Check that it works
matchify --helpThe output should contain “Convert if/elif/else chains to Python 3.10+ match statements”.
First thing to try
mkdir -p proj && cat > example_simple.py <<'PY'
x = 2
if x == 1:
print("one")
elif x == 2:
print("two")
else:
print("other")
PY
cat > example_format.py <<'PY'
# leading comment preserved?
x = 1 # inline comment
if x == 1: # branch comment
print("one") # action comment
elif x == 2:
print("two")
else:
print("other") # else comment
PY
cat > example_safe.py <<'PY'
x = 1
y = 2
if x == 1:
print("x is one")
elif y == 2:
print("y is two")
else:
print("other")
PY
cat proj/a.py <<'PY'
x = 1
if x == 1:
print("one")
elif x == 2:
print("two")
else:
print("other")
PY
cat proj/b.py <<'PY'
y = "a"
if y == "a":
print("a")
elif y == "b":
print("b")
else:
print("other")
PY
ls -Rcat > proj/a.py <<'PY'
x = 1
if x == 1:
print("one")
elif x == 2:
print("two")
else:
print("other")
PY
cat > proj/b.py <<'PY'
y = "a"
if y == "a":
print("a")
elif y == "b":
print("b")
else:
print("other")
PY
ls -R && cat example_simple.py && cat example_safe.pymatchify example_simple.py --checkRun matchify <file> --check to preview the changes for a Python file as a diff.
What it does
- Convert if/elif/else chains to match statementsTested
How to use it
- Run
matchify <file> --checkto preview the conversion as a diff. - Look for the
+matchlines to see the new match statement.
- Run
- Keep comments and formatting when convertingTested
How to use it
- Run
matchify <file> --checkon a file with comments. - Check the diff to see that your comments are kept.
- Run
- Process large codebases in parallelNot shown working
- Convert only when behavior stays the sameNot tested
How far pickfit got
Linux x86_64
- Installs
- Starts
- 2 of 4 features work
- Works offline
Good for
- convert if elif else chains to match statements
- preview conversions as diffs without writing
How pickfit tested it
Each run starts from a clean machine and follows the steps above. How pickfit verifies
Linux x86_64
Its main function works
- Replayed from scratch
- Works offline
- Checked on 1 Nov 2026
- Version 0.3.0
Differences the test machine hit
- README: --check only reports them as diffs
In the test: --check exits 1 when conversions are available (per README), so exit 1 is success for conversion checks