Skip to content

Commit

Permalink
Move from isort to reorder-python-imports (#441)
Browse files Browse the repository at this point in the history
It’s [way faster](https://twitter.com/codewithanthony/status/1553034384206438401) and its one-import-per-line style prevents merge conflicts.
  • Loading branch information
adamchainz authored Nov 4, 2022
1 parent 636cd37 commit abadbda
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 33 deletions.
12 changes: 9 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ repos:
- id: blacken-docs
additional_dependencies:
- black==22.10.0
- repo: https://github.com/pycqa/isort
rev: 5.10.1
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: isort
- id: reorder-python-imports
args:
- --py37-plus
- --application-directories
- .:example:src
- --add-import
- 'from __future__ import annotations'
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ build-backend = "setuptools.build_meta"
[tool.black]
target-version = ['py37']

[tool.isort]
profile = "black"
add_imports = "from __future__ import annotations"

[tool.pytest.ini_options]
addopts = """\
--strict-config
Expand Down
13 changes: 7 additions & 6 deletions src/whitenoise/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
from wsgiref.util import FileWrapper

from .media_types import MediaTypes
from .responders import IsDirectoryError, MissingFileError, Redirect, StaticFile
from .string_utils import (
decode_if_byte_string,
decode_path_info,
ensure_leading_trailing_slash,
)
from .responders import IsDirectoryError
from .responders import MissingFileError
from .responders import Redirect
from .responders import StaticFile
from .string_utils import decode_if_byte_string
from .string_utils import decode_path_info
from .string_utils import ensure_leading_trailing_slash


class WhiteNoise:
Expand Down
3 changes: 2 additions & 1 deletion src/whitenoise/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from django.urls import get_script_prefix

from .base import WhiteNoise
from .string_utils import decode_if_byte_string, ensure_leading_trailing_slash
from .string_utils import decode_if_byte_string
from .string_utils import ensure_leading_trailing_slash

__all__ = ["WhiteNoiseMiddleware"]

Expand Down
3 changes: 2 additions & 1 deletion src/whitenoise/responders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import os
import re
import stat
from email.utils import formatdate, parsedate
from email.utils import formatdate
from email.utils import parsedate
from http import HTTPStatus
from io import BufferedIOBase
from time import mktime
Expand Down
6 changes: 2 additions & 4 deletions src/whitenoise/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import textwrap

from django.conf import settings
from django.contrib.staticfiles.storage import (
ManifestStaticFilesStorage,
StaticFilesStorage,
)
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
from django.contrib.staticfiles.storage import StaticFilesStorage

from .compress import Compressor

Expand Down
3 changes: 2 additions & 1 deletion tests/django_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import os.path

from .utils import TEST_FILE_PATH, AppServer
from .utils import AppServer
from .utils import TEST_FILE_PATH

ALLOWED_HOSTS = ["*"]

Expand Down
13 changes: 8 additions & 5 deletions tests/test_django_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
import shutil
import tempfile
from contextlib import closing
from urllib.parse import urljoin, urlparse
from urllib.parse import urljoin
from urllib.parse import urlparse

import pytest
from django.conf import settings
from django.contrib.staticfiles import finders, storage
from django.contrib.staticfiles import finders
from django.contrib.staticfiles import storage
from django.core.management import call_command
from django.core.wsgi import get_wsgi_application
from django.test.utils import override_settings
from django.utils.functional import empty

from whitenoise.middleware import WhiteNoiseFileResponse, WhiteNoiseMiddleware

from .utils import AppServer, Files
from .utils import AppServer
from .utils import Files
from whitenoise.middleware import WhiteNoiseFileResponse
from whitenoise.middleware import WhiteNoiseMiddleware


def reset_lazy_object(obj):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_runserver_nostatic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from django.core.management import get_commands, load_command_class
from django.core.management import get_commands
from django.core.management import load_command_class


def get_command_instance(name):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

import pytest
from django.conf import settings
from django.contrib.staticfiles.storage import HashedFilesMixin, staticfiles_storage
from django.contrib.staticfiles.storage import HashedFilesMixin
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.management import call_command
from django.test.utils import override_settings
from django.utils.functional import empty

from whitenoise.storage import CompressedManifestStaticFilesStorage, MissingFileError

from .utils import Files
from whitenoise.storage import CompressedManifestStaticFilesStorage
from whitenoise.storage import MissingFileError


@pytest.fixture()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_string_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from whitenoise.string_utils import decode_if_byte_string, ensure_leading_trailing_slash
from whitenoise.string_utils import decode_if_byte_string
from whitenoise.string_utils import ensure_leading_trailing_slash


class DecodeIfByteStringTests:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import pytest

from .utils import AppServer
from .utils import Files
from whitenoise import WhiteNoise
from whitenoise.responders import StaticFile

from .utils import AppServer, Files


@pytest.fixture(scope="module")
def files():
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import os
import threading
from wsgiref.simple_server import WSGIRequestHandler, make_server
from wsgiref.simple_server import make_server
from wsgiref.simple_server import WSGIRequestHandler
from wsgiref.util import shift_path_info

import requests
Expand Down

0 comments on commit abadbda

Please sign in to comment.