diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..52591e4 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,6 @@ +[settings] +known_first_party=sqlalchemy_utils,tests +line_length=79 +multi_line_output=3 +not_skip=__init__.py +order_by_type=false diff --git a/.travis.yml b/.travis.yml index c665e30..a307723 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,5 +33,6 @@ install: - pip install -e .[$EXTRAS] script: + - isort --recursive --diff sqlalchemy_utils tests && isort --recursive --check-only sqlalchemy_utils tests - flake8 sqlalchemy_utils tests - py.test diff --git a/setup.py b/setup.py index 1c7112e..02d8a52 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,8 @@ extras_require = { 'pytz>=2014.2', 'python-dateutil>=2.2', 'pymysql', - 'flake8>=2.4.0' + 'flake8>=2.4.0', + 'isort==3.9.6' ], 'anyjson': ['anyjson>=0.3.3'], 'babel': ['Babel>=1.3'], diff --git a/sqlalchemy_utils/__init__.py b/sqlalchemy_utils/__init__.py index f6f5e3d..5101395 100644 --- a/sqlalchemy_utils/__init__.py +++ b/sqlalchemy_utils/__init__.py @@ -1,10 +1,10 @@ from .aggregates import aggregated # noqa from .asserts import ( # noqa - assert_min_value, assert_max_length, assert_max_value, - assert_nullable, - assert_non_nullable + assert_min_value, + assert_non_nullable, + assert_nullable ) from .batch import batch_fetch, with_backrefs # noqa from .decorators import generates # noqa @@ -25,8 +25,8 @@ from .functions import ( # noqa get_declarative_base, get_hybrid_properties, get_mapper, - get_query_entities, get_primary_keys, + get_query_entities, get_referencing_foreign_keys, get_tables, group_foreign_keys, @@ -42,8 +42,9 @@ from .functions import ( # noqa render_expression, render_statement, sort_query, - table_name, + table_name ) +from .generic import generic_relationship # noqa from .i18n import TranslationHybrid # noqa from .listeners import ( # noqa auto_delete_orphans, @@ -51,9 +52,9 @@ from .listeners import ( # noqa force_auto_coercion, force_instant_defaults ) -from .generic import generic_relationship # noqa -from .proxy_dict import ProxyDict, proxy_dict # noqa +from .models import Timestamp # noqa from .observer import observes # noqa +from .proxy_dict import proxy_dict, ProxyDict # noqa from .query_chain import QueryChain # noqa from .types import ( # noqa ArrowType, @@ -85,7 +86,5 @@ from .types import ( # noqa UUIDType, WeekDaysType ) -from .models import Timestamp # noqa - __version__ = '0.29.8' diff --git a/sqlalchemy_utils/aggregates.py b/sqlalchemy_utils/aggregates.py index ee4a5a0..c02b1f2 100644 --- a/sqlalchemy_utils/aggregates.py +++ b/sqlalchemy_utils/aggregates.py @@ -365,9 +365,13 @@ TODO from collections import defaultdict from weakref import WeakKeyDictionary -import sqlalchemy as sa import six +import sqlalchemy as sa from sqlalchemy.ext.declarative import declared_attr + +from .functions.orm import get_column_key +from .relationships import chained_join, select_aggregate + try: # SQLAlchemy 0.9 from sqlalchemy.sql.functions import _FunctionGenerator @@ -375,9 +379,6 @@ except ImportError: # SQLAlchemy 0.8 from sqlalchemy.sql.expression import _FunctionGenerator -from .functions.orm import get_column_key -from .relationships import chained_join, select_aggregate - aggregated_attrs = WeakKeyDictionary(defaultdict(list)) diff --git a/sqlalchemy_utils/asserts.py b/sqlalchemy_utils/asserts.py index 507c8e6..a7f5ee9 100644 --- a/sqlalchemy_utils/asserts.py +++ b/sqlalchemy_utils/asserts.py @@ -33,6 +33,7 @@ We can easily test the constraints by assert_* functions:: assert_max_length(user, 'email', 300) """ from decimal import Decimal + import sqlalchemy as sa from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.exc import DataError, IntegrityError diff --git a/sqlalchemy_utils/batch.py b/sqlalchemy_utils/batch.py index 8aa97dd..5796dd4 100644 --- a/sqlalchemy_utils/batch.py +++ b/sqlalchemy_utils/batch.py @@ -1,21 +1,24 @@ from collections import defaultdict from itertools import chain + import six import sqlalchemy as sa from sqlalchemy.orm import RelationshipProperty from sqlalchemy.orm.attributes import ( - set_committed_value, InstrumentedAttribute + InstrumentedAttribute, + set_committed_value ) from sqlalchemy.orm.session import object_session -from sqlalchemy_utils.generic import GenericRelationshipProperty + from sqlalchemy_utils.functions.orm import ( - list_local_values, list_local_remote_exprs, + list_local_values, local_values, + remote, remote_column_names, - remote_values, - remote + remote_values ) +from sqlalchemy_utils.generic import GenericRelationshipProperty class PathException(Exception): diff --git a/sqlalchemy_utils/decorators.py b/sqlalchemy_utils/decorators.py index 64e00ab..342a202 100644 --- a/sqlalchemy_utils/decorators.py +++ b/sqlalchemy_utils/decorators.py @@ -1,7 +1,9 @@ -from collections import defaultdict import itertools -import sqlalchemy as sa +from collections import defaultdict + import six +import sqlalchemy as sa + from .functions import getdotattr diff --git a/sqlalchemy_utils/expression_parser.py b/sqlalchemy_utils/expression_parser.py index 5bac9d3..074cc61 100644 --- a/sqlalchemy_utils/expression_parser.py +++ b/sqlalchemy_utils/expression_parser.py @@ -7,22 +7,22 @@ import six import sqlalchemy as sa from sqlalchemy.orm.attributes import InstrumentedAttribute from sqlalchemy.sql.annotation import AnnotatedColumn -from sqlalchemy.sql.expression import ( - BooleanClauseList, - BinaryExpression, - UnaryExpression, - BindParameter, - Cast, -) from sqlalchemy.sql.elements import ( - False_, - True_, - Grouping, - ClauseList, - Label, Case, - Tuple, - Null + ClauseList, + False_, + Grouping, + Label, + Null, + True_, + Tuple +) +from sqlalchemy.sql.expression import ( + BinaryExpression, + BindParameter, + BooleanClauseList, + Cast, + UnaryExpression ) diff --git a/sqlalchemy_utils/expressions.py b/sqlalchemy_utils/expressions.py index 9eadac4..8ac1a1d 100644 --- a/sqlalchemy_utils/expressions.py +++ b/sqlalchemy_utils/expressions.py @@ -1,11 +1,11 @@ import sqlalchemy as sa +from sqlalchemy.ext.compiler import compiles from sqlalchemy.sql import expression from sqlalchemy.sql.expression import ( - Executable, + _literal_as_text, ClauseElement, - _literal_as_text + Executable ) -from sqlalchemy.ext.compiler import compiles class explain(Executable, ClauseElement): diff --git a/sqlalchemy_utils/functions/__init__.py b/sqlalchemy_utils/functions/__init__.py index edc6270..a02df98 100644 --- a/sqlalchemy_utils/functions/__init__.py +++ b/sqlalchemy_utils/functions/__init__.py @@ -1,10 +1,3 @@ -from .mock import create_mock_engine, mock_engine # noqa -from .render import render_expression, render_statement # noqa -from .sort_query import ( # noqa - make_order_by_deterministic, - sort_query, - QuerySorterException -) from .database import ( # noqa analyze, create_database, @@ -22,8 +15,9 @@ from .foreign_keys import ( # noqa group_foreign_keys, is_indexed_foreign_key, merge_references, - non_indexed_foreign_keys, + non_indexed_foreign_keys ) +from .mock import create_mock_engine, mock_engine # noqa from .orm import ( # noqa get_bind, get_class_by_table, @@ -41,5 +35,11 @@ from .orm import ( # noqa is_loaded, naturally_equivalent, quote, - table_name, + table_name +) +from .render import render_expression, render_statement # noqa +from .sort_query import ( # noqa + make_order_by_deterministic, + QuerySorterException, + sort_query ) diff --git a/sqlalchemy_utils/functions/database.py b/sqlalchemy_utils/functions/database.py index b89442b..3e7b034 100644 --- a/sqlalchemy_utils/functions/database.py +++ b/sqlalchemy_utils/functions/database.py @@ -5,7 +5,8 @@ from copy import copy import sqlalchemy as sa from sqlalchemy.engine.url import make_url -from sqlalchemy.exc import ProgrammingError, OperationalError +from sqlalchemy.exc import OperationalError, ProgrammingError + from sqlalchemy_utils.expressions import explain_analyze from .orm import quote diff --git a/sqlalchemy_utils/functions/foreign_keys.py b/sqlalchemy_utils/functions/foreign_keys.py index 9157580..c9a0ef2 100644 --- a/sqlalchemy_utils/functions/foreign_keys.py +++ b/sqlalchemy_utils/functions/foreign_keys.py @@ -5,10 +5,10 @@ import six import sqlalchemy as sa from sqlalchemy.exc import NoInspectionAvailable from sqlalchemy.orm import object_session -from sqlalchemy.schema import MetaData, Table, ForeignKeyConstraint +from sqlalchemy.schema import ForeignKeyConstraint, MetaData, Table -from .orm import get_column_key, get_mapper, get_tables from ..query_chain import QueryChain +from .orm import get_column_key, get_mapper, get_tables def get_foreign_key_values(fk, obj): diff --git a/sqlalchemy_utils/functions/mock.py b/sqlalchemy_utils/functions/mock.py index 812a42c..258e4da 100644 --- a/sqlalchemy_utils/functions/mock.py +++ b/sqlalchemy_utils/functions/mock.py @@ -2,6 +2,7 @@ import contextlib import datetime import inspect import re + import six import sqlalchemy as sa diff --git a/sqlalchemy_utils/functions/orm.py b/sqlalchemy_utils/functions/orm.py index 5525fb3..113972e 100644 --- a/sqlalchemy_utils/functions/orm.py +++ b/sqlalchemy_utils/functions/orm.py @@ -2,10 +2,12 @@ try: from collections import OrderedDict except ImportError: from ordereddict import OrderedDict + from functools import partial from inspect import isclass from itertools import chain from operator import attrgetter + import six import sqlalchemy as sa from sqlalchemy.ext.hybrid import hybrid_property @@ -16,6 +18,7 @@ from sqlalchemy.orm.properties import ColumnProperty from sqlalchemy.orm.query import _ColumnEntity from sqlalchemy.orm.session import object_session from sqlalchemy.orm.util import AliasedInsp + from sqlalchemy_utils.utils import is_sequence diff --git a/sqlalchemy_utils/functions/render.py b/sqlalchemy_utils/functions/render.py index 44010c5..bf3be1e 100644 --- a/sqlalchemy_utils/functions/render.py +++ b/sqlalchemy_utils/functions/render.py @@ -1,6 +1,8 @@ import inspect + import six import sqlalchemy as sa + from .mock import create_mock_engine diff --git a/sqlalchemy_utils/functions/sort_query.py b/sqlalchemy_utils/functions/sort_query.py index 81688af..f233c4f 100644 --- a/sqlalchemy_utils/functions/sort_query.py +++ b/sqlalchemy_utils/functions/sort_query.py @@ -1,5 +1,5 @@ import sqlalchemy as sa -from sqlalchemy.sql.expression import desc, asc +from sqlalchemy.sql.expression import asc, desc from .database import has_unique_index from .orm import get_query_descriptor, get_tables diff --git a/sqlalchemy_utils/generic.py b/sqlalchemy_utils/generic.py index 1360a35..d117e0c 100644 --- a/sqlalchemy_utils/generic.py +++ b/sqlalchemy_utils/generic.py @@ -3,11 +3,11 @@ from collections import Iterable import six import sqlalchemy as sa from sqlalchemy.ext.hybrid import hybrid_property -from sqlalchemy.orm import attributes, class_mapper -from sqlalchemy.orm import ColumnProperty +from sqlalchemy.orm import attributes, class_mapper, ColumnProperty from sqlalchemy.orm.interfaces import MapperProperty, PropComparator from sqlalchemy.orm.session import _state_session from sqlalchemy.util import set_creation_order + from sqlalchemy_utils.functions import identity from .exceptions import ImproperlyConfigured diff --git a/sqlalchemy_utils/i18n.py b/sqlalchemy_utils/i18n.py index 129f86b..daa414a 100644 --- a/sqlalchemy_utils/i18n.py +++ b/sqlalchemy_utils/i18n.py @@ -2,7 +2,6 @@ from sqlalchemy.ext.hybrid import hybrid_property from .exceptions import ImproperlyConfigured - try: from babel.dates import get_day_names except ImportError: @@ -13,7 +12,6 @@ except ImportError: 'module.' ) - try: from flask.ext.babel import get_locale except ImportError: diff --git a/sqlalchemy_utils/listeners.py b/sqlalchemy_utils/listeners.py index 29970ff..ce6d774 100644 --- a/sqlalchemy_utils/listeners.py +++ b/sqlalchemy_utils/listeners.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from .exceptions import ImproperlyConfigured diff --git a/sqlalchemy_utils/models.py b/sqlalchemy_utils/models.py index c2cdf66..80a85ec 100644 --- a/sqlalchemy_utils/models.py +++ b/sqlalchemy_utils/models.py @@ -1,4 +1,5 @@ from datetime import datetime + import sqlalchemy as sa diff --git a/sqlalchemy_utils/observer.py b/sqlalchemy_utils/observer.py index d5b51ac..c216c8f 100644 --- a/sqlalchemy_utils/observer.py +++ b/sqlalchemy_utils/observer.py @@ -149,15 +149,15 @@ Category has many Products. catalog.product_count # 1 """ +import itertools +from collections import defaultdict, Iterable, namedtuple + import sqlalchemy as sa -from collections import defaultdict, namedtuple, Iterable -import itertools from sqlalchemy_utils.functions import getdotattr from sqlalchemy_utils.path import AttrPath from sqlalchemy_utils.utils import is_sequence - Callback = namedtuple('Callback', ['func', 'path', 'backref', 'fullpath']) diff --git a/sqlalchemy_utils/path.py b/sqlalchemy_utils/path.py index aaa812e..57ec694 100644 --- a/sqlalchemy_utils/path.py +++ b/sqlalchemy_utils/path.py @@ -1,6 +1,7 @@ import sqlalchemy as sa from sqlalchemy.orm.attributes import InstrumentedAttribute from sqlalchemy.util.langhelpers import symbol + from .utils import str_coercible diff --git a/sqlalchemy_utils/primitives/__init__.py b/sqlalchemy_utils/primitives/__init__.py index c4c401b..6831294 100644 --- a/sqlalchemy_utils/primitives/__init__.py +++ b/sqlalchemy_utils/primitives/__init__.py @@ -1,7 +1,6 @@ from .weekday import WeekDay from .weekdays import WeekDays - __all__ = ( WeekDay, WeekDays diff --git a/sqlalchemy_utils/primitives/weekdays.py b/sqlalchemy_utils/primitives/weekdays.py index 715bc3d..b6aedab 100644 --- a/sqlalchemy_utils/primitives/weekdays.py +++ b/sqlalchemy_utils/primitives/weekdays.py @@ -1,6 +1,7 @@ import six from sqlalchemy_utils.utils import str_coercible + from .weekday import WeekDay diff --git a/sqlalchemy_utils/types/__init__.py b/sqlalchemy_utils/types/__init__.py index 9e37990..4895582 100644 --- a/sqlalchemy_utils/types/__init__.py +++ b/sqlalchemy_utils/types/__init__.py @@ -1,22 +1,24 @@ from functools import wraps + from sqlalchemy.orm.collections import InstrumentedList as _InstrumentedList + from .arrow import ArrowType -from .choice import ChoiceType, Choice +from .choice import Choice, ChoiceType from .color import ColorType -from .country import CountryType, Country +from .country import Country, CountryType from .email import EmailType from .encrypted import EncryptedType from .ip_address import IPAddressType from .json import JSONType from .locale import LocaleType +from .password import Password, PasswordType +from .phone_number import PhoneNumber, PhoneNumberType from .range import ( DateRangeType, DateTimeRangeType, IntRangeType, - NumericRangeType, + NumericRangeType ) -from .password import Password, PasswordType -from .phone_number import PhoneNumber, PhoneNumberType from .scalar_list import ScalarListException, ScalarListType from .timezone import TimezoneType from .ts_vector import TSVectorType @@ -24,7 +26,6 @@ from .url import URLType from .uuid import UUIDType from .weekdays import WeekDaysType - __all__ = ( ArrowType, Choice, diff --git a/sqlalchemy_utils/types/arrow.py b/sqlalchemy_utils/types/arrow.py index 03bc7d1..441368d 100644 --- a/sqlalchemy_utils/types/arrow.py +++ b/sqlalchemy_utils/types/arrow.py @@ -1,16 +1,20 @@ from __future__ import absolute_import + from collections import Iterable from datetime import datetime + import six +from sqlalchemy import types + +from sqlalchemy_utils.exceptions import ImproperlyConfigured + +from .scalar_coercible import ScalarCoercible arrow = None try: import arrow except: pass -from sqlalchemy import types -from sqlalchemy_utils.exceptions import ImproperlyConfigured -from .scalar_coercible import ScalarCoercible class ArrowType(types.TypeDecorator, ScalarCoercible): diff --git a/sqlalchemy_utils/types/choice.py b/sqlalchemy_utils/types/choice.py index e93fb45..89168a3 100644 --- a/sqlalchemy_utils/types/choice.py +++ b/sqlalchemy_utils/types/choice.py @@ -1,7 +1,9 @@ -from sqlalchemy import types import six +from sqlalchemy import types + from ..exceptions import ImproperlyConfigured from .scalar_coercible import ScalarCoercible + try: from enum import Enum except ImportError: diff --git a/sqlalchemy_utils/types/color.py b/sqlalchemy_utils/types/color.py index dbe743f..7020a8f 100644 --- a/sqlalchemy_utils/types/color.py +++ b/sqlalchemy_utils/types/color.py @@ -1,6 +1,8 @@ import six from sqlalchemy import types + from sqlalchemy_utils.exceptions import ImproperlyConfigured + from .scalar_coercible import ScalarCoercible colour = None diff --git a/sqlalchemy_utils/types/country.py b/sqlalchemy_utils/types/country.py index cb689f9..9baeaaa 100644 --- a/sqlalchemy_utils/types/country.py +++ b/sqlalchemy_utils/types/country.py @@ -1,8 +1,10 @@ -from sqlalchemy import types import six -from .scalar_coercible import ScalarCoercible +from sqlalchemy import types + from sqlalchemy_utils import i18n +from .scalar_coercible import ScalarCoercible + class Country(object): def __init__(self, code_or_country): diff --git a/sqlalchemy_utils/types/email.py b/sqlalchemy_utils/types/email.py index 73acda1..59c5b9b 100644 --- a/sqlalchemy_utils/types/email.py +++ b/sqlalchemy_utils/types/email.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from ..operators import CaseInsensitiveComparator diff --git a/sqlalchemy_utils/types/encrypted.py b/sqlalchemy_utils/types/encrypted.py index 0d28b41..4470334 100644 --- a/sqlalchemy_utils/types/encrypted.py +++ b/sqlalchemy_utils/types/encrypted.py @@ -1,9 +1,12 @@ # -*- coding: utf-8 -*- import base64 -import six import datetime -from sqlalchemy.types import TypeDecorator, String, Binary + +import six +from sqlalchemy.types import Binary, String, TypeDecorator + from sqlalchemy_utils.exceptions import ImproperlyConfigured + from .scalar_coercible import ScalarCoercible cryptography = None diff --git a/sqlalchemy_utils/types/ip_address.py b/sqlalchemy_utils/types/ip_address.py index 3c78f5a..ec1c27a 100644 --- a/sqlalchemy_utils/types/ip_address.py +++ b/sqlalchemy_utils/types/ip_address.py @@ -1,4 +1,9 @@ import six +from sqlalchemy import types + +from sqlalchemy_utils.exceptions import ImproperlyConfigured + +from .scalar_coercible import ScalarCoercible ip_address = None try: @@ -10,11 +15,6 @@ except ImportError: pass -from sqlalchemy import types -from sqlalchemy_utils.exceptions import ImproperlyConfigured -from .scalar_coercible import ScalarCoercible - - class IPAddressType(types.TypeDecorator, ScalarCoercible): """ Changes IPAddress objects to a string representation on the way in and diff --git a/sqlalchemy_utils/types/json.py b/sqlalchemy_utils/types/json.py index b2b0a22..06b3ca5 100644 --- a/sqlalchemy_utils/types/json.py +++ b/sqlalchemy_utils/types/json.py @@ -1,5 +1,10 @@ from __future__ import absolute_import + +import six import sqlalchemy as sa +from sqlalchemy.dialects.postgresql.base import ischema_names + +from ..exceptions import ImproperlyConfigured json = None try: @@ -7,10 +12,6 @@ try: except ImportError: import json as json -import six -from sqlalchemy.dialects.postgresql.base import ischema_names -from ..exceptions import ImproperlyConfigured - try: from sqlalchemy.dialects.postgresql import JSON has_postgres_json = True diff --git a/sqlalchemy_utils/types/locale.py b/sqlalchemy_utils/types/locale.py index be5c48f..fccc7d2 100644 --- a/sqlalchemy_utils/types/locale.py +++ b/sqlalchemy_utils/types/locale.py @@ -1,7 +1,9 @@ -from sqlalchemy import types import six -from .scalar_coercible import ScalarCoercible +from sqlalchemy import types + from ..exceptions import ImproperlyConfigured +from .scalar_coercible import ScalarCoercible + babel = None try: import babel diff --git a/sqlalchemy_utils/types/password.py b/sqlalchemy_utils/types/password.py index 0f9d72e..852b3cb 100644 --- a/sqlalchemy_utils/types/password.py +++ b/sqlalchemy_utils/types/password.py @@ -1,11 +1,14 @@ -import six import weakref -from sqlalchemy_utils.exceptions import ImproperlyConfigured + +import six from sqlalchemy import types -from sqlalchemy.dialects import postgresql, oracle -from .scalar_coercible import ScalarCoercible +from sqlalchemy.dialects import oracle, postgresql from sqlalchemy.ext.mutable import Mutable +from sqlalchemy_utils.exceptions import ImproperlyConfigured + +from .scalar_coercible import ScalarCoercible + passlib = None try: import passlib diff --git a/sqlalchemy_utils/types/phone_number.py b/sqlalchemy_utils/types/phone_number.py index 3dd1409..e03b03a 100644 --- a/sqlalchemy_utils/types/phone_number.py +++ b/sqlalchemy_utils/types/phone_number.py @@ -1,13 +1,13 @@ from sqlalchemy import types + from sqlalchemy_utils.exceptions import ImproperlyConfigured from sqlalchemy_utils.utils import str_coercible -from .scalar_coercible import ScalarCoercible +from .scalar_coercible import ScalarCoercible try: import phonenumbers from phonenumbers.phonenumber import PhoneNumber as BasePhoneNumber - except ImportError: phonenumbers = None BasePhoneNumber = object diff --git a/sqlalchemy_utils/types/range.py b/sqlalchemy_utils/types/range.py index a40036a..396353c 100644 --- a/sqlalchemy_utils/types/range.py +++ b/sqlalchemy_utils/types/range.py @@ -119,22 +119,25 @@ Membership operators .. _intervals: https://github.com/kvesteri/intervals """ from collections import Iterable + +import six +import sqlalchemy as sa +from sqlalchemy import types +from sqlalchemy.dialects.postgresql import ( + DATERANGE, + INT4RANGE, + NUMRANGE, + TSRANGE +) + +from ..exceptions import ImproperlyConfigured +from .scalar_coercible import ScalarCoercible + intervals = None try: import intervals except ImportError: pass -import six -import sqlalchemy as sa -from sqlalchemy.dialects.postgresql import ( - INT4RANGE, - DATERANGE, - NUMRANGE, - TSRANGE, -) -from sqlalchemy import types -from ..exceptions import ImproperlyConfigured -from .scalar_coercible import ScalarCoercible class RangeComparator(types.TypeEngine.Comparator): diff --git a/sqlalchemy_utils/types/timezone.py b/sqlalchemy_utils/types/timezone.py index c349ea6..730260f 100644 --- a/sqlalchemy_utils/types/timezone.py +++ b/sqlalchemy_utils/types/timezone.py @@ -1,6 +1,8 @@ import six from sqlalchemy import types + from sqlalchemy_utils.exceptions import ImproperlyConfigured + from .scalar_coercible import ScalarCoercible diff --git a/sqlalchemy_utils/types/url.py b/sqlalchemy_utils/types/url.py index 68d5042..f74475a 100644 --- a/sqlalchemy_utils/types/url.py +++ b/sqlalchemy_utils/types/url.py @@ -5,6 +5,7 @@ except ImportError: pass import six from sqlalchemy import types + from .scalar_coercible import ScalarCoercible diff --git a/sqlalchemy_utils/types/uuid.py b/sqlalchemy_utils/types/uuid.py index 59d29e3..2fc3ad1 100644 --- a/sqlalchemy_utils/types/uuid.py +++ b/sqlalchemy_utils/types/uuid.py @@ -1,7 +1,10 @@ from __future__ import absolute_import + import uuid + from sqlalchemy import types from sqlalchemy.dialects import postgresql + from .scalar_coercible import ScalarCoercible diff --git a/sqlalchemy_utils/types/weekdays.py b/sqlalchemy_utils/types/weekdays.py index 6b1d269..efd6232 100644 --- a/sqlalchemy_utils/types/weekdays.py +++ b/sqlalchemy_utils/types/weekdays.py @@ -5,10 +5,12 @@ except ImportError: pass import six from sqlalchemy import types + from sqlalchemy_utils.exceptions import ImproperlyConfigured from sqlalchemy_utils.primitives import WeekDay, WeekDays -from .scalar_coercible import ScalarCoercible + from .bit import BitType +from .scalar_coercible import ScalarCoercible class WeekDaysType(types.TypeDecorator, ScalarCoercible): diff --git a/tests/__init__.py b/tests/__init__.py index 0fedbd6..34ce3e8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,13 +1,16 @@ import warnings -import sqlalchemy as sa +import sqlalchemy as sa from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base, synonym_for from sqlalchemy.ext.hybrid import hybrid_property +from sqlalchemy.orm import sessionmaker from sqlalchemy_utils import ( - InstrumentedList, coercion_listener, aggregates, i18n + aggregates, + coercion_listener, + i18n, + InstrumentedList ) diff --git a/tests/aggregate/test_backrefs.py b/tests/aggregate/test_backrefs.py index c870444..e7d0d2d 100644 --- a/tests/aggregate/test_backrefs.py +++ b/tests/aggregate/test_backrefs.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_custom_select_expressions.py b/tests/aggregate/test_custom_select_expressions.py index 725acca..de03b79 100644 --- a/tests/aggregate/test_custom_select_expressions.py +++ b/tests/aggregate/test_custom_select_expressions.py @@ -1,5 +1,7 @@ from decimal import Decimal + import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_join_table_inheritance.py b/tests/aggregate/test_join_table_inheritance.py index a6e5041..fa891ec 100644 --- a/tests/aggregate/test_join_table_inheritance.py +++ b/tests/aggregate/test_join_table_inheritance.py @@ -1,5 +1,7 @@ from decimal import Decimal + import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_m2m.py b/tests/aggregate/test_m2m.py index a63f02a..4a9ac45 100644 --- a/tests/aggregate/test_m2m.py +++ b/tests/aggregate/test_m2m.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_multiple_aggregates_per_class.py b/tests/aggregate/test_multiple_aggregates_per_class.py index aa949b5..ee8b5dc 100644 --- a/tests/aggregate/test_multiple_aggregates_per_class.py +++ b/tests/aggregate/test_multiple_aggregates_per_class.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_o2m_o2m.py b/tests/aggregate/test_o2m_o2m.py index b245a0b..9abed54 100644 --- a/tests/aggregate/test_o2m_o2m.py +++ b/tests/aggregate/test_o2m_o2m.py @@ -1,5 +1,7 @@ from decimal import Decimal + import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_search_vectors.py b/tests/aggregate/test_search_vectors.py index 28c72ac..d2a8621 100644 --- a/tests/aggregate/test_search_vectors.py +++ b/tests/aggregate/test_search_vectors.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import aggregated, TSVectorType from tests import TestCase diff --git a/tests/aggregate/test_simple_paths.py b/tests/aggregate/test_simple_paths.py index 07104a2..1f1c071 100644 --- a/tests/aggregate/test_simple_paths.py +++ b/tests/aggregate/test_simple_paths.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_with_column_alias.py b/tests/aggregate/test_with_column_alias.py index 744cbcd..80a87e5 100644 --- a/tests/aggregate/test_with_column_alias.py +++ b/tests/aggregate/test_with_column_alias.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/aggregate/test_with_ondelete_cascade.py b/tests/aggregate/test_with_ondelete_cascade.py index 6070d9b..93a26d0 100644 --- a/tests/aggregate/test_with_ondelete_cascade.py +++ b/tests/aggregate/test_with_ondelete_cascade.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import aggregated from tests import TestCase diff --git a/tests/batch_fetch/test_compound_fetching.py b/tests/batch_fetch/test_compound_fetching.py index db24c76..e4a6ff1 100644 --- a/tests/batch_fetch/test_compound_fetching.py +++ b/tests/batch_fetch/test_compound_fetching.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import batch_fetch from tests import TestCase diff --git a/tests/batch_fetch/test_deep_relationships.py b/tests/batch_fetch/test_deep_relationships.py index afd39b4..98cd5be 100644 --- a/tests/batch_fetch/test_deep_relationships.py +++ b/tests/batch_fetch/test_deep_relationships.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import batch_fetch, with_backrefs from tests import TestCase diff --git a/tests/batch_fetch/test_generic_relationship.py b/tests/batch_fetch/test_generic_relationship.py index 0748c2c..e612562 100644 --- a/tests/batch_fetch/test_generic_relationship.py +++ b/tests/batch_fetch/test_generic_relationship.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals + import sqlalchemy as sa -from tests import TestCase + from sqlalchemy_utils import batch_fetch, generic_relationship +from tests import TestCase class TestBatchFetchGenericRelationship(TestCase): diff --git a/tests/batch_fetch/test_join_table_inheritance.py b/tests/batch_fetch/test_join_table_inheritance.py index a7f66be..362ebe4 100644 --- a/tests/batch_fetch/test_join_table_inheritance.py +++ b/tests/batch_fetch/test_join_table_inheritance.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import batch_fetch from tests import TestCase diff --git a/tests/batch_fetch/test_many_to_many_composite_keys.py b/tests/batch_fetch/test_many_to_many_composite_keys.py index 0d19578..a2306e4 100644 --- a/tests/batch_fetch/test_many_to_many_composite_keys.py +++ b/tests/batch_fetch/test_many_to_many_composite_keys.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import batch_fetch, with_backrefs from tests import TestCase diff --git a/tests/batch_fetch/test_many_to_one_relationships.py b/tests/batch_fetch/test_many_to_one_relationships.py index 4c774a0..578e290 100644 --- a/tests/batch_fetch/test_many_to_one_relationships.py +++ b/tests/batch_fetch/test_many_to_one_relationships.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import batch_fetch from tests import TestCase diff --git a/tests/batch_fetch/test_one_to_many_composite_keys.py b/tests/batch_fetch/test_one_to_many_composite_keys.py index 386f7fa..b19bc71 100644 --- a/tests/batch_fetch/test_one_to_many_composite_keys.py +++ b/tests/batch_fetch/test_one_to_many_composite_keys.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import batch_fetch from tests import TestCase diff --git a/tests/batch_fetch/test_one_to_many_relationships.py b/tests/batch_fetch/test_one_to_many_relationships.py index 876ae30..f782fe6 100644 --- a/tests/batch_fetch/test_one_to_many_relationships.py +++ b/tests/batch_fetch/test_one_to_many_relationships.py @@ -1,5 +1,6 @@ import sqlalchemy as sa from pytest import raises + from sqlalchemy_utils import batch_fetch from tests import TestCase diff --git a/tests/functions/test_database.py b/tests/functions/test_database.py index f72bd6b..ab14b85 100644 --- a/tests/functions/test_database.py +++ b/tests/functions/test_database.py @@ -3,20 +3,16 @@ import os import sqlalchemy as sa from flexmock import flexmock from pytest import mark + +from sqlalchemy_utils import create_database, database_exists, drop_database +from tests import TestCase + pymysql = None try: import pymysql # noqa except ImportError: pass -from tests import TestCase - -from sqlalchemy_utils import ( - create_database, - drop_database, - database_exists, -) - class DatabaseTest(TestCase): def test_create_and_drop(self): diff --git a/tests/functions/test_dependent_objects.py b/tests/functions/test_dependent_objects.py index 06b4876..0702dd7 100644 --- a/tests/functions/test_dependent_objects.py +++ b/tests/functions/test_dependent_objects.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import dependent_objects, get_referencing_foreign_keys from tests import TestCase diff --git a/tests/functions/test_get_class_by_table.py b/tests/functions/test_get_class_by_table.py index af1f529..99db410 100644 --- a/tests/functions/test_get_class_by_table.py +++ b/tests/functions/test_get_class_by_table.py @@ -1,6 +1,5 @@ -from pytest import raises - import sqlalchemy as sa +from pytest import raises from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_utils import get_class_by_table diff --git a/tests/functions/test_get_column_key.py b/tests/functions/test_get_column_key.py index c7ed02f..486483c 100644 --- a/tests/functions/test_get_column_key.py +++ b/tests/functions/test_get_column_key.py @@ -1,7 +1,7 @@ from copy import copy -from pytest import raises import sqlalchemy as sa +from pytest import raises from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_utils import get_column_key diff --git a/tests/functions/test_get_hybrid_properties.py b/tests/functions/test_get_hybrid_properties.py index 68b2dd6..a37a664 100644 --- a/tests/functions/test_get_hybrid_properties.py +++ b/tests/functions/test_get_hybrid_properties.py @@ -1,6 +1,6 @@ import sqlalchemy as sa -from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy_utils import get_hybrid_properties diff --git a/tests/functions/test_get_mapper.py b/tests/functions/test_get_mapper.py index 89088ee..766b495 100644 --- a/tests/functions/test_get_mapper.py +++ b/tests/functions/test_get_mapper.py @@ -1,9 +1,8 @@ -from pytest import raises import sqlalchemy as sa +from pytest import raises from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_utils import get_mapper - from tests import TestCase diff --git a/tests/functions/test_get_primary_keys.py b/tests/functions/test_get_primary_keys.py index 060ebc5..73525be 100644 --- a/tests/functions/test_get_primary_keys.py +++ b/tests/functions/test_get_primary_keys.py @@ -1,12 +1,13 @@ -try: - from collections import OrderedDict -except ImportError: - from ordereddict import OrderedDict import sqlalchemy as sa from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_utils import get_primary_keys +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict + class TestGetPrimaryKeys(object): def setup_method(self, method): diff --git a/tests/functions/test_get_query_entities.py b/tests/functions/test_get_query_entities.py index 448779c..e9a37e1 100644 --- a/tests/functions/test_get_query_entities.py +++ b/tests/functions/test_get_query_entities.py @@ -1,6 +1,6 @@ import sqlalchemy as sa -from sqlalchemy_utils import get_query_entities +from sqlalchemy_utils import get_query_entities from tests import TestCase diff --git a/tests/functions/test_get_referencing_foreign_keys.py b/tests/functions/test_get_referencing_foreign_keys.py index 4e0660e..dc8a5de 100644 --- a/tests/functions/test_get_referencing_foreign_keys.py +++ b/tests/functions/test_get_referencing_foreign_keys.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import get_referencing_foreign_keys from tests import TestCase diff --git a/tests/functions/test_get_tables.py b/tests/functions/test_get_tables.py index 58f4edc..682e782 100644 --- a/tests/functions/test_get_tables.py +++ b/tests/functions/test_get_tables.py @@ -1,7 +1,6 @@ import sqlalchemy as sa from sqlalchemy_utils import get_tables - from tests import TestCase diff --git a/tests/functions/test_getdotattr.py b/tests/functions/test_getdotattr.py index 6dae397..c768ecb 100644 --- a/tests/functions/test_getdotattr.py +++ b/tests/functions/test_getdotattr.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.functions import getdotattr from tests import TestCase diff --git a/tests/functions/test_has_unique_index.py b/tests/functions/test_has_unique_index.py index 47ea1c4..157dfc8 100644 --- a/tests/functions/test_has_unique_index.py +++ b/tests/functions/test_has_unique_index.py @@ -1,5 +1,5 @@ -from pytest import raises import sqlalchemy as sa +from pytest import raises from sqlalchemy.ext.declarative import declarative_base from sqlalchemy_utils import has_unique_index diff --git a/tests/functions/test_identity.py b/tests/functions/test_identity.py index f220f0d..d1d3d42 100644 --- a/tests/functions/test_identity.py +++ b/tests/functions/test_identity.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.functions import identity from tests import TestCase diff --git a/tests/functions/test_json_sql.py b/tests/functions/test_json_sql.py index 7faf313..bb3766a 100644 --- a/tests/functions/test_json_sql.py +++ b/tests/functions/test_json_sql.py @@ -1,7 +1,7 @@ import pytest import sqlalchemy as sa -from sqlalchemy_utils import json_sql +from sqlalchemy_utils import json_sql from tests import TestCase diff --git a/tests/functions/test_make_order_by_deterministic.py b/tests/functions/test_make_order_by_deterministic.py index 87f635d..70d9aa8 100644 --- a/tests/functions/test_make_order_by_deterministic.py +++ b/tests/functions/test_make_order_by_deterministic.py @@ -1,7 +1,6 @@ import sqlalchemy as sa from sqlalchemy_utils.functions.sort_query import make_order_by_deterministic - from tests import assert_contains, TestCase diff --git a/tests/functions/test_merge_references.py b/tests/functions/test_merge_references.py index e982bd8..e97f7a2 100644 --- a/tests/functions/test_merge_references.py +++ b/tests/functions/test_merge_references.py @@ -1,6 +1,6 @@ import sqlalchemy as sa -from sqlalchemy_utils import merge_references +from sqlalchemy_utils import merge_references from tests import TestCase diff --git a/tests/functions/test_non_indexed_foreign_keys.py b/tests/functions/test_non_indexed_foreign_keys.py index 65b64df..46a9d51 100644 --- a/tests/functions/test_non_indexed_foreign_keys.py +++ b/tests/functions/test_non_indexed_foreign_keys.py @@ -1,6 +1,7 @@ import sqlalchemy as sa -from tests import TestCase + from sqlalchemy_utils.functions import non_indexed_foreign_keys +from tests import TestCase class TestFindNonIndexedForeignKeys(TestCase): diff --git a/tests/functions/test_render.py b/tests/functions/test_render.py index 8855400..13b2a38 100644 --- a/tests/functions/test_render.py +++ b/tests/functions/test_render.py @@ -1,10 +1,11 @@ import sqlalchemy as sa -from tests import TestCase + from sqlalchemy_utils.functions import ( - render_statement, + mock_engine, render_expression, - mock_engine + render_statement ) +from tests import TestCase class TestRender(TestCase): diff --git a/tests/functions/test_table_name.py b/tests/functions/test_table_name.py index 234d22f..6018110 100644 --- a/tests/functions/test_table_name.py +++ b/tests/functions/test_table_name.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import table_name from tests import TestCase diff --git a/tests/generic_relationship/__init__.py b/tests/generic_relationship/__init__.py index caabb0c..9b2de76 100644 --- a/tests/generic_relationship/__init__.py +++ b/tests/generic_relationship/__init__.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals + import six + from tests import TestCase diff --git a/tests/generic_relationship/test_abstract_base_class.py b/tests/generic_relationship/test_abstract_base_class.py index efdf79d..709f0db 100644 --- a/tests/generic_relationship/test_abstract_base_class.py +++ b/tests/generic_relationship/test_abstract_base_class.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals + import sqlalchemy as sa -from sqlalchemy_utils import generic_relationship from sqlalchemy.ext.declarative import declared_attr + +from sqlalchemy_utils import generic_relationship from tests.generic_relationship import GenericRelationshipTestCase diff --git a/tests/generic_relationship/test_column_aliases.py b/tests/generic_relationship/test_column_aliases.py index 3e34bc7..1d93c79 100644 --- a/tests/generic_relationship/test_column_aliases.py +++ b/tests/generic_relationship/test_column_aliases.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals + import sqlalchemy as sa + from sqlalchemy_utils import generic_relationship from tests.generic_relationship import GenericRelationshipTestCase diff --git a/tests/generic_relationship/test_composite_keys.py b/tests/generic_relationship/test_composite_keys.py index 6528e37..d730d09 100644 --- a/tests/generic_relationship/test_composite_keys.py +++ b/tests/generic_relationship/test_composite_keys.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + import six import sqlalchemy as sa + from sqlalchemy_utils import generic_relationship from tests.generic_relationship import GenericRelationshipTestCase diff --git a/tests/generic_relationship/test_hybrid_properties.py b/tests/generic_relationship/test_hybrid_properties.py index 564e23a..ce4575f 100644 --- a/tests/generic_relationship/test_hybrid_properties.py +++ b/tests/generic_relationship/test_hybrid_properties.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals + import six import sqlalchemy as sa from sqlalchemy.ext.hybrid import hybrid_property + from sqlalchemy_utils import generic_relationship from tests import TestCase diff --git a/tests/generic_relationship/test_single_table_inheritance.py b/tests/generic_relationship/test_single_table_inheritance.py index ac9ad14..1013717 100644 --- a/tests/generic_relationship/test_single_table_inheritance.py +++ b/tests/generic_relationship/test_single_table_inheritance.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals + import six import sqlalchemy as sa + from sqlalchemy_utils import generic_relationship from tests import TestCase diff --git a/tests/observes/test_o2m_o2m_o2m.py b/tests/observes/test_o2m_o2m_o2m.py index 9656141..a11b378 100644 --- a/tests/observes/test_o2m_o2m_o2m.py +++ b/tests/observes/test_o2m_o2m_o2m.py @@ -1,7 +1,7 @@ import sqlalchemy as sa -from tests import TestCase from sqlalchemy_utils.observer import observes +from tests import TestCase class TestObservesFor3LevelDeepOneToMany(TestCase): diff --git a/tests/observes/test_o2m_o2o_o2m.py b/tests/observes/test_o2m_o2o_o2m.py index a08aa09..2299280 100644 --- a/tests/observes/test_o2m_o2o_o2m.py +++ b/tests/observes/test_o2m_o2o_o2m.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.observer import observes from tests import TestCase diff --git a/tests/observes/test_o2o_o2o_o2o.py b/tests/observes/test_o2o_o2o_o2o.py index a62feba..00cfca8 100644 --- a/tests/observes/test_o2o_o2o_o2o.py +++ b/tests/observes/test_o2o_o2o_o2o.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.observer import observes from tests import TestCase diff --git a/tests/primitives/test_weekdays.py b/tests/primitives/test_weekdays.py index f9496a8..5e3f923 100644 --- a/tests/primitives/test_weekdays.py +++ b/tests/primitives/test_weekdays.py @@ -1,14 +1,15 @@ +import pytest +import six +from flexmock import flexmock + +from sqlalchemy_utils import i18n +from sqlalchemy_utils.primitives import WeekDay, WeekDays + Locale = None try: from babel import Locale except ImportError: pass -from flexmock import flexmock -import pytest - -import six -from sqlalchemy_utils.primitives import WeekDay, WeekDays -from sqlalchemy_utils import i18n @pytest.mark.skipif('Locale is None') diff --git a/tests/relationships/test_chained_join.py b/tests/relationships/test_chained_join.py index a19ebcf..aff42d4 100644 --- a/tests/relationships/test_chained_join.py +++ b/tests/relationships/test_chained_join.py @@ -3,7 +3,7 @@ from tests import TestCase from tests.mixins import ( ThreeLevelDeepManyToMany, ThreeLevelDeepOneToMany, - ThreeLevelDeepOneToOne, + ThreeLevelDeepOneToOne ) diff --git a/tests/relationships/test_select_aggregate.py b/tests/relationships/test_select_aggregate.py index 88d201f..f4fe687 100644 --- a/tests/relationships/test_select_aggregate.py +++ b/tests/relationships/test_select_aggregate.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.aggregates import select_aggregate from tests import TestCase from tests.mixins import ThreeLevelDeepManyToMany diff --git a/tests/test_asserts.py b/tests/test_asserts.py index ea6d587..ba1f820 100644 --- a/tests/test_asserts.py +++ b/tests/test_asserts.py @@ -1,15 +1,15 @@ -import sqlalchemy as sa import pytest +import sqlalchemy as sa from sqlalchemy.dialects.postgresql import ARRAY + from sqlalchemy_utils import ( - assert_min_value, assert_max_length, assert_max_value, - assert_nullable, - assert_non_nullable + assert_min_value, + assert_non_nullable, + assert_nullable ) from sqlalchemy_utils.asserts import raises - from tests import TestCase diff --git a/tests/test_auto_delete_orphans.py b/tests/test_auto_delete_orphans.py index d1c45ba..6efb5b9 100644 --- a/tests/test_auto_delete_orphans.py +++ b/tests/test_auto_delete_orphans.py @@ -1,7 +1,7 @@ -from pytest import raises import sqlalchemy as sa -from sqlalchemy_utils import auto_delete_orphans, ImproperlyConfigured +from pytest import raises +from sqlalchemy_utils import auto_delete_orphans, ImproperlyConfigured from tests import TestCase diff --git a/tests/test_case_insensitive_comparator.py b/tests/test_case_insensitive_comparator.py index 56dd79b..19812e1 100644 --- a/tests/test_case_insensitive_comparator.py +++ b/tests/test_case_insensitive_comparator.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import EmailType from tests import TestCase diff --git a/tests/test_expression_parser.py b/tests/test_expression_parser.py index 42a3b3c..d7cccac 100644 --- a/tests/test_expression_parser.py +++ b/tests/test_expression_parser.py @@ -1,8 +1,8 @@ -from sqlalchemy_utils import ExpressionParser import sqlalchemy as sa from sqlalchemy.sql.elements import Cast, Null -from . import TestCase +from sqlalchemy_utils import ExpressionParser +from tests import TestCase class MyExpressionParser(ExpressionParser): diff --git a/tests/test_expressions.py b/tests/test_expressions.py index 0c0e80f..c692fb0 100644 --- a/tests/test_expressions.py +++ b/tests/test_expressions.py @@ -1,5 +1,6 @@ import sqlalchemy as sa from sqlalchemy.dialects import postgresql + from sqlalchemy_utils.expressions import explain, explain_analyze from tests import TestCase diff --git a/tests/test_generates.py b/tests/test_generates.py index 532c62b..2917905 100644 --- a/tests/test_generates.py +++ b/tests/test_generates.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import generates from tests import TestCase diff --git a/tests/test_instant_defaults_listener.py b/tests/test_instant_defaults_listener.py index fa1a2d4..0ec444a 100644 --- a/tests/test_instant_defaults_listener.py +++ b/tests/test_instant_defaults_listener.py @@ -1,9 +1,10 @@ from datetime import datetime + import sqlalchemy as sa + from sqlalchemy_utils.listeners import force_instant_defaults from tests import TestCase - force_instant_defaults() diff --git a/tests/test_models.py b/tests/test_models.py index 5968e1e..83aa912 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,5 +1,7 @@ from datetime import datetime + import sqlalchemy as sa + from sqlalchemy_utils import Timestamp from tests import TestCase diff --git a/tests/test_path.py b/tests/test_path.py index 3246fa1..06af498 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -2,7 +2,8 @@ import six import sqlalchemy as sa from pytest import mark from sqlalchemy.util.langhelpers import symbol -from sqlalchemy_utils.path import Path, AttrPath + +from sqlalchemy_utils.path import AttrPath, Path from tests import TestCase diff --git a/tests/test_proxy_dict.py b/tests/test_proxy_dict.py index 58bec79..a87f39c 100644 --- a/tests/test_proxy_dict.py +++ b/tests/test_proxy_dict.py @@ -1,6 +1,7 @@ -from flexmock import flexmock import sqlalchemy as sa -from sqlalchemy_utils import ProxyDict, proxy_dict +from flexmock import flexmock + +from sqlalchemy_utils import proxy_dict, ProxyDict from tests import TestCase diff --git a/tests/test_query_chain.py b/tests/test_query_chain.py index 7796ff7..89b4ea4 100644 --- a/tests/test_query_chain.py +++ b/tests/test_query_chain.py @@ -1,6 +1,6 @@ import sqlalchemy as sa -from sqlalchemy_utils import QueryChain +from sqlalchemy_utils import QueryChain from tests import TestCase diff --git a/tests/test_sort_query.py b/tests/test_sort_query.py index 2f8332c..ef84270 100644 --- a/tests/test_sort_query.py +++ b/tests/test_sort_query.py @@ -1,5 +1,6 @@ -from pytest import raises import sqlalchemy as sa +from pytest import raises + from sqlalchemy_utils import sort_query from sqlalchemy_utils.functions import QuerySorterException from tests import assert_contains, TestCase diff --git a/tests/test_translation_hybrid.py b/tests/test_translation_hybrid.py index a11e402..66c5116 100644 --- a/tests/test_translation_hybrid.py +++ b/tests/test_translation_hybrid.py @@ -1,7 +1,7 @@ import sqlalchemy as sa from sqlalchemy.dialects.postgresql import HSTORE -from sqlalchemy_utils import TranslationHybrid +from sqlalchemy_utils import TranslationHybrid from tests import TestCase diff --git a/tests/types/test_arrow.py b/tests/types/test_arrow.py index c1b4f00..f3ca975 100644 --- a/tests/types/test_arrow.py +++ b/tests/types/test_arrow.py @@ -1,6 +1,8 @@ from datetime import datetime -from pytest import mark + import sqlalchemy as sa +from pytest import mark + from sqlalchemy_utils.types import arrow from tests import TestCase diff --git a/tests/types/test_choice.py b/tests/types/test_choice.py index d82177e..c11bdfe 100644 --- a/tests/types/test_choice.py +++ b/tests/types/test_choice.py @@ -1,7 +1,8 @@ -from flexmock import flexmock -from pytest import raises, mark import sqlalchemy as sa -from sqlalchemy_utils import ChoiceType, Choice, ImproperlyConfigured +from flexmock import flexmock +from pytest import mark, raises + +from sqlalchemy_utils import Choice, ChoiceType, ImproperlyConfigured from sqlalchemy_utils.types.choice import Enum from tests import TestCase diff --git a/tests/types/test_color.py b/tests/types/test_color.py index 37366f0..aa1d60c 100644 --- a/tests/types/test_color.py +++ b/tests/types/test_color.py @@ -1,6 +1,7 @@ +import sqlalchemy as sa from flexmock import flexmock from pytest import mark -import sqlalchemy as sa + from sqlalchemy_utils import ColorType, types # noqa from tests import TestCase diff --git a/tests/types/test_country.py b/tests/types/test_country.py index 07821ad..2df8ff3 100644 --- a/tests/types/test_country.py +++ b/tests/types/test_country.py @@ -1,5 +1,6 @@ import sqlalchemy as sa -from sqlalchemy_utils import CountryType, Country + +from sqlalchemy_utils import Country, CountryType from tests import TestCase diff --git a/tests/types/test_email.py b/tests/types/test_email.py index 06d03a5..5b65f71 100644 --- a/tests/types/test_email.py +++ b/tests/types/test_email.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils import EmailType from tests import TestCase diff --git a/tests/types/test_encrypted.py b/tests/types/test_encrypted.py index 7b28866..a91e642 100644 --- a/tests/types/test_encrypted.py +++ b/tests/types/test_encrypted.py @@ -1,17 +1,19 @@ -import sqlalchemy as sa -from datetime import datetime, date, time +from datetime import date, datetime, time + import pytest +import sqlalchemy as sa from pytest import mark + +from sqlalchemy_utils import ColorType, EncryptedType, PhoneNumberType +from sqlalchemy_utils.types.encrypted import AesEngine, FernetEngine +from tests import TestCase + cryptography = None try: import cryptography # noqa except ImportError: pass -from tests import TestCase -from sqlalchemy_utils import EncryptedType, PhoneNumberType, ColorType -from sqlalchemy_utils.types.encrypted import AesEngine, FernetEngine - @mark.skipif('cryptography is None') class EncryptedTypeTestCase(TestCase): diff --git a/tests/types/test_int_range.py b/tests/types/test_int_range.py index a547d52..fd60dac 100644 --- a/tests/types/test_int_range.py +++ b/tests/types/test_int_range.py @@ -1,5 +1,9 @@ -from pytest import mark import sqlalchemy as sa +from pytest import mark + +from sqlalchemy_utils import IntRangeType +from tests import TestCase + intervals = None inf = -1 try: @@ -7,8 +11,6 @@ try: from infinity import inf except ImportError: pass -from tests import TestCase -from sqlalchemy_utils import IntRangeType @mark.skipif('intervals is None') diff --git a/tests/types/test_ip_address.py b/tests/types/test_ip_address.py index a3725ba..3b5a4e5 100644 --- a/tests/types/test_ip_address.py +++ b/tests/types/test_ip_address.py @@ -1,6 +1,7 @@ -from pytest import mark import six import sqlalchemy as sa +from pytest import mark + from sqlalchemy_utils.types import ip_address from tests import TestCase diff --git a/tests/types/test_json.py b/tests/types/test_json.py index ab4939a..8305a36 100644 --- a/tests/types/test_json.py +++ b/tests/types/test_json.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from pytest import mark import sqlalchemy as sa +from pytest import mark + from sqlalchemy_utils.types import json from tests import TestCase diff --git a/tests/types/test_locale.py b/tests/types/test_locale.py index 9eaa03a..573aa3d 100644 --- a/tests/types/test_locale.py +++ b/tests/types/test_locale.py @@ -1,5 +1,6 @@ -from pytest import mark, raises import sqlalchemy as sa +from pytest import mark, raises + from sqlalchemy_utils.types import locale from tests import TestCase diff --git a/tests/types/test_numeric_range.py b/tests/types/test_numeric_range.py index 26ec82f..25923f6 100644 --- a/tests/types/test_numeric_range.py +++ b/tests/types/test_numeric_range.py @@ -1,16 +1,17 @@ from decimal import Decimal - -from pytest import mark import sqlalchemy as sa +from pytest import mark + +from sqlalchemy_utils import NumericRangeType +from tests import TestCase + intervals = None try: import intervals from infinity import inf except ImportError: pass -from tests import TestCase -from sqlalchemy_utils import NumericRangeType @mark.skipif('intervals is None') diff --git a/tests/types/test_password.py b/tests/types/test_password.py index 8f28133..474ad94 100644 --- a/tests/types/test_password.py +++ b/tests/types/test_password.py @@ -1,8 +1,9 @@ -from pytest import mark import sqlalchemy as sa -from tests import TestCase +from pytest import mark from sqlalchemy import inspect + from sqlalchemy_utils import Password, PasswordType, types # noqa +from tests import TestCase @mark.skipif('types.password.passlib is None') diff --git a/tests/types/test_phonenumber.py b/tests/types/test_phonenumber.py index fbeb1db..5f83571 100644 --- a/tests/types/test_phonenumber.py +++ b/tests/types/test_phonenumber.py @@ -2,8 +2,8 @@ import six import sqlalchemy as sa from pytest import mark +from sqlalchemy_utils import PhoneNumber, PhoneNumberType, types # noqa from tests import TestCase -from sqlalchemy_utils import PhoneNumberType, PhoneNumber, types # noqa @mark.skipif('types.phone_number.phonenumbers is None') diff --git a/tests/types/test_scalar_list.py b/tests/types/test_scalar_list.py index 89ce841..3f556fc 100644 --- a/tests/types/test_scalar_list.py +++ b/tests/types/test_scalar_list.py @@ -1,7 +1,8 @@ import six import sqlalchemy as sa -from sqlalchemy_utils import ScalarListType from pytest import raises + +from sqlalchemy_utils import ScalarListType from tests import TestCase diff --git a/tests/types/test_timezone.py b/tests/types/test_timezone.py index 0110be7..3d8a11c 100644 --- a/tests/types/test_timezone.py +++ b/tests/types/test_timezone.py @@ -1,4 +1,5 @@ import sqlalchemy as sa + from sqlalchemy_utils.types import timezone from tests import TestCase diff --git a/tests/types/test_tsvector.py b/tests/types/test_tsvector.py index bb5fda9..5a75a91 100644 --- a/tests/types/test_tsvector.py +++ b/tests/types/test_tsvector.py @@ -1,5 +1,6 @@ import sqlalchemy as sa from sqlalchemy.dialects.postgresql import TSVECTOR + from sqlalchemy_utils import TSVectorType from tests import TestCase diff --git a/tests/types/test_url.py b/tests/types/test_url.py index f23b1a8..63970d4 100644 --- a/tests/types/test_url.py +++ b/tests/types/test_url.py @@ -1,7 +1,7 @@ -from pytest import mark import sqlalchemy as sa -from sqlalchemy_utils.types import url +from pytest import mark +from sqlalchemy_utils.types import url from tests import TestCase diff --git a/tests/types/test_uuid.py b/tests/types/test_uuid.py index 5a1de10..5bc4437 100644 --- a/tests/types/test_uuid.py +++ b/tests/types/test_uuid.py @@ -1,8 +1,10 @@ -import sqlalchemy as sa -from tests import TestCase -from sqlalchemy_utils import UUIDType import uuid +import sqlalchemy as sa + +from sqlalchemy_utils import UUIDType +from tests import TestCase + class TestUUIDType(TestCase): def create_models(self): diff --git a/tests/types/test_weekdays.py b/tests/types/test_weekdays.py index afdedbb..d9c03d0 100644 --- a/tests/types/test_weekdays.py +++ b/tests/types/test_weekdays.py @@ -1,10 +1,10 @@ import pytest import sqlalchemy as sa + +from sqlalchemy_utils import i18n +from sqlalchemy_utils.primitives import WeekDays from sqlalchemy_utils.types import WeekDaysType from sqlalchemy_utils.types.weekdays import babel -from sqlalchemy_utils.primitives import WeekDays -from sqlalchemy_utils import i18n - from tests import TestCase