Skip to content

Commit

Permalink
Nest reflection under utils module
Browse files Browse the repository at this point in the history
  • Loading branch information
subhashb committed Jul 25, 2024
1 parent 3b4face commit f2deb99
Show file tree
Hide file tree
Showing 69 changed files with 94 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/protean/adapters/cache/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from protean.core.view import BaseView
from protean.port.cache import BaseCache
from protean.reflection import id_field
from protean.utils.inflection import underscore
from protean.utils.reflection import id_field


class TTLDict(collections.abc.MutableMapping):
Expand Down
2 changes: 1 addition & 1 deletion src/protean/adapters/cache/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from protean.core.view import BaseView
from protean.port.cache import BaseCache
from protean.reflection import id_field
from protean.utils.inflection import underscore
from protean.utils.reflection import id_field


class RedisCache(BaseCache):
Expand Down
2 changes: 1 addition & 1 deletion src/protean/adapters/repository/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
from protean.fields import Reference
from protean.port.dao import BaseDAO, BaseLookup
from protean.port.provider import BaseProvider
from protean.reflection import attributes, id_field
from protean.utils import IdentityStrategy, IdentityType
from protean.utils.container import Options
from protean.utils.globals import current_domain
from protean.utils.query import Q
from protean.utils.reflection import attributes, id_field

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/protean/adapters/repository/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from protean.fields.basic import Auto
from protean.port.dao import BaseDAO, BaseLookup
from protean.port.provider import BaseProvider
from protean.reflection import attributes, fields, id_field
from protean.utils.container import Options
from protean.utils.globals import current_uow
from protean.utils.query import Q
from protean.utils.reflection import attributes, fields, id_field


def derive_schema_name(model_cls):
Expand Down
2 changes: 1 addition & 1 deletion src/protean/adapters/repository/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
from protean.fields.embedded import _ShadowField
from protean.port.dao import BaseDAO, BaseLookup
from protean.port.provider import BaseProvider
from protean.reflection import attributes, id_field
from protean.utils import IdentityType
from protean.utils.container import Options
from protean.utils.globals import current_domain, current_uow
from protean.utils.query import Q
from protean.utils.reflection import attributes, id_field

logging.getLogger("sqlalchemy").setLevel(logging.ERROR)
logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from protean.exceptions import IncorrectUsageError, NotSupportedError
from protean.fields import HasMany, HasOne, Integer, Reference, ValueObject
from protean.fields import List as ProteanList
from protean.reflection import fields
from protean.utils import DomainObjects, derive_element_class, fqn, inflection
from protean.utils.reflection import fields

logger = logging.getLogger(__name__)

Expand Down
16 changes: 8 additions & 8 deletions src/protean/core/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
)
from protean.fields import Auto, HasMany, Reference, ValueObject
from protean.fields.association import Association
from protean.reflection import (
_FIELDS,
attributes,
data_fields,
declared_fields,
fields,
id_field,
)
from protean.utils import (
DomainObjects,
derive_element_class,
generate_identity,
inflection,
)
from protean.utils.container import BaseContainer, IdentityMixin, OptionsMixin
from protean.utils.reflection import (
_FIELDS,
attributes,
data_fields,
declared_fields,
fields,
id_field,
)

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from protean.fields import HasMany, HasOne
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,
DomainObjects,
Expand All @@ -20,6 +19,7 @@
)
from protean.utils.container import Element, OptionsMixin
from protean.utils.globals import current_domain, current_uow
from protean.utils.reflection import association_fields, has_association_fields

if TYPE_CHECKING:
from protean.domain import Domain
Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
String,
Text,
)
from protean.reflection import _FIELDS
from protean.utils import DomainObjects, derive_element_class
from protean.utils.container import Element, Options, OptionsMixin
from protean.utils.reflection import _FIELDS

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/unit_of_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
InvalidOperationError,
ValidationError,
)
from protean.reflection import id_field
from protean.utils import EventProcessing
from protean.utils.globals import _uow_context_stack, current_domain
from protean.utils.reflection import id_field

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from protean.exceptions import IncorrectUsageError, NotSupportedError
from protean.fields import Field, Reference, ValueObject
from protean.fields.association import Association
from protean.reflection import _ID_FIELD_NAME, declared_fields, id_field
from protean.utils import DomainObjects, derive_element_class, inflection
from protean.utils.container import BaseContainer, OptionsMixin
from protean.utils.reflection import _ID_FIELD_NAME, declared_fields, id_field

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/protean/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
)
from protean.fields import HasMany, HasOne, Reference, ValueObject
from protean.fields import List as ProteanList
from protean.reflection import declared_fields, has_fields, id_field
from protean.utils import (
CommandProcessing,
DomainObjects,
Expand All @@ -39,6 +38,7 @@
)
from protean.utils.container import Element
from protean.utils.globals import g
from protean.utils.reflection import declared_fields, has_fields, id_field

from .config import Config2, ConfigAttribute
from .context import DomainContext, _DomainContextGlobals
Expand Down
6 changes: 5 additions & 1 deletion src/protean/fields/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

from protean import exceptions, utils
from protean.exceptions import ValidationError
from protean.reflection import association_fields, has_association_fields, id_field
from protean.utils.globals import current_domain
from protean.utils.reflection import (
association_fields,
has_association_fields,
id_field,
)

