From c842362b31d602f46031d604ad8a0525b1d3258f Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Sun, 6 Dec 2020 19:23:10 +0200 Subject: [PATCH] Set up isort in CI --- .github/workflows/build.yml | 1 + imgdiff.py | 16 +++++++++++----- setup.py | 3 ++- tests.py | 9 +++++---- tox.ini | 5 +++++ 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e62a58..2f4d07e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,7 @@ jobs: matrix: toxenv: - flake8 + - isort steps: - name: Git clone diff --git a/imgdiff.py b/imgdiff.py index df77fa4..da40fd8 100755 --- a/imgdiff.py +++ b/imgdiff.py @@ -4,19 +4,25 @@ Released under the MIT licence. """ -import os -import sys + import optparse +import os import shutil import subprocess +import sys import tempfile import time -# There are two ways PIL is packaged +# There are two ways PIL used to be packaged try: - from PIL import Image, ImageDraw, ImageChops, ImageFilter + from PIL import Image, ImageChops, ImageDraw, ImageFilter except ImportError: - import Image, ImageDraw, ImageChops, ImageFilter + # This is the old way, and probably nobody uses it anymore. (PIL's dead + # anyway, Pillow supplanted it.) + import Image + import ImageChops + import ImageDraw + import ImageFilter __version__ = '1.7.2.dev0' diff --git a/setup.py b/setup.py index 08df39b..57b2c95 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/python -import os, re +import os +import re from setuptools import setup diff --git a/tests.py b/tests.py index 42d3da4..dd54171 100644 --- a/tests.py +++ b/tests.py @@ -4,15 +4,16 @@ import sys import tempfile import unittest -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO import mock import imgdiff +try: + from cStringIO import StringIO +except ImportError: + from io import StringIO + @mock.patch('sys.stderr', StringIO()) class TestMain(unittest.TestCase): diff --git a/tox.ini b/tox.ini index 3c84621..1552b0d 100644 --- a/tox.ini +++ b/tox.ini @@ -23,3 +23,8 @@ commands = deps = flake8 skip_install = true commands = flake8 imgdiff.py setup.py tests.py + +[testenv:isort] +deps = isort +skip_install = true +commands = isort {posargs: -c --diff imgdiff.py setup.py tests.py}