isort --check-only will complain about import whitespace if the file is missing a closing newline.
def test_strict_whitespace_no_newline(capsys):
test_input = ('import os\n'
'\n'
'from django.conf import settings\n'
'\n'
'print(1)')
SortImports(file_contents=test_input, check=True)
out, err = capsys.readouterr()
assert out == '' # valid imports, but AssertionError
isort --check-onlywill complain about import whitespace if the file is missing a closing newline.