from .base import Field, FieldBase
from .mixins import FieldCacheMixin, FieldDescriptorMixin
Expand Down
2 changes: 1 addition & 1 deletion src/protean/fields/embedded.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from protean.exceptions import IncorrectUsageError
from protean.fields import Field
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class _ShadowField(Field):
Expand Down
2 changes: 1 addition & 1 deletion src/protean/port/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
)
from protean.fields import Auto, Field
from protean.port.provider import BaseProvider
from protean.reflection import declared_fields, id_field, unique_fields
from protean.utils import DomainObjects
from protean.utils.globals import current_uow
from protean.utils.query import Q
from protean.utils.reflection import declared_fields, id_field, unique_fields

if TYPE_CHECKING:
from protean.domain import Domain
Expand Down
2 changes: 1 addition & 1 deletion src/protean/utils/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from protean.fields import Auto, Field, FieldBase, ValueObject
from protean.utils import generate_identity

from ..reflection import (
from .reflection import (
_FIELDS,
_ID_FIELD_NAME,
attributes,
Expand Down
2 changes: 1 addition & 1 deletion src/protean/utils/eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from protean.exceptions import ConfigurationError, IncorrectUsageError
from protean.fields import DateTime, Field, Integer, String, ValueObject
from protean.fields.association import Association, Reference
from protean.reflection import _ID_FIELD_NAME, declared_fields, fields
from protean.utils.container import BaseContainer, OptionsMixin
from protean.utils.reflection import _ID_FIELD_NAME, declared_fields, fields


class Metadata(BaseValueObject):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from protean.core.entity import BaseEntity
from protean.core.event import BaseEvent
from protean.fields import Date, HasMany, List, String, ValueObject
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class Customer(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from protean.core.event import BaseEvent
from protean.core.value_object import BaseValueObject
from protean.fields import HasMany, HasOne, Integer, List, String, ValueObject
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class University(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from protean.core.event import BaseEvent
from protean.core.value_object import BaseValueObject
from protean.fields import HasMany, HasOne, Integer, List, String, ValueObject
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class University(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from protean.core.entity import BaseEntity
from protean.core.event import BaseEvent
from protean.fields import HasOne, Integer, String, ValueObject
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class Department(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
String,
ValueObject,
)
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class Shipment(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from protean.core.entity import BaseEntity
from protean.core.event import BaseEvent
from protean.fields import Date, HasMany, List, String, ValueObject
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class Customer(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from protean.core.entity import BaseEntity
from protean.core.event import BaseEvent
from protean.fields import HasOne, Integer, String, ValueObject
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class Department(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from protean.core.aggregate import BaseAggregate, element_to_fact_event
from protean.core.event import BaseEvent
from protean.fields import String
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class University(BaseAggregate):
Expand Down
2 changes: 1 addition & 1 deletion tests/aggregate/test_aggregate_abstraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from protean.exceptions import NotSupportedError
from protean.fields import String
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields

from .elements import AbstractRole, ConcreteRole

Expand Down
2 changes: 1 addition & 1 deletion tests/aggregate/test_aggregate_association.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from protean.reflection import attributes
from protean.utils.reflection import attributes

from .elements import (
Account,
Expand Down
2 changes: 1 addition & 1 deletion tests/aggregate/test_aggregate_association_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from protean.reflection import attributes
from protean.utils.reflection import attributes

from .elements import (
Account,
Expand Down
2 changes: 1 addition & 1 deletion tests/aggregate/test_aggregate_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.exceptions import NotSupportedError, ValidationError
from protean.reflection import attributes, declared_fields
from protean.utils import fully_qualified_name
from protean.utils.reflection import attributes, declared_fields

from .elements import (
AccountWithId,
Expand Down
7 changes: 6 additions & 1 deletion tests/aggregate/test_aggregate_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

from protean.exceptions import InvalidOperationError, ValidationError
from protean.fields import Auto, String
from protean.reflection import _ID_FIELD_NAME, attributes, declared_fields, id_field
from protean.utils.reflection import (
_ID_FIELD_NAME,
attributes,
declared_fields,
id_field,
)

from .elements import PersonAutoSSN, PersonExplicitID, Role, RoleClone, SubclassRole

Expand Down
2 changes: 1 addition & 1 deletion tests/aggregate/test_aggregate_reference_field.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from protean.exceptions import ValidationError
from protean.reflection import attributes
from protean.utils.reflection import attributes

from .elements import Account, Author

Expand Down
2 changes: 1 addition & 1 deletion tests/command/test_command_identity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from protean.core.command import BaseCommand
from protean.fields import Identifier, String
from protean.reflection import has_id_field, id_field
from protean.utils.reflection import has_id_field, id_field


class Register(BaseCommand):
Expand Down
2 changes: 1 addition & 1 deletion tests/command/test_command_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from protean.core.aggregate import BaseAggregate
from protean.core.command import BaseCommand
from protean.fields import Identifier, String
from protean.reflection import fields
from protean.utils import fqn
from protean.utils.reflection import fields


class User(BaseAggregate):
Expand Down
2 changes: 1 addition & 1 deletion tests/domain/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
NotSupportedError,
)
from protean.fields import DateTime, HasMany, HasOne, Reference, String, Text
from protean.reflection import declared_fields
from protean.utils import fully_qualified_name
from protean.utils.reflection import declared_fields

from .elements import UserAggregate, UserEntity, UserFoo, UserVO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.fields import Date, Float, HasMany, Identifier, String
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class Customer(BaseAggregate):
Expand Down
2 changes: 1 addition & 1 deletion tests/entity/associations/test_has_many_with_has_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.fields import HasMany, HasOne, Integer, String
from protean.reflection import declared_fields
from protean.utils.reflection import declared_fields


class University(BaseAggregate):
Expand Down
Loading

0 comments on commit f2deb99

Please sign in to comment.