pip install py-typewriter-cli
Typewriter supports Python 3.10 through 3.13.
Given a file like:
from typing import Any, Union
count: int = None
name: str = None
payload: Any = None
def greet(user_id: int = None, msg: Union[str, None] = None) -> Union[str, None]:
if user_id is None:
return None
return f"hello-{user_id}\n{msg}"
Preview the rewrite without changing the file:
typewriter run path/to/example.py --check
In --check mode Typewriter prints a unified diff and exits with:
0 when no changes are needed1 when rewrites would be applied2 when an error occursApply the same rewrite in place:
typewriter run path/to/example.py
Run recursively on Python files in a directory:
typewriter run examples
Transform an in-memory string instead of a file:
typewriter run --code "var: int = None\n"
PATH and --code are mutually exclusive, and literal \n sequences in --code input are interpreted as newlines.