mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
Used isort to sort imports (#460)
This commit is contained in:
parent
b0be6e2422
commit
79ff8ea6be
23 changed files with 86 additions and 53 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
CHANGES
|
CHANGES
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
Next release (tbc)
|
||||||
|
------------------
|
||||||
|
- Applied `isort` to codebase (Refs GH-#402)
|
||||||
|
|
||||||
4.1.0 (2020-11-29)
|
4.1.0 (2020-11-29)
|
||||||
------------------
|
------------------
|
||||||
- Update InheritanceQuerySetMixin to avoid querying too much tables
|
- Update InheritanceQuerySetMixin to avoid querying too much tables
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,13 @@ To run tox and generate a coverage report (in ``htmlcov`` directory)::
|
||||||
|
|
||||||
**Please note**: Before a pull request can be merged, all tests must pass and
|
**Please note**: Before a pull request can be merged, all tests must pass and
|
||||||
code/branch coverage in tests must be 100%.
|
code/branch coverage in tests must be 100%.
|
||||||
|
|
||||||
|
Code Formatting
|
||||||
|
---------------
|
||||||
|
We make use of `isort`_ to sort imports.
|
||||||
|
|
||||||
|
.. _isort: https://pycqa.github.io/isort/
|
||||||
|
|
||||||
|
Once it is installed you can make sure the code is properly formatted by running::
|
||||||
|
|
||||||
|
make format
|
||||||
|
|
|
||||||
3
Makefile
3
Makefile
|
|
@ -30,3 +30,6 @@ messages: init
|
||||||
|
|
||||||
compilemessages: init
|
compilemessages: init
|
||||||
$(PYTHON) translations.py compile
|
$(PYTHON) translations.py compile
|
||||||
|
|
||||||
|
format:
|
||||||
|
isort model_utils tests setup.py
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from pkg_resources import get_distribution, DistributionNotFound
|
from pkg_resources import DistributionNotFound, get_distribution
|
||||||
|
|
||||||
from .choices import Choices # noqa:F401
|
from .choices import Choices # noqa:F401
|
||||||
from .tracker import FieldTracker, ModelTracker # noqa:F401
|
from .tracker import FieldTracker, ModelTracker # noqa:F401
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import uuid
|
import uuid
|
||||||
from django.db import models
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
from django.db import models
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
|
||||||
DEFAULT_CHOICES_NAME = 'STATUS'
|
DEFAULT_CHOICES_NAME = 'STATUS'
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db import connection
|
from django.db import connection, models
|
||||||
from django.db import models
|
|
||||||
from django.db.models.constants import LOOKUP_SEP
|
from django.db.models.constants import LOOKUP_SEP
|
||||||
from django.db.models.fields.related import OneToOneField, OneToOneRel
|
from django.db.models.fields.related import OneToOneField, OneToOneRel
|
||||||
from django.db.models.query import ModelIterable
|
from django.db.models.query import ModelIterable, QuerySet
|
||||||
from django.db.models.query import QuerySet
|
|
||||||
from django.db.models.sql.datastructures import Join
|
from django.db.models.sql.datastructures import Join
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import models, transaction, router
|
from django.db import models, router, transaction
|
||||||
|
from django.db.models.functions import Now
|
||||||
from django.db.models.signals import post_save, pre_save
|
from django.db.models.signals import post_save, pre_save
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from model_utils.fields import (
|
from model_utils.fields import (
|
||||||
AutoCreatedField,
|
AutoCreatedField,
|
||||||
AutoLastModifiedField,
|
AutoLastModifiedField,
|
||||||
StatusField,
|
|
||||||
MonitorField,
|
MonitorField,
|
||||||
|
StatusField,
|
||||||
UUIDField,
|
UUIDField,
|
||||||
)
|
)
|
||||||
from model_utils.managers import (
|
from model_utils.managers import QueryManager, SoftDeletableManager
|
||||||
QueryManager,
|
|
||||||
SoftDeletableManager,
|
|
||||||
)
|
|
||||||
|
|
||||||
from django.db.models.functions import Now
|
|
||||||
now = Now()
|
now = Now()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,6 @@ all_files = 1
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
django_find_project = false
|
django_find_project = false
|
||||||
DJANGO_SETTINGS_MODULE = tests.settings
|
DJANGO_SETTINGS_MODULE = tests.settings
|
||||||
|
|
||||||
|
[isort]
|
||||||
|
profile = black
|
||||||
|
|
|
||||||
3
setup.py
3
setup.py
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
from setuptools import setup, find_packages
|
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
|
||||||
def long_desc(root_path):
|
def long_desc(root_path):
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from model_utils.managers import SoftDeletableQuerySet, SoftDeletableManager
|
from model_utils.managers import SoftDeletableManager, SoftDeletableQuerySet
|
||||||
|
|
||||||
|
|
||||||
class CustomSoftDeleteQuerySet(SoftDeletableQuerySet):
|
class CustomSoftDeleteQuerySet(SoftDeletableQuerySet):
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,23 @@
|
||||||
import django
|
import django
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.query_utils import DeferredAttribute
|
|
||||||
from django.db.models import Manager
|
from django.db.models import Manager
|
||||||
|
from django.db.models.query_utils import DeferredAttribute
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from model_utils import Choices
|
from model_utils import Choices
|
||||||
from model_utils.fields import (
|
from model_utils.fields import MonitorField, SplitField, StatusField, UUIDField
|
||||||
SplitField,
|
from model_utils.managers import InheritanceManager, JoinManagerMixin, QueryManager
|
||||||
MonitorField,
|
|
||||||
StatusField,
|
|
||||||
UUIDField,
|
|
||||||
)
|
|
||||||
from model_utils.managers import (
|
|
||||||
QueryManager,
|
|
||||||
InheritanceManager,
|
|
||||||
JoinManagerMixin
|
|
||||||
)
|
|
||||||
from model_utils.models import (
|
from model_utils.models import (
|
||||||
|
SaveSignalHandlingModel,
|
||||||
SoftDeletableModel,
|
SoftDeletableModel,
|
||||||
StatusModel,
|
StatusModel,
|
||||||
TimeFramedModel,
|
TimeFramedModel,
|
||||||
TimeStampedModel,
|
TimeStampedModel,
|
||||||
UUIDModel,
|
UUIDModel,
|
||||||
SaveSignalHandlingModel,
|
|
||||||
)
|
)
|
||||||
|
from model_utils.tracker import FieldTracker, ModelTracker
|
||||||
from tests.fields import MutableField
|
from tests.fields import MutableField
|
||||||
from tests.managers import CustomSoftDeleteManager
|
from tests.managers import CustomSoftDeleteManager
|
||||||
from model_utils.tracker import FieldTracker, ModelTracker
|
|
||||||
|
|
||||||
|
|
||||||
class InheritanceManagerTestRelated(models.Model):
|
class InheritanceManagerTestRelated(models.Model):
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,27 @@
|
||||||
from unittest import skip
|
from unittest import skip
|
||||||
|
|
||||||
|
from django.core.cache import cache
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.core.cache import cache
|
|
||||||
from model_utils import FieldTracker
|
from model_utils import FieldTracker
|
||||||
from model_utils.tracker import DescriptorWrapper
|
from model_utils.tracker import DescriptorWrapper
|
||||||
from tests.models import (
|
from tests.models import (
|
||||||
Tracked, TrackedFK, InheritedTrackedFK, TrackedNotDefault, TrackedNonFieldAttr, TrackedMultiple,
|
InheritedModelTracked,
|
||||||
InheritedTracked, TrackedFileField, TrackedAbstract, TrackerTimeStamped,
|
InheritedTracked,
|
||||||
ModelTracked, ModelTrackedFK, ModelTrackedNotDefault, ModelTrackedMultiple, InheritedModelTracked,
|
InheritedTrackedFK,
|
||||||
|
ModelTracked,
|
||||||
|
ModelTrackedFK,
|
||||||
|
ModelTrackedMultiple,
|
||||||
|
ModelTrackedNotDefault,
|
||||||
|
Tracked,
|
||||||
|
TrackedAbstract,
|
||||||
|
TrackedFileField,
|
||||||
|
TrackedFK,
|
||||||
|
TrackedMultiple,
|
||||||
|
TrackedNonFieldAttr,
|
||||||
|
TrackedNotDefault,
|
||||||
|
TrackerTimeStamped,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from django.test import TestCase
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from model_utils.fields import MonitorField
|
from model_utils.fields import MonitorField
|
||||||
from tests.models import Monitored, MonitorWhen, MonitorWhenEmpty, DoubleMonitored
|
from tests.models import DoubleMonitored, Monitored, MonitorWhen, MonitorWhenEmpty
|
||||||
|
|
||||||
|
|
||||||
class MonitorFieldTests(TestCase):
|
class MonitorFieldTests(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ from django.test import TestCase
|
||||||
|
|
||||||
from model_utils.fields import StatusField
|
from model_utils.fields import StatusField
|
||||||
from tests.models import (
|
from tests.models import (
|
||||||
Article, StatusFieldDefaultFilled, StatusFieldDefaultNotFilled,
|
Article,
|
||||||
StatusFieldChoicesName,
|
StatusFieldChoicesName,
|
||||||
|
StatusFieldDefaultFilled,
|
||||||
|
StatusFieldDefaultNotFilled,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from django.test import TestCase
|
|
||||||
from django.db.models import Prefetch
|
from django.db.models import Prefetch
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
from tests.models import InheritanceManagerTestParent, InheritanceManagerTestChild1
|
from tests.models import InheritanceManagerTestChild1, InheritanceManagerTestParent
|
||||||
|
|
||||||
|
|
||||||
class InheritanceIterableTest(TestCase):
|
class InheritanceIterableTest(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,15 @@ from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from tests.models import (
|
from tests.models import (
|
||||||
InheritanceManagerTestRelated, InheritanceManagerTestGrandChild1,
|
|
||||||
InheritanceManagerTestGrandChild1_2, InheritanceManagerTestParent,
|
|
||||||
InheritanceManagerTestChild1,
|
InheritanceManagerTestChild1,
|
||||||
InheritanceManagerTestChild2, TimeFrame, InheritanceManagerTestChild3,
|
InheritanceManagerTestChild2,
|
||||||
|
InheritanceManagerTestChild3,
|
||||||
InheritanceManagerTestChild4,
|
InheritanceManagerTestChild4,
|
||||||
|
InheritanceManagerTestGrandChild1,
|
||||||
|
InheritanceManagerTestGrandChild1_2,
|
||||||
|
InheritanceManagerTestParent,
|
||||||
|
InheritanceManagerTestRelated,
|
||||||
|
TimeFrame,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from tests.models import JoinItemForeignKey, BoxJoinModel
|
from tests.models import BoxJoinModel, JoinItemForeignKey
|
||||||
|
|
||||||
|
|
||||||
class JoinManagerTest(TestCase):
|
class JoinManagerTest(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from django.db import models
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from model_utils.managers import QueryManager
|
from model_utils.managers import QueryManager
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
from django.db.models.signals import post_save, pre_save
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from tests.models import SaveSignalHandlingTestModel
|
from tests.models import SaveSignalHandlingTestModel
|
||||||
from tests.signals import pre_save_test, post_save_test
|
from tests.signals import post_save_test, pre_save_test
|
||||||
from django.db.models.signals import pre_save, post_save
|
|
||||||
|
|
||||||
|
|
||||||
class SaveSignalHandlingModelTests(TestCase):
|
class SaveSignalHandlingModelTests(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from django.test.testcases import TestCase
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from django.test.testcases import TestCase
|
from tests.models import Status, StatusCustomManager, StatusPlainTuple
|
||||||
|
|
||||||
from tests.models import Status, StatusPlainTuple, StatusCustomManager
|
|
||||||
|
|
||||||
|
|
||||||
class StatusModelTests(TestCase):
|
class StatusModelTests(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from django.db import models
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from model_utils.managers import QueryManager
|
from model_utils.managers import QueryManager
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from tests.models import CustomUUIDModel, CustomNotPrimaryUUIDModel
|
from tests.models import CustomNotPrimaryUUIDModel, CustomUUIDModel
|
||||||
|
|
||||||
|
|
||||||
class UUIDFieldTests(TestCase):
|
class UUIDFieldTests(TestCase):
|
||||||
|
|
|
||||||
11
tox.ini
11
tox.ini
|
|
@ -1,13 +1,13 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
py{36,37,38,39}-dj{22,30,31,master}
|
py{36,37,38,39}-dj{22,30,31,master}
|
||||||
flake8
|
flake8, isort
|
||||||
|
|
||||||
[gh-actions]
|
[gh-actions]
|
||||||
python =
|
python =
|
||||||
3.6: py36
|
3.6: py36
|
||||||
3.7: py37
|
3.7: py37
|
||||||
3.8: py38, flake8
|
3.8: py38, flake8, isort
|
||||||
3.9: py39
|
3.9: py39
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
|
@ -46,3 +46,10 @@ ignore =
|
||||||
W503 ; line break before binary operator
|
W503 ; line break before binary operator
|
||||||
E402 ; module level import not at top of file
|
E402 ; module level import not at top of file
|
||||||
E501 ; line too long
|
E501 ; line too long
|
||||||
|
|
||||||
|
[testenv:isort]
|
||||||
|
basepython = python3.8
|
||||||
|
deps = isort
|
||||||
|
commands =
|
||||||
|
isort model_utils tests setup.py --check-only --diff
|
||||||
|
skip_install = True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue