From 91e204f8a22df962a3a4a3e0316d14e8b613a110 Mon Sep 17 00:00:00 2001 From: Milan Stute Date: Wed, 2 Dec 2020 14:29:02 +0100 Subject: [PATCH] Add isort to CI pipeline --- .github/workflows/testpackage.yml | 4 ++++ Makefile | 6 +++++- opendrop/client.py | 4 ++-- opendrop/server.py | 4 ++-- opendrop/util.py | 10 +++++----- requirements-dev.txt | 1 + setup.cfg | 11 ++++++++++- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/testpackage.yml b/.github/workflows/testpackage.yml index a8ab31d..4d9692e 100644 --- a/.github/workflows/testpackage.yml +++ b/.github/workflows/testpackage.yml @@ -22,6 +22,10 @@ jobs: - name: Install package run: | pip install -e . + - name: Check format with isort + run: | + pip install isort + isort -c opendrop/**.py - name: Check format with black run: | pip install black diff --git a/Makefile b/Makefile index 9bee981..48686e0 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ VENV=venv PYTHON=$(VENV)/bin/python3 -ci: checkformat lint test +ci: isort checkformat lint test $(VENV): $(VENV)/bin/activate @@ -23,8 +23,12 @@ checkformat: $(VENV) lint: $(VENV) $(PYTHON) -m flake8 . --count --show-source --statistics --exclude $(VENV) +isort: $(VENV) + $(PYTHON) -m isort -c opendrop/**.py + test: $(VENV) $(PYTHON) -m pytest autoformat: $(VENV) + $(PYTHON) -m isort opendrop/**.py $(PYTHON) -m black . --exclude $(VENV) diff --git a/opendrop/client.py b/opendrop/client.py index 1e616ef..0485761 100644 --- a/opendrop/client.py +++ b/opendrop/client.py @@ -28,9 +28,9 @@ from http.client import HTTPSConnection import fleep import libarchive +from zeroconf import IPVersion, ServiceBrowser, Zeroconf -from .util import AirDropUtil, AbsArchiveWrite -from zeroconf import ServiceBrowser, Zeroconf, IPVersion +from .util import AbsArchiveWrite, AirDropUtil logger = logging.getLogger(__name__) diff --git a/opendrop/server.py b/opendrop/server.py index 6c7ecff..7c03821 100644 --- a/opendrop/server.py +++ b/opendrop/server.py @@ -23,14 +23,14 @@ import platform import plistlib import socket import time -from http.server import HTTPServer, BaseHTTPRequestHandler +from http.server import BaseHTTPRequestHandler, HTTPServer import libarchive import libarchive.extract import libarchive.read +from zeroconf import IPVersion, ServiceInfo, Zeroconf from .util import AirDropUtil -from zeroconf import Zeroconf, ServiceInfo, IPVersion logger = logging.getLogger(__name__) diff --git a/opendrop/util.py b/opendrop/util.py index 6b9b75e..c7f9807 100644 --- a/opendrop/util.py +++ b/opendrop/util.py @@ -26,20 +26,20 @@ import os import plistlib import ifaddr -from PIL import Image, ExifTags from libarchive import ffi -from libarchive.entry import new_archive_entry, ArchiveEntry +from libarchive.entry import ArchiveEntry, new_archive_entry from libarchive.ffi import ( ARCHIVE_EOF, - entry_sourcepath, entry_clear, - read_next_header2, + entry_sourcepath, read_disk_descend, - write_header, + read_next_header2, write_data, write_finish_entry, + write_header, ) from libarchive.write import ArchiveWrite, new_archive_read_disk +from PIL import ExifTags, Image class AirDropUtil: diff --git a/requirements-dev.txt b/requirements-dev.txt index 39b210a..9f01c1a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,5 @@ black flake8 flake8-bugbear +isort pytest diff --git a/setup.cfg b/setup.cfg index c7992b2..78a4a79 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,4 +2,13 @@ extend-ignore = E203, E501 max-line-length = 80 max-complexity = 18 -select = B9 \ No newline at end of file +select = B9 + +[isort] +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +ensure_newline_before_comments = True +line_length = 88 +