This will allow the following to be used: isort_diff = StringIO() isort_output = StringIO() isort.file("x.py", show_diff=isort_diff, output=isort_output) Fixes #1583