This is not part of this PR, but I just noticed that there's an import inside the loop here. Of course it doesn't perform the import on every iteration, but it's unpleasant that it's here: please put this in the import block at the top of the file.