From d8814163e2e1552c1939828d0a784d0b23ad0e90 Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Wed, 12 Jun 2024 07:42:16 -0700 Subject: [PATCH] Sort imports with ruff --- .pre-commit-config.yaml | 2 +- docs_src/guides/access-domain/002.py | 2 +- docs_src/guides/composing-a-domain/011.py | 1 - docs_src/guides/domain-behavior/001.py | 4 ++-- docs_src/guides/domain-behavior/005.py | 1 - docs_src/guides/domain-behavior/006.py | 2 +- docs_src/guides/domain-behavior/007.py | 2 +- docs_src/guides/domain-behavior/008.py | 2 +- docs_src/guides/domain-behavior/009.py | 3 +-- docs_src/guides/domain-definition/events/001.py | 2 +- .../fields/association-fields/002.py | 2 +- .../domain-definition/fields/container-fields/004.py | 2 +- .../guides/domain-definition/fields/options/010.py | 1 + pyproject.toml | 3 +++ src/protean/adapters/broker/celery.py | 1 - src/protean/adapters/broker/redis.py | 1 - src/protean/adapters/cache/memory.py | 1 - src/protean/adapters/cache/redis.py | 1 - src/protean/adapters/event_store/__init__.py | 1 - src/protean/adapters/event_store/message_db.py | 1 - src/protean/adapters/repository/__init__.py | 1 - src/protean/adapters/repository/elasticsearch.py | 2 -- src/protean/adapters/repository/memory.py | 1 - src/protean/adapters/repository/sqlalchemy.py | 4 +--- src/protean/cli/__init__.py | 2 -- src/protean/cli/generate.py | 1 - src/protean/cli/new.py | 2 -- src/protean/cli/shell.py | 1 - src/protean/container.py | 1 - src/protean/core/command.py | 2 +- src/protean/core/domain_service.py | 3 +-- src/protean/core/entity.py | 3 +-- src/protean/core/event_sourced_aggregate.py | 1 - src/protean/core/event_sourced_repository.py | 2 +- src/protean/core/queryset.py | 7 +++---- src/protean/core/repository.py | 9 ++++----- src/protean/core/subscriber.py | 1 - src/protean/core/value_object.py | 1 - src/protean/domain/__init__.py | 1 - src/protean/domain/config.py | 2 +- src/protean/domain/registry.py | 1 - src/protean/fields/association.py | 2 +- src/protean/fields/base.py | 1 - src/protean/fields/basic.py | 2 -- src/protean/globals.py | 9 ++++----- src/protean/port/broker.py | 1 - src/protean/port/dao.py | 3 +-- src/protean/server/engine.py | 1 - src/protean/server/subscription.py | 1 - src/protean/utils/__init__.py | 3 +-- src/protean/utils/domain_discovery.py | 1 - src/protean/utils/mixins.py | 1 - .../adapters/broker/celery_broker/test_subscriber.py | 1 - tests/adapters/broker/celery_broker/tests.py | 1 - tests/adapters/broker/redis_broker/tests.py | 2 +- tests/adapters/cache/redis_cache/tests.py | 1 - tests/adapters/email/sendgrid_email/tests.py | 1 - tests/adapters/model/dict_model/elements.py | 1 - tests/adapters/model/elasticsearch_model/elements.py | 4 +--- tests/adapters/model/elasticsearch_model/tests.py | 1 - .../model/sqlalchemy_model/postgresql/elements.py | 1 - .../postgresql/test_array_datatype.py | 1 - .../postgresql/test_json_datatype.py | 1 - .../model/sqlalchemy_model/sqlite/elements.py | 1 - .../sqlalchemy_model/sqlite/test_array_datatype.py | 1 - .../sqlalchemy_model/sqlite/test_json_datatype.py | 1 - .../repository/elasticsearch_repo/elements.py | 1 - .../repository/elasticsearch_repo/test_dao.py | 1 - .../repository/elasticsearch_repo/test_provider.py | 1 - .../repository/elasticsearch_repo/test_query.py | 1 - .../sqlalchemy_repo/postgresql/elements.py | 1 - .../sqlalchemy_repo/postgresql/test_provider.py | 1 - .../repository/sqlalchemy_repo/sqlite/elements.py | 1 - .../sqlalchemy_repo/sqlite/test_provider.py | 1 - tests/adapters/repository/test_generic.py | 1 - tests/aggregate/test_aggregate_events.py | 2 +- tests/aggregate/test_aggregate_initialization.py | 4 ++-- tests/aggregate/test_atomic_change.py | 2 +- tests/cli/test_domain_loading.py | 1 - tests/cli/test_generate_docker_compose.py | 2 -- tests/cli/test_new.py | 2 -- tests/cli/test_server.py | 2 -- tests/cli/test_shell.py | 2 -- tests/config/test_load.py | 1 - tests/config/test_load_env_vars.py | 4 ++-- tests/config/test_replace_env_var.py | 4 +++- tests/domain/test_aggregate_cluster_assignment.py | 2 +- tests/domain/test_domain_config.py | 2 +- tests/domain/test_domain_identity_function.py | 2 +- tests/domain/test_domain_name.py | 1 - tests/domain/test_domain_shell_context.py | 1 - tests/domain/test_domain_traversal.py | 2 -- .../test_domain_service_as_callable_class.py | 8 ++++---- .../test_domain_service_as_instantiable_class.py | 8 ++++---- .../test_domain_service_with_class_methods.py | 8 ++++---- tests/domain_service/test_invariants_triggering.py | 8 ++++---- tests/domain_service/tests.py | 1 - tests/email_provider/tests.py | 1 - .../test_for_association_type_validation.py | 2 +- tests/entity/associations/test_has_many_filtering.py | 8 ++++---- tests/entity/associations/test_has_many_recursive.py | 6 +++--- .../associations/test_has_many_with_has_one.py | 2 +- .../test_has_many_with_has_one_with_has_one.py | 2 +- tests/entity/associations/test_has_one_recursive.py | 2 +- .../associations/test_has_one_with_has_many.py | 6 +++--- tests/entity/associations/test_multiple_has_many.py | 6 +++--- tests/entity/associations/test_multiple_has_one.py | 2 +- tests/entity/associations/test_owner_and_root.py | 2 +- tests/entity/invariants/test_invariant_decorator.py | 2 +- .../entity/invariants/test_invariant_triggerring.py | 8 ++++---- tests/entity/test_entity.py | 8 ++++---- .../entity/test_entity_aggregate_cluster_property.py | 2 +- tests/entity/test_lifecycle_methods.py | 2 +- .../test_automatic_id_field.py | 2 +- ...ing_multiple_events_for_one_aggregate_in_a_uow.py | 1 - tests/field/test_auto.py | 6 +++--- tests/field/test_choices.py | 4 ++-- tests/field/test_field_types.py | 1 - tests/field/test_list.py | 12 ++++++------ tests/reflection/test_id_field.py | 4 ++-- tests/repository/elements.py | 1 - tests/server/test_engine_run.py | 1 - tests/server/test_error_handling.py | 1 - tests/shared.py | 1 - tests/support/domains/test14/domain14.py | 1 - tests/support/domains/test15/domain15.py | 1 - tests/support/domains/test16/domain16.py | 1 - tests/support/domains/test17/domain17.py | 1 - tests/support/domains/test18/domain18.py | 1 - tests/support/domains/test19/domain19.py | 1 - tests/support/domains/test20/content/post20.py | 1 + tests/support/domains/test20/publishing20.py | 1 - tests/support/domains/test21/content/post21.py | 1 + tests/support/domains/test21/publishing21.py | 1 - .../domains/test22/src/publishing/domain22.py | 1 - .../domains/test23/src/publishing/domain23.py | 1 - tests/support/domains/test24/domain24.py | 1 - tests/test_aggregates.py | 2 +- tests/value_object/tests.py | 2 +- tests/views/tests.py | 4 ++-- 140 files changed, 115 insertions(+), 205 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8734090d..ef1b7443 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,6 @@ repos: hooks: # Run the linter. - id: ruff - args: [ --fix ] + args: [ "check", "--select", "I", "--fix" ] # Run the formatter. - id: ruff-format diff --git a/docs_src/guides/access-domain/002.py b/docs_src/guides/access-domain/002.py index 59da8a56..a0443179 100644 --- a/docs_src/guides/access-domain/002.py +++ b/docs_src/guides/access-domain/002.py @@ -2,8 +2,8 @@ from enum import Enum from protean import Domain, handle -from protean.globals import current_domain from protean.fields import DateTime, Identifier, String +from protean.globals import current_domain publishing = Domain(__file__, "Publishing", load_toml=False) diff --git a/docs_src/guides/composing-a-domain/011.py b/docs_src/guides/composing-a-domain/011.py index 3616172d..e4a31fbf 100644 --- a/docs_src/guides/composing-a-domain/011.py +++ b/docs_src/guides/composing-a-domain/011.py @@ -1,7 +1,6 @@ import uuid import sqlalchemy as sa - from sqlalchemy.dialects.postgresql import UUID from protean import Domain diff --git a/docs_src/guides/domain-behavior/001.py b/docs_src/guides/domain-behavior/001.py index 13002489..2d8cc827 100644 --- a/docs_src/guides/domain-behavior/001.py +++ b/docs_src/guides/domain-behavior/001.py @@ -1,9 +1,9 @@ -from enum import Enum from datetime import date +from enum import Enum from protean import Domain, invariant from protean.exceptions import ValidationError -from protean.fields import Date, Float, Identifier, Integer, String, HasMany +from protean.fields import Date, Float, HasMany, Identifier, Integer, String domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/domain-behavior/005.py b/docs_src/guides/domain-behavior/005.py index 21e2b609..cde4a2fb 100644 --- a/docs_src/guides/domain-behavior/005.py +++ b/docs_src/guides/domain-behavior/005.py @@ -3,7 +3,6 @@ from protean import Domain from protean.fields import String - domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/domain-behavior/006.py b/docs_src/guides/domain-behavior/006.py index c94f6109..df5098cf 100644 --- a/docs_src/guides/domain-behavior/006.py +++ b/docs_src/guides/domain-behavior/006.py @@ -6,9 +6,9 @@ from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, String, ValueObject, ) diff --git a/docs_src/guides/domain-behavior/007.py b/docs_src/guides/domain-behavior/007.py index c0d83ad4..8297aa33 100644 --- a/docs_src/guides/domain-behavior/007.py +++ b/docs_src/guides/domain-behavior/007.py @@ -6,9 +6,9 @@ from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, String, ValueObject, ) diff --git a/docs_src/guides/domain-behavior/008.py b/docs_src/guides/domain-behavior/008.py index b9cf554a..bd8c0d79 100644 --- a/docs_src/guides/domain-behavior/008.py +++ b/docs_src/guides/domain-behavior/008.py @@ -6,9 +6,9 @@ from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, String, ValueObject, ) diff --git a/docs_src/guides/domain-behavior/009.py b/docs_src/guides/domain-behavior/009.py index 778b92c4..80ac35c4 100644 --- a/docs_src/guides/domain-behavior/009.py +++ b/docs_src/guides/domain-behavior/009.py @@ -1,8 +1,7 @@ from datetime import datetime, timezone -from protean import Domain, invariant +from protean import Domain, fields, invariant from protean.exceptions import ValidationError -from protean import fields domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/domain-definition/events/001.py b/docs_src/guides/domain-definition/events/001.py index c2a7d61d..e2593600 100644 --- a/docs_src/guides/domain-definition/events/001.py +++ b/docs_src/guides/domain-definition/events/001.py @@ -1,7 +1,7 @@ from enum import Enum from protean import Domain -from protean.fields import String, Identifier +from protean.fields import Identifier, String domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/domain-definition/fields/association-fields/002.py b/docs_src/guides/domain-definition/fields/association-fields/002.py index 67fc8f51..b1c48230 100644 --- a/docs_src/guides/domain-definition/fields/association-fields/002.py +++ b/docs_src/guides/domain-definition/fields/association-fields/002.py @@ -1,5 +1,5 @@ from protean import Domain -from protean.fields import HasMany, Float, String, Text +from protean.fields import Float, HasMany, String, Text domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/domain-definition/fields/container-fields/004.py b/docs_src/guides/domain-definition/fields/container-fields/004.py index 6a42654e..e82529a6 100644 --- a/docs_src/guides/domain-definition/fields/container-fields/004.py +++ b/docs_src/guides/domain-definition/fields/container-fields/004.py @@ -1,5 +1,5 @@ from protean import Domain -from protean.fields import HasOne, String, List, ValueObject +from protean.fields import HasOne, List, String, ValueObject domain = Domain(__file__, load_toml=False) diff --git a/docs_src/guides/domain-definition/fields/options/010.py b/docs_src/guides/domain-definition/fields/options/010.py index 2359572b..5696d381 100644 --- a/docs_src/guides/domain-definition/fields/options/010.py +++ b/docs_src/guides/domain-definition/fields/options/010.py @@ -1,4 +1,5 @@ from typing import Any + from protean import Domain from protean.exceptions import ValidationError from protean.fields import String diff --git a/pyproject.toml b/pyproject.toml index 29c1e7dd..db937e46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -131,6 +131,9 @@ protean = "protean.cli:app" # Configurations # ################## +[tool.ruff.lint.isort] +known-first-party = ["protean"] + [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] diff --git a/src/protean/adapters/broker/celery.py b/src/protean/adapters/broker/celery.py index 26b79202..c62a31c5 100644 --- a/src/protean/adapters/broker/celery.py +++ b/src/protean/adapters/broker/celery.py @@ -1,6 +1,5 @@ import logging import logging.config - from collections.abc import Iterable from typing import Dict diff --git a/src/protean/adapters/broker/redis.py b/src/protean/adapters/broker/redis.py index a53cd3e6..a9943c4d 100644 --- a/src/protean/adapters/broker/redis.py +++ b/src/protean/adapters/broker/redis.py @@ -1,5 +1,4 @@ import json - from typing import TYPE_CHECKING, Dict import redis diff --git a/src/protean/adapters/cache/memory.py b/src/protean/adapters/cache/memory.py index 6cbd0c88..709a28cc 100644 --- a/src/protean/adapters/cache/memory.py +++ b/src/protean/adapters/cache/memory.py @@ -1,7 +1,6 @@ import collections import re import time - from threading import RLock from typing import Optional, Union diff --git a/src/protean/adapters/cache/redis.py b/src/protean/adapters/cache/redis.py index 12e8fb0f..dd7ee94f 100644 --- a/src/protean/adapters/cache/redis.py +++ b/src/protean/adapters/cache/redis.py @@ -1,5 +1,4 @@ import json - from typing import Optional, Union import redis diff --git a/src/protean/adapters/event_store/__init__.py b/src/protean/adapters/event_store/__init__.py index f4faa7b8..fcd1da67 100644 --- a/src/protean/adapters/event_store/__init__.py +++ b/src/protean/adapters/event_store/__init__.py @@ -1,6 +1,5 @@ import importlib import logging - from collections import defaultdict from typing import List, Optional, Type diff --git a/src/protean/adapters/event_store/message_db.py b/src/protean/adapters/event_store/message_db.py index 87e34476..84291e48 100644 --- a/src/protean/adapters/event_store/message_db.py +++ b/src/protean/adapters/event_store/message_db.py @@ -2,7 +2,6 @@ from urllib.parse import urlparse import psycopg2 - from message_db.client import MessageDB from protean.exceptions import ConfigurationError diff --git a/src/protean/adapters/repository/__init__.py b/src/protean/adapters/repository/__init__.py index 28d89bda..de414a77 100644 --- a/src/protean/adapters/repository/__init__.py +++ b/src/protean/adapters/repository/__init__.py @@ -3,7 +3,6 @@ import collections import importlib import logging - from collections import defaultdict from protean.core.repository import BaseRepository, repository_factory diff --git a/src/protean/adapters/repository/elasticsearch.py b/src/protean/adapters/repository/elasticsearch.py index 9a1f37f1..7f8e87e6 100644 --- a/src/protean/adapters/repository/elasticsearch.py +++ b/src/protean/adapters/repository/elasticsearch.py @@ -2,12 +2,10 @@ import json import logging - from typing import Any from uuid import UUID import elasticsearch_dsl - from elasticsearch import Elasticsearch from elasticsearch.exceptions import NotFoundError from elasticsearch_dsl import Document, Index, Keyword, Mapping, Search, query diff --git a/src/protean/adapters/repository/memory.py b/src/protean/adapters/repository/memory.py index d6d2565e..03054485 100644 --- a/src/protean/adapters/repository/memory.py +++ b/src/protean/adapters/repository/memory.py @@ -2,7 +2,6 @@ import copy import json - from collections import defaultdict from datetime import date, datetime from itertools import count diff --git a/src/protean/adapters/repository/sqlalchemy.py b/src/protean/adapters/repository/sqlalchemy.py index e7e1133d..4a1feb8f 100644 --- a/src/protean/adapters/repository/sqlalchemy.py +++ b/src/protean/adapters/repository/sqlalchemy.py @@ -4,12 +4,10 @@ import json import logging import uuid - from enum import Enum from typing import Any import sqlalchemy.dialects.postgresql as psql - from sqlalchemy import Column, MetaData, and_, create_engine, or_, orm, text from sqlalchemy import types as sa_types from sqlalchemy.engine.url import make_url @@ -17,9 +15,9 @@ from sqlalchemy.types import CHAR, TypeDecorator from protean.container import Options +from protean.core.model import BaseModel from protean.core.queryset import ResultSet from protean.core.value_object import BaseValueObject -from protean.core.model import BaseModel from protean.exceptions import ( ConfigurationError, ObjectNotFoundError, diff --git a/src/protean/cli/__init__.py b/src/protean/cli/__init__.py index b358c5a2..861b7e8d 100644 --- a/src/protean/cli/__init__.py +++ b/src/protean/cli/__init__.py @@ -17,12 +17,10 @@ import logging import subprocess - from enum import Enum from typing import Optional import typer - from rich import print from typing_extensions import Annotated diff --git a/src/protean/cli/generate.py b/src/protean/cli/generate.py index 3a8de8b1..ade2f6ca 100644 --- a/src/protean/cli/generate.py +++ b/src/protean/cli/generate.py @@ -1,7 +1,6 @@ import logging import typer - from typing_extensions import Annotated from protean.exceptions import NoDomainException diff --git a/src/protean/cli/new.py b/src/protean/cli/new.py index 6b6a70f1..fc9cf2fa 100644 --- a/src/protean/cli/new.py +++ b/src/protean/cli/new.py @@ -1,11 +1,9 @@ import os import re import shutil - from typing import List, Optional import typer - from copier import run_copy from typing_extensions import Annotated diff --git a/src/protean/cli/shell.py b/src/protean/cli/shell.py index 81ab3f5a..20e6abb2 100644 --- a/src/protean/cli/shell.py +++ b/src/protean/cli/shell.py @@ -15,7 +15,6 @@ import typing import typer - from IPython.terminal.embed import InteractiveShellEmbed from typing_extensions import Annotated diff --git a/src/protean/container.py b/src/protean/container.py index 48e4120e..4517f7ed 100644 --- a/src/protean/container.py +++ b/src/protean/container.py @@ -3,7 +3,6 @@ import copy import inspect import logging - from collections import defaultdict from typing import Any, Type, Union diff --git a/src/protean/core/command.py b/src/protean/core/command.py index 96b40d74..1beb8263 100644 --- a/src/protean/core/command.py +++ b/src/protean/core/command.py @@ -2,8 +2,8 @@ from protean.exceptions import ( IncorrectUsageError, InvalidDataError, - ValidationError, NotSupportedError, + ValidationError, ) from protean.fields import Field from protean.reflection import _ID_FIELD_NAME, declared_fields diff --git a/src/protean/core/domain_service.py b/src/protean/core/domain_service.py index 5d51b992..a20044d4 100644 --- a/src/protean/core/domain_service.py +++ b/src/protean/core/domain_service.py @@ -1,13 +1,12 @@ import inspect import logging - from collections import defaultdict from functools import wraps from typing import List, Union from protean import BaseAggregate from protean.container import Element, OptionsMixin -from protean.exceptions import IncorrectUsageError, ValidationError, NotSupportedError +from protean.exceptions import IncorrectUsageError, NotSupportedError, ValidationError from protean.utils import DomainObjects, derive_element_class logger = logging.getLogger(__name__) diff --git a/src/protean/core/entity.py b/src/protean/core/entity.py index 08e2e224..d3f928a5 100644 --- a/src/protean/core/entity.py +++ b/src/protean/core/entity.py @@ -4,7 +4,6 @@ import functools import inspect import logging - from collections import defaultdict from functools import partial @@ -12,7 +11,7 @@ from protean.exceptions import IncorrectUsageError, NotSupportedError, ValidationError from protean.fields import Auto, HasMany, Reference, ValueObject from protean.fields.association import Association -from protean.reflection import attributes, declared_fields, fields, id_field, _FIELDS +from protean.reflection import _FIELDS, attributes, declared_fields, fields, id_field from protean.utils import ( DomainObjects, derive_element_class, diff --git a/src/protean/core/event_sourced_aggregate.py b/src/protean/core/event_sourced_aggregate.py index 2b3115f9..66c4db9d 100644 --- a/src/protean/core/event_sourced_aggregate.py +++ b/src/protean/core/event_sourced_aggregate.py @@ -2,7 +2,6 @@ import inspect import logging import typing - from collections import defaultdict from typing import Dict diff --git a/src/protean/core/event_sourced_repository.py b/src/protean/core/event_sourced_repository.py index 35a0e241..e63057f7 100644 --- a/src/protean/core/event_sourced_repository.py +++ b/src/protean/core/event_sourced_repository.py @@ -4,8 +4,8 @@ from protean.container import Element, OptionsMixin from protean.exceptions import ( IncorrectUsageError, - ObjectNotFoundError, NotSupportedError, + ObjectNotFoundError, ) from protean.fields import Identifier from protean.globals import current_uow diff --git a/src/protean/core/queryset.py b/src/protean/core/queryset.py index a3db136c..3466d458 100644 --- a/src/protean/core/queryset.py +++ b/src/protean/core/queryset.py @@ -4,17 +4,16 @@ import copy import logging - -from typing import Any, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Union from protean.globals import current_uow from protean.utils import DomainObjects from protean.utils.query import Q if TYPE_CHECKING: - from protean.port.dao import BaseDAO - from protean.domain import Domain from protean.core.entity import BaseEntity + from protean.domain import Domain + from protean.port.dao import BaseDAO logger = logging.getLogger(__name__) diff --git a/src/protean/core/repository.py b/src/protean/core/repository.py index f6860eef..c9aa9aa1 100644 --- a/src/protean/core/repository.py +++ b/src/protean/core/repository.py @@ -1,19 +1,15 @@ from __future__ import annotations import logging - from functools import lru_cache from typing import TYPE_CHECKING -if TYPE_CHECKING: - from protean.domain import Domain - from protean.container import Element, OptionsMixin from protean.core.aggregate import BaseAggregate from protean.exceptions import IncorrectUsageError, NotSupportedError from protean.fields import HasMany, HasOne -from protean.port.provider import BaseProvider from protean.port.dao import BaseDAO +from protean.port.provider import BaseProvider from protean.reflection import association_fields, has_association_fields from protean.utils import ( Database, @@ -22,6 +18,9 @@ fully_qualified_name, ) +if TYPE_CHECKING: + from protean.domain import Domain + logger = logging.getLogger(__name__) diff --git a/src/protean/core/subscriber.py b/src/protean/core/subscriber.py index 49652cd9..9fc5f775 100644 --- a/src/protean/core/subscriber.py +++ b/src/protean/core/subscriber.py @@ -1,5 +1,4 @@ import logging - from abc import abstractmethod from typing import Any, Optional diff --git a/src/protean/core/value_object.py b/src/protean/core/value_object.py index 8fc37d3f..89bfbe85 100644 --- a/src/protean/core/value_object.py +++ b/src/protean/core/value_object.py @@ -2,7 +2,6 @@ import inspect import logging - from collections import defaultdict from protean.container import BaseContainer, OptionsMixin, fields diff --git a/src/protean/domain/__init__.py b/src/protean/domain/__init__.py index aaf1c15d..f77f6e1a 100644 --- a/src/protean/domain/__init__.py +++ b/src/protean/domain/__init__.py @@ -5,7 +5,6 @@ import inspect import logging import sys - from collections import defaultdict from functools import lru_cache from typing import Any, Callable, Dict, List, Optional, Tuple, Union diff --git a/src/protean/domain/config.py b/src/protean/domain/config.py index 1a5f9940..60c3377e 100644 --- a/src/protean/domain/config.py +++ b/src/protean/domain/config.py @@ -1,11 +1,11 @@ import logging import os import re + import tomllib from protean.exceptions import ConfigurationError - logger = logging.getLogger(__name__) diff --git a/src/protean/domain/registry.py b/src/protean/domain/registry.py index e96b4912..ffbd108f 100644 --- a/src/protean/domain/registry.py +++ b/src/protean/domain/registry.py @@ -1,5 +1,4 @@ import logging - from collections import defaultdict from enum import Enum from typing import Any, Dict diff --git a/src/protean/fields/association.py b/src/protean/fields/association.py index 174dcfa1..289aab60 100644 --- a/src/protean/fields/association.py +++ b/src/protean/fields/association.py @@ -3,7 +3,7 @@ from protean import exceptions, utils from protean.exceptions import ValidationError from protean.globals import current_domain -from protean.reflection import id_field, has_association_fields, association_fields +from protean.reflection import association_fields, has_association_fields, id_field from .base import Field, FieldBase from .mixins import FieldCacheMixin, FieldDescriptorMixin diff --git a/src/protean/fields/base.py b/src/protean/fields/base.py index ddedb181..98905340 100644 --- a/src/protean/fields/base.py +++ b/src/protean/fields/base.py @@ -1,7 +1,6 @@ """Module for defining base Field class""" import enum - from abc import ABCMeta, abstractmethod from collections import defaultdict from typing import Any, Callable, Iterable, List diff --git a/src/protean/fields/basic.py b/src/protean/fields/basic.py index 17da3d98..d50dcb99 100644 --- a/src/protean/fields/basic.py +++ b/src/protean/fields/basic.py @@ -1,11 +1,9 @@ """Module for defining basic Field types of Entity""" import datetime - from uuid import UUID import bleach - from dateutil.parser import parse as date_parser from protean.exceptions import InvalidOperationError, ValidationError diff --git a/src/protean/globals.py b/src/protean/globals.py index 605ad0fd..f6d57c89 100644 --- a/src/protean/globals.py +++ b/src/protean/globals.py @@ -1,16 +1,15 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any - -if TYPE_CHECKING: - from protean import Domain, UnitOfWork - from functools import partial +from typing import TYPE_CHECKING, Any from werkzeug.local import LocalProxy, LocalStack from protean.exceptions import OutOfContextError +if TYPE_CHECKING: + from protean import Domain, UnitOfWork + _domain_ctx_err_msg = """\ Working outside of domain context. This typically means that you attempted to use functionality that needed diff --git a/src/protean/port/broker.py b/src/protean/port/broker.py index fe747e76..70fcabdf 100644 --- a/src/protean/port/broker.py +++ b/src/protean/port/broker.py @@ -2,7 +2,6 @@ import logging import logging.config - from abc import ABCMeta, abstractmethod from collections import defaultdict from collections.abc import Iterable diff --git a/src/protean/port/dao.py b/src/protean/port/dao.py index 8812f3ff..84a0bd59 100644 --- a/src/protean/port/dao.py +++ b/src/protean/port/dao.py @@ -1,9 +1,8 @@ from __future__ import annotations import logging - from abc import ABCMeta, abstractmethod -from typing import Any, TYPE_CHECKING +from typing import TYPE_CHECKING, Any from protean.core.entity import BaseEntity from protean.core.model import BaseModel diff --git a/src/protean/server/engine.py b/src/protean/server/engine.py index 56ae0894..88253d2e 100644 --- a/src/protean/server/engine.py +++ b/src/protean/server/engine.py @@ -4,7 +4,6 @@ import logging import signal import traceback - from typing import Type, Union from protean.core.command_handler import BaseCommandHandler diff --git a/src/protean/server/subscription.py b/src/protean/server/subscription.py index 022a6d28..a459a93a 100644 --- a/src/protean/server/subscription.py +++ b/src/protean/server/subscription.py @@ -1,6 +1,5 @@ import asyncio import logging - from typing import List, Union from protean import BaseCommandHandler, BaseEventHandler diff --git a/src/protean/utils/__init__.py b/src/protean/utils/__init__.py index 1b778e05..026d3dad 100644 --- a/src/protean/utils/__init__.py +++ b/src/protean/utils/__init__.py @@ -7,10 +7,9 @@ import functools import importlib import logging - from datetime import UTC, datetime from enum import Enum -from typing import Callable, Any +from typing import Any, Callable from uuid import uuid4 from protean.exceptions import ConfigurationError diff --git a/src/protean/utils/domain_discovery.py b/src/protean/utils/domain_discovery.py index c1adde02..5fe91d18 100644 --- a/src/protean/utils/domain_discovery.py +++ b/src/protean/utils/domain_discovery.py @@ -4,7 +4,6 @@ import re import sys import traceback - from types import ModuleType from protean import Domain diff --git a/src/protean/utils/mixins.py b/src/protean/utils/mixins.py index ab14bd19..8def8dca 100644 --- a/src/protean/utils/mixins.py +++ b/src/protean/utils/mixins.py @@ -2,7 +2,6 @@ import functools import logging - from collections import defaultdict from enum import Enum from typing import Callable, Dict, Union diff --git a/tests/adapters/broker/celery_broker/test_subscriber.py b/tests/adapters/broker/celery_broker/test_subscriber.py index 62c76c0b..1050ada2 100644 --- a/tests/adapters/broker/celery_broker/test_subscriber.py +++ b/tests/adapters/broker/celery_broker/test_subscriber.py @@ -1,5 +1,4 @@ import pytest - from celery import Task from protean.adapters.broker.celery import CeleryBroker, ProteanTask diff --git a/tests/adapters/broker/celery_broker/tests.py b/tests/adapters/broker/celery_broker/tests.py index ec084589..33aa87b1 100644 --- a/tests/adapters/broker/celery_broker/tests.py +++ b/tests/adapters/broker/celery_broker/tests.py @@ -1,5 +1,4 @@ import pytest - from mock import patch from protean.adapters.broker.celery import CeleryBroker diff --git a/tests/adapters/broker/redis_broker/tests.py b/tests/adapters/broker/redis_broker/tests.py index 871a439a..664bcbfe 100644 --- a/tests/adapters/broker/redis_broker/tests.py +++ b/tests/adapters/broker/redis_broker/tests.py @@ -6,7 +6,7 @@ from protean.adapters.broker.redis import RedisBroker from protean.globals import current_domain -from .elements import PersonAdded, Person +from .elements import Person, PersonAdded @pytest.fixture(autouse=True) diff --git a/tests/adapters/cache/redis_cache/tests.py b/tests/adapters/cache/redis_cache/tests.py index 2a7e9352..21126bf5 100644 --- a/tests/adapters/cache/redis_cache/tests.py +++ b/tests/adapters/cache/redis_cache/tests.py @@ -2,7 +2,6 @@ import time import pytest - from redis import Redis from protean import BaseView diff --git a/tests/adapters/email/sendgrid_email/tests.py b/tests/adapters/email/sendgrid_email/tests.py index 71aba28d..96e3c2f3 100644 --- a/tests/adapters/email/sendgrid_email/tests.py +++ b/tests/adapters/email/sendgrid_email/tests.py @@ -1,5 +1,4 @@ import pytest - from mock import patch from protean.adapters.email.sendgrid import SendgridEmailProvider diff --git a/tests/adapters/model/dict_model/elements.py b/tests/adapters/model/dict_model/elements.py index a1acd819..dc52a5dd 100644 --- a/tests/adapters/model/dict_model/elements.py +++ b/tests/adapters/model/dict_model/elements.py @@ -1,5 +1,4 @@ import re - from typing import List from protean import BaseAggregate, BaseModel, BaseRepository, BaseValueObject, invariant diff --git a/tests/adapters/model/elasticsearch_model/elements.py b/tests/adapters/model/elasticsearch_model/elements.py index 5eaf2bd5..e04076cb 100644 --- a/tests/adapters/model/elasticsearch_model/elements.py +++ b/tests/adapters/model/elasticsearch_model/elements.py @@ -1,5 +1,4 @@ import re - from datetime import datetime from elasticsearch_dsl import Keyword, Text @@ -7,9 +6,8 @@ from protean import BaseAggregate, BaseValueObject, invariant from protean.core.model import BaseModel from protean.exceptions import ValidationError -from protean.fields import DateTime, Integer, String +from protean.fields import DateTime, Integer, String, ValueObject from protean.fields import Text as ProteanText -from protean.fields import ValueObject class Person(BaseAggregate): diff --git a/tests/adapters/model/elasticsearch_model/tests.py b/tests/adapters/model/elasticsearch_model/tests.py index d0479af4..c3062e09 100644 --- a/tests/adapters/model/elasticsearch_model/tests.py +++ b/tests/adapters/model/elasticsearch_model/tests.py @@ -1,5 +1,4 @@ import pytest - from elasticsearch_dsl import Keyword, Text from protean import BaseAggregate diff --git a/tests/adapters/model/sqlalchemy_model/postgresql/elements.py b/tests/adapters/model/sqlalchemy_model/postgresql/elements.py index 2b9692fd..84895ece 100644 --- a/tests/adapters/model/sqlalchemy_model/postgresql/elements.py +++ b/tests/adapters/model/sqlalchemy_model/postgresql/elements.py @@ -1,5 +1,4 @@ import re - from datetime import datetime from sqlalchemy import Column, Text diff --git a/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py b/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py index 1db538cb..74697c2c 100644 --- a/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py +++ b/tests/adapters/model/sqlalchemy_model/postgresql/test_array_datatype.py @@ -1,7 +1,6 @@ from datetime import UTC, datetime import pytest - from sqlalchemy import types as sa_types from protean import BaseAggregate diff --git a/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py b/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py index df2290a9..efbc3fd7 100644 --- a/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py +++ b/tests/adapters/model/sqlalchemy_model/postgresql/test_json_datatype.py @@ -1,5 +1,4 @@ import pytest - from sqlalchemy import types as sa_types from protean import BaseAggregate diff --git a/tests/adapters/model/sqlalchemy_model/sqlite/elements.py b/tests/adapters/model/sqlalchemy_model/sqlite/elements.py index 04f5203d..4b45bed3 100644 --- a/tests/adapters/model/sqlalchemy_model/sqlite/elements.py +++ b/tests/adapters/model/sqlalchemy_model/sqlite/elements.py @@ -1,5 +1,4 @@ import re - from datetime import datetime from sqlalchemy import Column, Text diff --git a/tests/adapters/model/sqlalchemy_model/sqlite/test_array_datatype.py b/tests/adapters/model/sqlalchemy_model/sqlite/test_array_datatype.py index c5797214..75d67183 100644 --- a/tests/adapters/model/sqlalchemy_model/sqlite/test_array_datatype.py +++ b/tests/adapters/model/sqlalchemy_model/sqlite/test_array_datatype.py @@ -1,7 +1,6 @@ from datetime import UTC, datetime import pytest - from sqlalchemy import types as sa_types from protean import BaseAggregate diff --git a/tests/adapters/model/sqlalchemy_model/sqlite/test_json_datatype.py b/tests/adapters/model/sqlalchemy_model/sqlite/test_json_datatype.py index b7a8acab..df5821e8 100644 --- a/tests/adapters/model/sqlalchemy_model/sqlite/test_json_datatype.py +++ b/tests/adapters/model/sqlalchemy_model/sqlite/test_json_datatype.py @@ -1,5 +1,4 @@ import pytest - from sqlalchemy import types as sa_types from protean import BaseAggregate diff --git a/tests/adapters/repository/elasticsearch_repo/elements.py b/tests/adapters/repository/elasticsearch_repo/elements.py index b621959a..87bec441 100644 --- a/tests/adapters/repository/elasticsearch_repo/elements.py +++ b/tests/adapters/repository/elasticsearch_repo/elements.py @@ -1,5 +1,4 @@ import re - from datetime import datetime from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant diff --git a/tests/adapters/repository/elasticsearch_repo/test_dao.py b/tests/adapters/repository/elasticsearch_repo/test_dao.py index 8d158d46..c52d085e 100644 --- a/tests/adapters/repository/elasticsearch_repo/test_dao.py +++ b/tests/adapters/repository/elasticsearch_repo/test_dao.py @@ -2,7 +2,6 @@ from uuid import uuid4 import pytest - from elasticsearch import Elasticsearch from protean import Q, QuerySet diff --git a/tests/adapters/repository/elasticsearch_repo/test_provider.py b/tests/adapters/repository/elasticsearch_repo/test_provider.py index 990a3116..7e3c261b 100644 --- a/tests/adapters/repository/elasticsearch_repo/test_provider.py +++ b/tests/adapters/repository/elasticsearch_repo/test_provider.py @@ -1,7 +1,6 @@ """Module to test SQLAlchemy Provider Class""" import pytest - from elasticsearch import Elasticsearch from elasticsearch_dsl.response import Response diff --git a/tests/adapters/repository/elasticsearch_repo/test_query.py b/tests/adapters/repository/elasticsearch_repo/test_query.py index eb4059d0..004c76ed 100644 --- a/tests/adapters/repository/elasticsearch_repo/test_query.py +++ b/tests/adapters/repository/elasticsearch_repo/test_query.py @@ -1,5 +1,4 @@ import pytest - from elasticsearch_dsl.query import Bool, Term from .elements import Person diff --git a/tests/adapters/repository/sqlalchemy_repo/postgresql/elements.py b/tests/adapters/repository/sqlalchemy_repo/postgresql/elements.py index b621959a..87bec441 100644 --- a/tests/adapters/repository/sqlalchemy_repo/postgresql/elements.py +++ b/tests/adapters/repository/sqlalchemy_repo/postgresql/elements.py @@ -1,5 +1,4 @@ import re - from datetime import datetime from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant diff --git a/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py b/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py index 1676a206..fef81866 100644 --- a/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py +++ b/tests/adapters/repository/sqlalchemy_repo/postgresql/test_provider.py @@ -1,7 +1,6 @@ """Module to test SQLAlchemy Provider Class""" import pytest - from sqlalchemy.engine.result import Result from sqlalchemy.orm.session import Session diff --git a/tests/adapters/repository/sqlalchemy_repo/sqlite/elements.py b/tests/adapters/repository/sqlalchemy_repo/sqlite/elements.py index b621959a..87bec441 100644 --- a/tests/adapters/repository/sqlalchemy_repo/sqlite/elements.py +++ b/tests/adapters/repository/sqlalchemy_repo/sqlite/elements.py @@ -1,5 +1,4 @@ import re - from datetime import datetime from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant diff --git a/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py b/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py index c1c14440..052eb60c 100644 --- a/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py +++ b/tests/adapters/repository/sqlalchemy_repo/sqlite/test_provider.py @@ -1,7 +1,6 @@ """Module to test SQLAlchemy Provider Class""" import pytest - from sqlalchemy.engine.result import Result from sqlalchemy.orm.session import Session diff --git a/tests/adapters/repository/test_generic.py b/tests/adapters/repository/test_generic.py index 038f4473..864d15c5 100644 --- a/tests/adapters/repository/test_generic.py +++ b/tests/adapters/repository/test_generic.py @@ -1,5 +1,4 @@ import re - from typing import List from uuid import uuid4 diff --git a/tests/aggregate/test_aggregate_events.py b/tests/aggregate/test_aggregate_events.py index c523c24b..87e70c37 100644 --- a/tests/aggregate/test_aggregate_events.py +++ b/tests/aggregate/test_aggregate_events.py @@ -4,7 +4,7 @@ from protean import BaseAggregate, BaseEntity, BaseEvent from protean.core.unit_of_work import UnitOfWork -from protean.fields import Identifier, String, HasOne +from protean.fields import HasOne, Identifier, String from protean.globals import current_domain diff --git a/tests/aggregate/test_aggregate_initialization.py b/tests/aggregate/test_aggregate_initialization.py index dbd1d79a..82b68382 100644 --- a/tests/aggregate/test_aggregate_initialization.py +++ b/tests/aggregate/test_aggregate_initialization.py @@ -3,8 +3,8 @@ import pytest -from protean import BaseEntity, BaseAggregate -from protean.exceptions import ValidationError, NotSupportedError +from protean import BaseAggregate, BaseEntity +from protean.exceptions import NotSupportedError, ValidationError from protean.reflection import attributes, declared_fields from protean.utils import fully_qualified_name diff --git a/tests/aggregate/test_atomic_change.py b/tests/aggregate/test_atomic_change.py index 75ffe5c6..787c4af3 100644 --- a/tests/aggregate/test_atomic_change.py +++ b/tests/aggregate/test_atomic_change.py @@ -3,8 +3,8 @@ import pytest from protean import BaseAggregate, atomic_change, invariant -from protean.fields import Integer from protean.exceptions import ValidationError +from protean.fields import Integer class TestAtomicChange: diff --git a/tests/cli/test_domain_loading.py b/tests/cli/test_domain_loading.py index 58ab5f7f..2f5a701d 100644 --- a/tests/cli/test_domain_loading.py +++ b/tests/cli/test_domain_loading.py @@ -2,7 +2,6 @@ import os import sys - from pathlib import Path import pytest diff --git a/tests/cli/test_generate_docker_compose.py b/tests/cli/test_generate_docker_compose.py index b6713128..ad8ad55b 100644 --- a/tests/cli/test_generate_docker_compose.py +++ b/tests/cli/test_generate_docker_compose.py @@ -1,10 +1,8 @@ import os import sys - from pathlib import Path import pytest - from typer.testing import CliRunner from protean.cli import derive_domain diff --git a/tests/cli/test_new.py b/tests/cli/test_new.py index ac6f86ec..5bb7b62c 100644 --- a/tests/cli/test_new.py +++ b/tests/cli/test_new.py @@ -1,9 +1,7 @@ import os - from pathlib import Path import pytest - from typer.testing import CliRunner from protean.cli import app diff --git a/tests/cli/test_server.py b/tests/cli/test_server.py index 2a9d2c74..c014142a 100644 --- a/tests/cli/test_server.py +++ b/tests/cli/test_server.py @@ -1,10 +1,8 @@ import os import sys - from pathlib import Path import pytest - from typer.testing import CliRunner from protean.cli import app diff --git a/tests/cli/test_shell.py b/tests/cli/test_shell.py index d7a52f1a..5d01cb39 100644 --- a/tests/cli/test_shell.py +++ b/tests/cli/test_shell.py @@ -1,10 +1,8 @@ import os import sys - from pathlib import Path import pytest - from typer.testing import CliRunner from protean.cli import app diff --git a/tests/config/test_load.py b/tests/config/test_load.py index 732b691f..dd01d218 100644 --- a/tests/config/test_load.py +++ b/tests/config/test_load.py @@ -2,7 +2,6 @@ import os import sys - from pathlib import Path import pytest diff --git a/tests/config/test_load_env_vars.py b/tests/config/test_load_env_vars.py index e633b026..d6bf2025 100644 --- a/tests/config/test_load_env_vars.py +++ b/tests/config/test_load_env_vars.py @@ -1,10 +1,10 @@ import os + import pytest +from mock import patch from protean.domain.config import Config2 from protean.exceptions import ConfigurationError -from mock import patch - from protean.utils.domain_discovery import derive_domain from tests.shared import change_working_directory_to diff --git a/tests/config/test_replace_env_var.py b/tests/config/test_replace_env_var.py index 3ae9189d..495eeec4 100644 --- a/tests/config/test_replace_env_var.py +++ b/tests/config/test_replace_env_var.py @@ -1,7 +1,9 @@ import os + import pytest -from protean.domain.config import Config2 from mock import patch + +from protean.domain.config import Config2 from protean.exceptions import ConfigurationError diff --git a/tests/domain/test_aggregate_cluster_assignment.py b/tests/domain/test_aggregate_cluster_assignment.py index 4e3e6bab..a224fd92 100644 --- a/tests/domain/test_aggregate_cluster_assignment.py +++ b/tests/domain/test_aggregate_cluster_assignment.py @@ -2,8 +2,8 @@ from protean import ( BaseAggregate, - BaseEntity, BaseCommand, + BaseEntity, BaseEvent, BaseEventSourcedAggregate, ) diff --git a/tests/domain/test_domain_config.py b/tests/domain/test_domain_config.py index da682f56..be669dd7 100644 --- a/tests/domain/test_domain_config.py +++ b/tests/domain/test_domain_config.py @@ -1,6 +1,6 @@ import pytest -from protean import Domain, BaseAggregate +from protean import BaseAggregate, Domain from protean.exceptions import ConfigurationError from protean.fields import Auto diff --git a/tests/domain/test_domain_identity_function.py b/tests/domain/test_domain_identity_function.py index ed3b22a3..0bf90c0a 100644 --- a/tests/domain/test_domain_identity_function.py +++ b/tests/domain/test_domain_identity_function.py @@ -2,7 +2,7 @@ import re import time -from protean import Domain, BaseAggregate +from protean import BaseAggregate, Domain from protean.fields import Auto diff --git a/tests/domain/test_domain_name.py b/tests/domain/test_domain_name.py index 3ce2deb7..af2b145d 100644 --- a/tests/domain/test_domain_name.py +++ b/tests/domain/test_domain_name.py @@ -1,6 +1,5 @@ import os import sys - from pathlib import Path import pytest diff --git a/tests/domain/test_domain_shell_context.py b/tests/domain/test_domain_shell_context.py index 550e2c3d..7b954aa8 100644 --- a/tests/domain/test_domain_shell_context.py +++ b/tests/domain/test_domain_shell_context.py @@ -1,6 +1,5 @@ import os import sys - from pathlib import Path import pytest diff --git a/tests/domain/test_domain_traversal.py b/tests/domain/test_domain_traversal.py index b6db3d07..f9abae7b 100644 --- a/tests/domain/test_domain_traversal.py +++ b/tests/domain/test_domain_traversal.py @@ -1,12 +1,10 @@ import os import sys - from pathlib import Path import pytest from protean.utils.domain_discovery import derive_domain - from tests.shared import change_working_directory_to diff --git a/tests/domain_service/test_domain_service_as_callable_class.py b/tests/domain_service/test_domain_service_as_callable_class.py index dd20731f..4d9d9fbe 100644 --- a/tests/domain_service/test_domain_service_as_callable_class.py +++ b/tests/domain_service/test_domain_service_as_callable_class.py @@ -1,24 +1,24 @@ -import pytest - from datetime import datetime, timezone from enum import Enum from uuid import uuid4 +import pytest + from protean import ( BaseAggregate, BaseDomainService, + BaseEntity, BaseEvent, BaseValueObject, - BaseEntity, invariant, ) from protean.exceptions import ValidationError from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, String, ValueObject, ) diff --git a/tests/domain_service/test_domain_service_as_instantiable_class.py b/tests/domain_service/test_domain_service_as_instantiable_class.py index bdac126b..e6d19a57 100644 --- a/tests/domain_service/test_domain_service_as_instantiable_class.py +++ b/tests/domain_service/test_domain_service_as_instantiable_class.py @@ -1,24 +1,24 @@ -import pytest - from datetime import datetime, timezone from enum import Enum from uuid import uuid4 +import pytest + from protean import ( BaseAggregate, BaseDomainService, + BaseEntity, BaseEvent, BaseValueObject, - BaseEntity, invariant, ) from protean.exceptions import ValidationError from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, String, ValueObject, ) diff --git a/tests/domain_service/test_domain_service_with_class_methods.py b/tests/domain_service/test_domain_service_with_class_methods.py index 15814c45..53a7f508 100644 --- a/tests/domain_service/test_domain_service_with_class_methods.py +++ b/tests/domain_service/test_domain_service_with_class_methods.py @@ -1,22 +1,22 @@ -import pytest - from datetime import datetime, timezone from enum import Enum from uuid import uuid4 +import pytest + from protean import ( BaseAggregate, BaseDomainService, + BaseEntity, BaseEvent, BaseValueObject, - BaseEntity, ) from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, String, ValueObject, ) diff --git a/tests/domain_service/test_invariants_triggering.py b/tests/domain_service/test_invariants_triggering.py index 13ddc0ef..b7fe82e9 100644 --- a/tests/domain_service/test_invariants_triggering.py +++ b/tests/domain_service/test_invariants_triggering.py @@ -1,24 +1,24 @@ -import pytest - from datetime import datetime, timezone from enum import Enum from uuid import uuid4 +import pytest + from protean import ( BaseAggregate, BaseDomainService, + BaseEntity, BaseEvent, BaseValueObject, - BaseEntity, invariant, ) from protean.exceptions import ValidationError from protean.fields import ( DateTime, Float, + HasMany, Identifier, Integer, - HasMany, List, String, ValueObject, diff --git a/tests/domain_service/tests.py b/tests/domain_service/tests.py index 6f7050b4..a725bdee 100644 --- a/tests/domain_service/tests.py +++ b/tests/domain_service/tests.py @@ -1,7 +1,6 @@ import mock import pytest - from protean import BaseAggregate, BaseDomainService from protean.core import domain_service from protean.exceptions import IncorrectUsageError, NotSupportedError diff --git a/tests/email_provider/tests.py b/tests/email_provider/tests.py index 8580343f..9d399ea1 100644 --- a/tests/email_provider/tests.py +++ b/tests/email_provider/tests.py @@ -1,5 +1,4 @@ import pytest - from mock import patch from protean import BaseEmail diff --git a/tests/entity/associations/test_for_association_type_validation.py b/tests/entity/associations/test_for_association_type_validation.py index df51f537..9c9cc042 100644 --- a/tests/entity/associations/test_for_association_type_validation.py +++ b/tests/entity/associations/test_for_association_type_validation.py @@ -2,7 +2,7 @@ from protean import BaseAggregate, BaseEntity from protean.exceptions import ValidationError -from protean.fields import Integer, String, HasOne, HasMany +from protean.fields import HasMany, HasOne, Integer, String class University(BaseAggregate): diff --git a/tests/entity/associations/test_has_many_filtering.py b/tests/entity/associations/test_has_many_filtering.py index e1cf0150..b3dac2c4 100644 --- a/tests/entity/associations/test_has_many_filtering.py +++ b/tests/entity/associations/test_has_many_filtering.py @@ -1,10 +1,10 @@ -import pytest - from datetime import datetime -from protean import BaseEntity, BaseAggregate +import pytest + +from protean import BaseAggregate, BaseEntity from protean.exceptions import ObjectNotFoundError, TooManyObjectsError -from protean.fields import Date, Float, Integer, String, HasMany +from protean.fields import Date, Float, HasMany, Integer, String class Order(BaseAggregate): diff --git a/tests/entity/associations/test_has_many_recursive.py b/tests/entity/associations/test_has_many_recursive.py index d95cea57..c1107793 100644 --- a/tests/entity/associations/test_has_many_recursive.py +++ b/tests/entity/associations/test_has_many_recursive.py @@ -1,9 +1,9 @@ -import pytest - from datetime import datetime, timedelta +import pytest + from protean import BaseAggregate, BaseEntity -from protean.fields import Date, Float, Identifier, String, HasMany +from protean.fields import Date, Float, HasMany, Identifier, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_has_many_with_has_one.py b/tests/entity/associations/test_has_many_with_has_one.py index 8cc3e40c..186ff6a0 100644 --- a/tests/entity/associations/test_has_many_with_has_one.py +++ b/tests/entity/associations/test_has_many_with_has_one.py @@ -1,7 +1,7 @@ import pytest from protean import BaseAggregate, BaseEntity -from protean.fields import Integer, String, HasOne, HasMany +from protean.fields import HasMany, HasOne, Integer, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_has_many_with_has_one_with_has_one.py b/tests/entity/associations/test_has_many_with_has_one_with_has_one.py index e065f6dd..bb8f9c00 100644 --- a/tests/entity/associations/test_has_many_with_has_one_with_has_one.py +++ b/tests/entity/associations/test_has_many_with_has_one_with_has_one.py @@ -1,7 +1,7 @@ import pytest from protean import BaseAggregate, BaseEntity -from protean.fields import Integer, String, HasOne, HasMany +from protean.fields import HasMany, HasOne, Integer, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_has_one_recursive.py b/tests/entity/associations/test_has_one_recursive.py index 13fb0a29..5be03a8a 100644 --- a/tests/entity/associations/test_has_one_recursive.py +++ b/tests/entity/associations/test_has_one_recursive.py @@ -1,7 +1,7 @@ import pytest from protean import BaseAggregate, BaseEntity -from protean.fields import Integer, String, HasOne +from protean.fields import HasOne, Integer, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_has_one_with_has_many.py b/tests/entity/associations/test_has_one_with_has_many.py index 399c50eb..aba47b99 100644 --- a/tests/entity/associations/test_has_one_with_has_many.py +++ b/tests/entity/associations/test_has_one_with_has_many.py @@ -1,9 +1,9 @@ -import pytest - from datetime import datetime, timedelta +import pytest + from protean import BaseAggregate, BaseEntity -from protean.fields import Date, Float, Integer, String, HasOne, HasMany +from protean.fields import Date, Float, HasMany, HasOne, Integer, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_multiple_has_many.py b/tests/entity/associations/test_multiple_has_many.py index 620e4bc3..3544a08d 100644 --- a/tests/entity/associations/test_multiple_has_many.py +++ b/tests/entity/associations/test_multiple_has_many.py @@ -1,9 +1,9 @@ -import pytest - from datetime import datetime, timedelta +import pytest + from protean import BaseAggregate, BaseEntity -from protean.fields import Date, String, HasMany +from protean.fields import Date, HasMany, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_multiple_has_one.py b/tests/entity/associations/test_multiple_has_one.py index 4eeabe5c..77bcd3ef 100644 --- a/tests/entity/associations/test_multiple_has_one.py +++ b/tests/entity/associations/test_multiple_has_one.py @@ -1,6 +1,6 @@ import pytest -from protean import BaseEntity, BaseAggregate +from protean import BaseAggregate, BaseEntity from protean.fields import HasOne, Integer, String from protean.reflection import declared_fields diff --git a/tests/entity/associations/test_owner_and_root.py b/tests/entity/associations/test_owner_and_root.py index 1b35f18c..d1bd88e9 100644 --- a/tests/entity/associations/test_owner_and_root.py +++ b/tests/entity/associations/test_owner_and_root.py @@ -1,7 +1,7 @@ import pytest from protean import BaseAggregate, BaseEntity -from protean.fields import Integer, String, HasOne, HasMany +from protean.fields import HasMany, HasOne, Integer, String class University(BaseAggregate): diff --git a/tests/entity/invariants/test_invariant_decorator.py b/tests/entity/invariants/test_invariant_decorator.py index 6f7e8c63..c6305ea7 100644 --- a/tests/entity/invariants/test_invariant_decorator.py +++ b/tests/entity/invariants/test_invariant_decorator.py @@ -3,7 +3,7 @@ from protean import BaseAggregate, BaseEntity, invariant from protean.exceptions import ValidationError -from protean.fields import Date, Float, Integer, String, HasMany +from protean.fields import Date, Float, HasMany, Integer, String class OrderStatus(Enum): diff --git a/tests/entity/invariants/test_invariant_triggerring.py b/tests/entity/invariants/test_invariant_triggerring.py index 91a6e083..c33c70db 100644 --- a/tests/entity/invariants/test_invariant_triggerring.py +++ b/tests/entity/invariants/test_invariant_triggerring.py @@ -1,11 +1,11 @@ -import pytest - from datetime import date, datetime from enum import Enum -from protean import BaseAggregate, BaseEntity, invariant, atomic_change +import pytest + +from protean import BaseAggregate, BaseEntity, atomic_change, invariant from protean.exceptions import ValidationError -from protean.fields import Date, Float, Identifier, Integer, String, HasMany +from protean.fields import Date, Float, HasMany, Identifier, Integer, String class OrderStatus(Enum): diff --git a/tests/entity/test_entity.py b/tests/entity/test_entity.py index 7fc2a3e5..c7cf767c 100644 --- a/tests/entity/test_entity.py +++ b/tests/entity/test_entity.py @@ -5,17 +5,17 @@ from protean.reflection import attributes, declared_fields from .elements import ( - Account, AbstractPerson, + Account, + Adult, ConcretePerson, + DbPerson, + DifferentDbPerson, Person, PersonAutoSSN, Relative, SqlDifferentDbPerson, SqlPerson, - DbPerson, - DifferentDbPerson, - Adult, ) diff --git a/tests/entity/test_entity_aggregate_cluster_property.py b/tests/entity/test_entity_aggregate_cluster_property.py index 76d56d1c..a39f7072 100644 --- a/tests/entity/test_entity_aggregate_cluster_property.py +++ b/tests/entity/test_entity_aggregate_cluster_property.py @@ -1,7 +1,7 @@ import pytest from protean import BaseAggregate, BaseEntity -from protean.fields import Integer, String, HasOne, HasMany +from protean.fields import HasMany, HasOne, Integer, String class University(BaseAggregate): diff --git a/tests/entity/test_lifecycle_methods.py b/tests/entity/test_lifecycle_methods.py index 58455649..da5a04bf 100644 --- a/tests/entity/test_lifecycle_methods.py +++ b/tests/entity/test_lifecycle_methods.py @@ -1,8 +1,8 @@ import pytest from protean import BaseEntity -from protean.fields import String from protean.exceptions import ValidationError +from protean.fields import String from .elements import Area, Building, BuildingStatus diff --git a/tests/event_sourced_aggregates/test_automatic_id_field.py b/tests/event_sourced_aggregates/test_automatic_id_field.py index e23d7d29..65ab95fb 100644 --- a/tests/event_sourced_aggregates/test_automatic_id_field.py +++ b/tests/event_sourced_aggregates/test_automatic_id_field.py @@ -1,6 +1,6 @@ from protean import BaseEventSourcedAggregate from protean.fields import Auto, DateTime, Identifier, Integer, String -from protean.reflection import fields, id_field, declared_fields +from protean.reflection import declared_fields, fields, id_field from protean.utils import utcnow_func diff --git a/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py b/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py index de6c7bd0..8ccbe092 100644 --- a/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py +++ b/tests/event_sourced_aggregates/test_raising_multiple_events_for_one_aggregate_in_a_uow.py @@ -2,7 +2,6 @@ import random import string - from uuid import uuid4 from protean import ( diff --git a/tests/field/test_auto.py b/tests/field/test_auto.py index aa38bf51..7d82d03b 100644 --- a/tests/field/test_auto.py +++ b/tests/field/test_auto.py @@ -1,13 +1,13 @@ -import pytest import random import re import time - from uuid import UUID +import pytest + from protean import BaseAggregate, BaseView from protean.fields import Auto -from tests.shared import assert_str_is_uuid, assert_int_is_uuid +from tests.shared import assert_int_is_uuid, assert_str_is_uuid class TestValueGeneration: diff --git a/tests/field/test_choices.py b/tests/field/test_choices.py index e4e056ab..cc1d8013 100644 --- a/tests/field/test_choices.py +++ b/tests/field/test_choices.py @@ -1,7 +1,7 @@ -import pytest - from enum import Enum +import pytest + from protean.exceptions import ValidationError from protean.fields import String diff --git a/tests/field/test_field_types.py b/tests/field/test_field_types.py index a262c4d0..f229a5e5 100644 --- a/tests/field/test_field_types.py +++ b/tests/field/test_field_types.py @@ -1,7 +1,6 @@ """Test cases for all available field type implementations""" import enum - from datetime import datetime import pytest diff --git a/tests/field/test_list.py b/tests/field/test_list.py index cc618c46..72eb0062 100644 --- a/tests/field/test_list.py +++ b/tests/field/test_list.py @@ -1,18 +1,18 @@ -import pytest +from datetime import date, datetime -from datetime import datetime, date +import pytest from protean import BaseValueObject from protean.exceptions import ValidationError from protean.fields.basic import ( - List, - String, - Integer, Boolean, Date, DateTime, - Float, Dict, + Float, + Integer, + List, + String, ) from protean.fields.embedded import ValueObject diff --git a/tests/reflection/test_id_field.py b/tests/reflection/test_id_field.py index f1ec112c..a433cd73 100644 --- a/tests/reflection/test_id_field.py +++ b/tests/reflection/test_id_field.py @@ -1,6 +1,6 @@ -from protean import BaseAggregate, BaseValueObject, Domain, BaseEvent, BaseCommand +from protean import BaseAggregate, BaseCommand, BaseEvent, BaseValueObject, Domain from protean.fields import Float, Identifier, String -from protean.reflection import id_field, declared_fields +from protean.reflection import declared_fields, id_field domain = Domain(__name__) diff --git a/tests/repository/elements.py b/tests/repository/elements.py index fcf14a21..f3f6534f 100644 --- a/tests/repository/elements.py +++ b/tests/repository/elements.py @@ -1,5 +1,4 @@ import re - from typing import List from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant diff --git a/tests/server/test_engine_run.py b/tests/server/test_engine_run.py index b4e124aa..a0f0700f 100644 --- a/tests/server/test_engine_run.py +++ b/tests/server/test_engine_run.py @@ -1,5 +1,4 @@ import asyncio - from uuid import uuid4 import pytest diff --git a/tests/server/test_error_handling.py b/tests/server/test_error_handling.py index ec0f86a6..76900c2d 100644 --- a/tests/server/test_error_handling.py +++ b/tests/server/test_error_handling.py @@ -1,5 +1,4 @@ import asyncio - from uuid import uuid4 import pytest diff --git a/tests/shared.py b/tests/shared.py index b03d1da3..da873e06 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -2,7 +2,6 @@ import os import sys - from pathlib import Path from uuid import UUID diff --git a/tests/support/domains/test14/domain14.py b/tests/support/domains/test14/domain14.py index 75eac253..1dd35c69 100644 --- a/tests/support/domains/test14/domain14.py +++ b/tests/support/domains/test14/domain14.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST14") diff --git a/tests/support/domains/test15/domain15.py b/tests/support/domains/test15/domain15.py index 24901c45..3f42b45c 100644 --- a/tests/support/domains/test15/domain15.py +++ b/tests/support/domains/test15/domain15.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST15") diff --git a/tests/support/domains/test16/domain16.py b/tests/support/domains/test16/domain16.py index 24901c45..3f42b45c 100644 --- a/tests/support/domains/test16/domain16.py +++ b/tests/support/domains/test16/domain16.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST15") diff --git a/tests/support/domains/test17/domain17.py b/tests/support/domains/test17/domain17.py index 24901c45..3f42b45c 100644 --- a/tests/support/domains/test17/domain17.py +++ b/tests/support/domains/test17/domain17.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST15") diff --git a/tests/support/domains/test18/domain18.py b/tests/support/domains/test18/domain18.py index 16c02e34..4fb01c75 100644 --- a/tests/support/domains/test18/domain18.py +++ b/tests/support/domains/test18/domain18.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST18") diff --git a/tests/support/domains/test19/domain19.py b/tests/support/domains/test19/domain19.py index bec12c47..b2666ba5 100644 --- a/tests/support/domains/test19/domain19.py +++ b/tests/support/domains/test19/domain19.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST19") diff --git a/tests/support/domains/test20/content/post20.py b/tests/support/domains/test20/content/post20.py index 9b340db1..6de00aba 100644 --- a/tests/support/domains/test20/content/post20.py +++ b/tests/support/domains/test20/content/post20.py @@ -1,6 +1,7 @@ from datetime import datetime from protean.fields import DateTime, HasMany, Reference, String + from ..publishing20 import publishing diff --git a/tests/support/domains/test20/publishing20.py b/tests/support/domains/test20/publishing20.py index 1f6512c0..17be5410 100644 --- a/tests/support/domains/test20/publishing20.py +++ b/tests/support/domains/test20/publishing20.py @@ -1,5 +1,4 @@ from protean import Domain - publishing = Domain(__file__, "Publishing20") print(id(publishing)) diff --git a/tests/support/domains/test21/content/post21.py b/tests/support/domains/test21/content/post21.py index 4168cac3..fba17e47 100644 --- a/tests/support/domains/test21/content/post21.py +++ b/tests/support/domains/test21/content/post21.py @@ -1,6 +1,7 @@ from datetime import datetime from protean.fields import DateTime, HasMany, Reference, String + from ..publishing21 import publishing diff --git a/tests/support/domains/test21/publishing21.py b/tests/support/domains/test21/publishing21.py index ca86562a..76e58c5a 100644 --- a/tests/support/domains/test21/publishing21.py +++ b/tests/support/domains/test21/publishing21.py @@ -1,4 +1,3 @@ from protean import Domain - publishing = Domain(__file__, "Publishing21") diff --git a/tests/support/domains/test22/src/publishing/domain22.py b/tests/support/domains/test22/src/publishing/domain22.py index d1503cc9..d27b05a0 100644 --- a/tests/support/domains/test22/src/publishing/domain22.py +++ b/tests/support/domains/test22/src/publishing/domain22.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST22") diff --git a/tests/support/domains/test23/src/publishing/domain23.py b/tests/support/domains/test23/src/publishing/domain23.py index 6f88b77c..2d8bc07c 100644 --- a/tests/support/domains/test23/src/publishing/domain23.py +++ b/tests/support/domains/test23/src/publishing/domain23.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST23") diff --git a/tests/support/domains/test24/domain24.py b/tests/support/domains/test24/domain24.py index 699ff904..27815999 100644 --- a/tests/support/domains/test24/domain24.py +++ b/tests/support/domains/test24/domain24.py @@ -1,4 +1,3 @@ from protean import Domain - domain = Domain(__file__, "TEST24") diff --git a/tests/test_aggregates.py b/tests/test_aggregates.py index 15681488..5f7d2235 100644 --- a/tests/test_aggregates.py +++ b/tests/test_aggregates.py @@ -3,7 +3,7 @@ import pytest from protean import BaseAggregate -from protean.exceptions import ValidationError, NotSupportedError +from protean.exceptions import NotSupportedError, ValidationError from protean.fields import Date, DateTime, HasMany, Reference, String from protean.reflection import declared_fields from protean.utils import fully_qualified_name, utcnow_func diff --git a/tests/value_object/tests.py b/tests/value_object/tests.py index 128187a0..9b78c928 100644 --- a/tests/value_object/tests.py +++ b/tests/value_object/tests.py @@ -1,6 +1,6 @@ import pytest -from protean.exceptions import IncorrectUsageError, ValidationError, NotSupportedError +from protean.exceptions import IncorrectUsageError, NotSupportedError, ValidationError from protean.fields import Float from protean.reflection import attributes, declared_fields diff --git a/tests/views/tests.py b/tests/views/tests.py index 83683ccf..908bf98a 100644 --- a/tests/views/tests.py +++ b/tests/views/tests.py @@ -1,9 +1,9 @@ -import pytest - from collections import defaultdict from enum import Enum from uuid import uuid4 +import pytest + from protean import BaseView from protean.container import Options from protean.exceptions import InvalidOperationError, ValidationError