Skip to content

Commit

Permalink
Sort imports with isort
Browse files Browse the repository at this point in the history
  • Loading branch information
David Grochowski authored and ThePumpingLemma committed Nov 19, 2020
1 parent 2c9e631 commit b43890f
Show file tree
Hide file tree
Showing 28 changed files with 71 additions and 53 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Unreleased
- Add Python 3.9 support (gh-745)
- Support ``ignore_conflicts`` in ``bulk_create_with_history`` (gh-733)
- Use ``asgiref`` when available instead of thread locals (gh-747)
- Sort imports with isort (gh-751)

2.12.0 (2020-10-14)
-------------------
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ release: dist
twine upload dist/*

format:
black --target-version=py35 docs simple_history runtests.py setup.py
isort docs simple_history runtests.py setup.py
black docs simple_history runtests.py setup.py
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import os
import sys

from pkg_resources import get_distribution

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[tool.black]
line-length = 88
target-version = ["py35"]

[tool.isort]
profile = "black"
py_version = "35"

[tool.coverage.run]
parallel = true
branch = true
Expand Down
1 change: 1 addition & 0 deletions requirements/lint.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
black==20.8.b1
flake8==3.8.4
isort==5.6.4
2 changes: 1 addition & 1 deletion simple_history/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pkg_resources import get_distribution, DistributionNotFound
from pkg_resources import DistributionNotFound, get_distribution

try:
__version__ = get_distribution(__name__).version
Expand Down
9 changes: 3 additions & 6 deletions simple_history/admin.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
from django import http
from django.apps import apps as django_apps
from django.conf import settings

from django.urls import re_path
from django.contrib import admin
from django.contrib.admin import helpers
from django.contrib.admin.utils import unquote
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.urls import re_path, reverse
from django.utils.encoding import force_str
from django.utils.html import mark_safe
from django.utils.text import capfirst
from django.utils.translation import gettext as _

from . import utils

from django.utils.encoding import force_str
from django.utils.translation import gettext as _

USER_NATURAL_KEY = tuple(key.lower() for key in settings.AUTH_USER_MODEL.split(".", 1))

SIMPLE_HISTORY_EDIT = getattr(settings, "SIMPLE_HISTORY_EDIT", False)
Expand Down
4 changes: 2 additions & 2 deletions simple_history/management/commands/clean_duplicate_history.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.utils import timezone
from django.db import transaction
from django.utils import timezone

from . import populate_history
from ... import models, utils
from ...exceptions import NotHistoricalModelError
from . import populate_history


class Command(populate_history.Command):
Expand Down
4 changes: 2 additions & 2 deletions simple_history/management/commands/clean_old_history.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.utils import timezone
from django.db import transaction
from django.utils import timezone

from . import populate_history
from ... import models, utils
from ...exceptions import NotHistoricalModelError
from . import populate_history


class Command(populate_history.Command):
Expand Down
9 changes: 5 additions & 4 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
from django.db.models.fields.proxy import OrderWrt
from django.forms.models import model_to_dict
from django.urls import reverse
from django.utils.text import format_lazy
from django.utils import timezone
from django.utils.encoding import smart_str
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _

from simple_history import utils

from . import exceptions
from .manager import HistoryDescriptor
from .signals import post_create_historical_record, pre_create_historical_record
from .utils import get_change_reason_from_object

from django.utils.translation import gettext_lazy as _
from django.utils.encoding import smart_str

try:
from asgiref.local import Local as LocalContext
except ImportError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-01-18 21:58
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Generated by Django 2.1 on 2018-10-19 21:53

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

import simple_history.models

from .. import models as my_models


Expand Down
1 change: 1 addition & 0 deletions simple_history/registry_tests/migration_test_app/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models

from simple_history.models import HistoricalRecords


Expand Down
7 changes: 4 additions & 3 deletions simple_history/registry_tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
from io import StringIO
import unittest
import uuid
from datetime import datetime, timedelta
from io import StringIO

from django.apps import apps
from django.contrib.auth import get_user_model
from django.core import management
from django.test import TestCase, override_settings

from simple_history import exceptions, register

from ..tests.models import (
Choice,
InheritTracking1,
InheritTracking2,
InheritTracking3,
InheritTracking4,
ModelWithCustomAttrForeignKey,
ModelWithHistoryInDifferentApp,
Poll,
Restaurant,
TrackedAbstractBaseA,
Expand All @@ -25,8 +28,6 @@
UserAccessorOverride,
UUIDRegisterModel,
Voter,
ModelWithCustomAttrForeignKey,
ModelWithHistoryInDifferentApp,
)

get_model = apps.get_model
Expand Down
1 change: 0 additions & 1 deletion simple_history/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import django.dispatch


# Arguments: "instance", "history_instance", "history_date",
# "history_user", "history_change_reason", "using"
pre_create_historical_record = django.dispatch.Signal()
Expand Down
1 change: 1 addition & 0 deletions simple_history/tests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from simple_history.admin import SimpleHistoryAdmin
from simple_history.tests.external.models import ExternalModelWithCustomUserIdField

from .models import (
Book,
Choice,
Expand Down
7 changes: 3 additions & 4 deletions simple_history/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import datetime
import uuid

from django.apps import apps
from django.conf import settings
from django.db import models
from django.urls import reverse

from simple_history import register
from simple_history.models import HistoricalRecords
from .custom_user.models import CustomUser as User

from .external.models import AbstractExternal
from .external.models import AbstractExternal2
from .external.models import AbstractExternal3
from .custom_user.models import CustomUser as User
from .external.models import AbstractExternal, AbstractExternal2, AbstractExternal3

get_model = apps.get_model

Expand Down
2 changes: 2 additions & 0 deletions simple_history/tests/other_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.contrib.admin.sites import AdminSite

from simple_history.admin import SimpleHistoryAdmin

from .models import State

site = AdminSite(name="other_admin")
Expand Down
2 changes: 1 addition & 1 deletion simple_history/tests/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .test_models import *
from .test_admin import *
from .test_commands import *
from .test_manager import *
from .test_models import *
10 changes: 5 additions & 5 deletions simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from datetime import datetime, timedelta
from unittest.mock import ANY, patch

import django
from django.contrib.admin import AdminSite
from django.contrib.admin.utils import quote
from django.contrib.auth import get_user_model
Expand All @@ -8,13 +10,13 @@
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
import django
from unittest.mock import ANY, patch
from django.utils.encoding import force_str

from simple_history.admin import SimpleHistoryAdmin
from simple_history.models import HistoricalRecords
from simple_history.tests.external.models import ExternalModelWithCustomUserIdField
from simple_history.tests.tests.utils import middleware_override_settings

from ..models import (
Book,
BucketData,
Expand All @@ -24,13 +26,11 @@
Employee,
FileModel,
Person,
Planet,
Poll,
State,
Planet,
)

from django.utils.encoding import force_str

User = get_user_model()
today = datetime(2021, 1, 1, 10, 0)
tomorrow = today + timedelta(days=1)
Expand Down
3 changes: 2 additions & 1 deletion simple_history/tests/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

from simple_history import models as sh_models
from simple_history.management.commands import (
populate_history,
clean_duplicate_history,
clean_old_history,
populate_history,
)

from ..models import (
Book,
CustomManagerNameModel,
Expand Down
1 change: 0 additions & 1 deletion simple_history/tests/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from ..models import Document, Poll


User = get_user_model()


Expand Down
17 changes: 9 additions & 8 deletions simple_history/tests/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
database_router_override_settings_history_in_diff_db,
middleware_override_settings,
)
from simple_history.utils import get_history_model_for_model
from simple_history.utils import update_change_reason
from simple_history.utils import get_history_model_for_model, update_change_reason

from ..external.models import (
ExternalModel,
ExternalModelRegistered,
Expand Down Expand Up @@ -63,23 +63,23 @@
HistoricalPollWithHistoricalIPAddress,
HistoricalState,
InheritedRestaurant,
OverrideModelNameAsCallable,
OverrideModelNameUsingBaseModel1,
MyOverrideModelNameRegisterMethod1,
Library,
ManyToManyModelOther,
ModelWithExcludedManyToMany,
ModelWithFkToModelWithHistoryUsingBaseModelDb,
ModelWithHistoryInDifferentDb,
ModelWithHistoryUsingBaseModelDb,
MultiOneToOne,
MyOverrideModelNameRegisterMethod1,
OverrideModelNameAsCallable,
OverrideModelNameUsingBaseModel1,
Person,
Place,
Poll,
PollInfo,
PollWithExcludeFields,
PollWithExcludedFieldsWithDefaults,
PollWithExcludedFKField,
PollWithExcludeFields,
PollWithHistoricalIPAddress,
Province,
Restaurant,
Expand All @@ -89,10 +89,10 @@
State,
Street,
Temperature,
UUIDDefaultModel,
UUIDModel,
UnicodeVerboseName,
UserTextFieldChangeReasonModel,
UUIDDefaultModel,
UUIDModel,
WaterLevel,
)

Expand Down Expand Up @@ -821,6 +821,7 @@ def test_register_history_model_with_custom_model_name_override(self):
)

from simple_history import register

from ..models import OverrideModelNameRegisterMethod2

try:
Expand Down
2 changes: 1 addition & 1 deletion simple_history/tests/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from django.test import TestCase

from simple_history.signals import (
pre_create_historical_record,
post_create_historical_record,
pre_create_historical_record,
)

from ..models import Poll
Expand Down
4 changes: 2 additions & 2 deletions simple_history/tests/tests/test_templatetags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from simple_history.templatetags.getattributes import getattribute

from django.test import TestCase

from simple_history.templatetags.getattributes import getattribute


class Foo(object):
bar = "bar"
Expand Down
4 changes: 2 additions & 2 deletions simple_history/tests/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import datetime
from unittest.mock import Mock, patch

from django.contrib.auth import get_user_model
from django.db import IntegrityError, transaction
from django.test import TestCase, TransactionTestCase
from django.utils import timezone
from unittest.mock import Mock, patch

from simple_history.exceptions import AlternativeManagerError, NotHistoricalModelError
from simple_history.tests.models import (
Expand All @@ -19,8 +19,8 @@
)
from simple_history.utils import (
bulk_create_with_history,
update_change_reason,
bulk_update_with_history,
update_change_reason,
)

User = get_user_model()
Expand Down
Loading

0 comments on commit b43890f

Please sign in to comment.