Skip to content

Commit

Permalink
Fix flake8 issues with tox
Browse files Browse the repository at this point in the history
  • Loading branch information
subhashb committed Sep 28, 2020
1 parent a55ec1d commit 2cd1004
Show file tree
Hide file tree
Showing 45 changed files with 81 additions and 69 deletions.
6 changes: 3 additions & 3 deletions src/protean/adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Adapters
# Protean
from protean.adapters.broker import Brokers
from protean.adapters.broker.celery import CeleryBroker, ProteanTask
from protean.adapters.broker.inline import InlineBroker
from protean.adapters.email import EmailProviders
from protean.adapters.email.dummy import DummyEmailProvider
from protean.adapters.email.sendgrid import SendgridEmailProvider
from protean.adapters.repository import Providers
from protean.adapters.repository.elasticsearch import ESProvider, ElasticsearchModel
from protean.adapters.repository.elasticsearch import ElasticsearchModel, ESProvider
from protean.adapters.repository.memory import MemoryModel, MemoryProvider
from protean.adapters.repository.sqlalchemy import SAProvider, SqlalchemyModel
from protean.adapters.repository.memory import MemoryProvider, MemoryModel


__all__ = (
"Brokers",
Expand Down
2 changes: 2 additions & 0 deletions src/protean/adapters/broker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Standard Library Imports
import importlib
import logging

from collections.abc import MutableMapping

# Protean
from protean.core.exceptions import ConfigurationError
from protean.globals import current_uow
from protean.utils import DomainObjects
Expand Down
5 changes: 2 additions & 3 deletions src/protean/adapters/broker/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
# Protean
from celery import Celery, Task
from kombu import Queue
from protean.port.broker import BaseBroker
from protean.core.domain_event import BaseDomainEvent
from protean.utils import DomainObjects
from protean.utils import fully_qualified_name
from protean.port.broker import BaseBroker
from protean.utils import DomainObjects, fully_qualified_name
from protean.utils.inflection import underscore

logger = logging.getLogger("protean.adapters.celery")
Expand Down
2 changes: 1 addition & 1 deletion src/protean/adapters/broker/inline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Protean
from protean.port.broker import BaseBroker
from protean.core.domain_event import BaseDomainEvent
from protean.globals import current_domain
from protean.port.broker import BaseBroker
from protean.utils import fully_qualified_name


Expand Down
2 changes: 2 additions & 0 deletions src/protean/adapters/email/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Standard Library Imports
import importlib
import logging

# Protean
from protean.core.exceptions import ConfigurationError
from protean.globals import current_uow

Expand Down
4 changes: 3 additions & 1 deletion src/protean/adapters/repository/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
""" Package for Concrete Implementations of Protean repositories """
# Standard Library Imports
import importlib
import logging

# Protean
from protean.core.exceptions import ConfigurationError
from protean.utils import fully_qualified_name, DomainObjects
from protean.utils import DomainObjects, fully_qualified_name

logger = logging.getLogger("protean.repository")

Expand Down
6 changes: 2 additions & 4 deletions src/protean/adapters/repository/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
from elasticsearch_dsl import Document, Index, Search, query
from protean.core.exceptions import ObjectNotFoundError
from protean.core.field.association import Reference
from protean.port.provider import BaseProvider
from protean.port.dao import BaseDAO
from protean.port.dao import BaseLookup
from protean.port.dao import ResultSet
from protean.globals import current_domain
from protean.port.dao import BaseDAO, BaseLookup, ResultSet
from protean.port.provider import BaseProvider
from protean.utils import Database, IdentityStrategy, IdentityType
from protean.utils.query import Q

Expand Down
6 changes: 2 additions & 4 deletions src/protean/adapters/repository/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

# Protean
from protean.core.exceptions import ObjectNotFoundError
from protean.port.provider import BaseProvider
from protean.port.dao import BaseDAO
from protean.port.dao import BaseLookup
from protean.core.model import BaseModel
from protean.port.dao import ResultSet
from protean.globals import current_uow
from protean.port.dao import BaseDAO, BaseLookup, ResultSet
from protean.port.provider import BaseProvider
from protean.utils import Database
from protean.utils.query import Q

Expand Down
6 changes: 2 additions & 4 deletions src/protean/adapters/repository/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
String,
Text,
)
from protean.port.provider import BaseProvider
from protean.port.dao import BaseDAO
from protean.port.dao import BaseLookup
from protean.core.model import BaseModel
from protean.port.dao import ResultSet
from protean.globals import current_domain, current_uow
from protean.port.dao import BaseDAO, BaseLookup, ResultSet
from protean.port.provider import BaseProvider
from protean.utils import Database, IdentityType
from protean.utils.query import Q
from sqlalchemy import Column, MetaData, and_, create_engine, or_, orm
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 @@ -4,7 +4,7 @@

# Protean
from protean.core.entity import BaseEntity
from protean.core.exceptions import IncorrectUsageError, NotSupportedError
from protean.core.exceptions import NotSupportedError
from protean.utils import DomainObjects, derive_element_class

logger = logging.getLogger("protean.domain.aggregate")
Expand Down
1 change: 0 additions & 1 deletion src/protean/core/domain_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging

# Protean
from protean.core.exceptions import IncorrectUsageError
from protean.utils import DomainObjects, derive_element_class
from protean.utils.container import BaseContainer

Expand Down
7 changes: 5 additions & 2 deletions src/protean/core/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
from abc import abstractmethod

# Protean
from protean.utils import DomainObjects, derive_element_class
from protean.globals import current_domain
from protean.utils import convert_str_values_to_list
from protean.utils import (
DomainObjects,
convert_str_values_to_list,
derive_element_class,
)


class BaseEmailProvider:
Expand Down
9 changes: 7 additions & 2 deletions src/protean/core/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
from protean.core.field.association import Association, Reference
from protean.core.field.basic import Auto, Field
from protean.core.field.embedded import ValueObjectField
from protean.utils import DomainObjects, derive_element_class
from protean.globals import current_domain
from protean.utils import IdentityStrategy, IdentityType, inflection
from protean.utils import (
DomainObjects,
IdentityStrategy,
IdentityType,
derive_element_class,
inflection,
)

# Local/Relative Imports
from ..core.field.association import _ReferenceField # Relative path to private class
Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/field/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Utility functions for the Field Module """
# Protean
from protean.utils import DomainObjects
from protean.globals import current_domain
from protean.utils import DomainObjects


def fetch_entity_cls_from_registry(entity):
Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Standard Library Imports
from abc import abstractmethod
from protean.core.exceptions import IncorrectUsageError

# Protean
from protean.core.exceptions import IncorrectUsageError
from protean.utils import DomainObjects, derive_element_class


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 @@ -4,8 +4,8 @@
# Protean
from protean.core.exceptions import IncorrectUsageError, ValidationError
from protean.core.field.association import HasMany, HasOne
from protean.utils import DomainObjects, derive_element_class
from protean.globals import current_domain
from protean.utils import DomainObjects, derive_element_class

logger = logging.getLogger("protean.repository")

Expand Down
12 changes: 7 additions & 5 deletions src/protean/domain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import logging
import sys

# Protean
from protean.adapters import Brokers, EmailProviders, Providers
from protean.core.exceptions import (
IncorrectUsageError,
NotSupportedError,
ObjectNotFoundError,
)
from protean.domain.registry import _DomainRegistry
from protean.adapters import Brokers, EmailProviders, Providers
from protean.utils import fully_qualified_name, DomainObjects
from protean.utils import DomainObjects, fully_qualified_name
from werkzeug.datastructures import ImmutableDict

# Local/Relative Imports
Expand Down Expand Up @@ -85,8 +86,8 @@ class Domain(_PackageBoundObject):
"AUTOLOAD_DOMAIN": True,
"IDENTITY_STRATEGY": IdentityStrategy.UUID,
"IDENTITY_TYPE": IdentityType.STRING,
"DATABASES": {"default": {"PROVIDER": "protean.adapters.MemoryProvider",},},
"BROKERS": {"default": {"PROVIDER": "protean.adapters.InlineBroker",},},
"DATABASES": {"default": {"PROVIDER": "protean.adapters.MemoryProvider"}},
"BROKERS": {"default": {"PROVIDER": "protean.adapters.InlineBroker"}},
"EMAIL_PROVIDERS": {
"default": {
"PROVIDER": "protean.adapters.DummyEmailProvider",
Expand Down Expand Up @@ -274,6 +275,7 @@ def registry(self):
return self._domain_registry

def factory_for(self, domain_object_type):
# Protean
from protean.core.aggregate import aggregate_factory
from protean.core.application_service import application_service_factory
from protean.core.command import command_factory
Expand All @@ -284,8 +286,8 @@ def factory_for(self, domain_object_type):
from protean.core.entity import entity_factory
from protean.core.model import model_factory
from protean.core.repository import repository_factory
from protean.core.subscriber import subscriber_factory
from protean.core.serializer import serializer_factory
from protean.core.subscriber import subscriber_factory
from protean.core.value_object import value_object_factory
from protean.core.view import view_factory

Expand Down
4 changes: 2 additions & 2 deletions src/protean/domain/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import sys

# Local/Relative Imports
# Protean
from protean.globals import _domain_context_stack

# a singleton sentinel value for parameter defaults
Expand Down Expand Up @@ -101,7 +101,7 @@ def pop(self, exc=_sentinel):
self.domain.do_teardown_domain_context(exc)
finally:
rv = _domain_context_stack.pop()
assert rv is self, f"Popped wrong domain context. (%r instead of %r)" % (
assert rv is self, "Popped wrong domain context. (%r instead of %r)" % (
rv,
self,
)
Expand Down
9 changes: 6 additions & 3 deletions src/protean/domain/registry.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from enum import Enum
import inflection
# Standard Library Imports
import logging

from collections import defaultdict
from enum import Enum
from typing import Any, Dict

from protean.utils import fully_qualified_name, DomainObjects
# Protean
import inflection

from protean.utils import DomainObjects, fully_qualified_name

logger = logging.getLogger("protean.domain")

Expand Down
3 changes: 1 addition & 2 deletions src/protean/port/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from collections.abc import Iterable

# Protean
from protean.utils import DomainObjects
from protean.utils import fully_qualified_name
from protean.utils import DomainObjects, fully_qualified_name

logger = logging.getLogger("protean.port.broker")

Expand Down
1 change: 1 addition & 0 deletions src/protean/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from enum import Enum, auto

# Protean
from protean.core.exceptions import IncorrectUsageError

logger = logging.getLogger("protean.utils")
Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/broker/celery_broker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
"formatter": "console",
},
},
"loggers": {"protean": {"handlers": ["console"], "level": "DEBUG"},},
"loggers": {"protean": {"handlers": ["console"], "level": "DEBUG"}},
}
2 changes: 1 addition & 1 deletion tests/adapters/broker/celery_broker/elements.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Protean
from protean.core.aggregate import BaseAggregate
from protean.core.subscriber import BaseSubscriber
from protean.core.domain_event import BaseDomainEvent
from protean.core.field.basic import Auto, Integer, String
from protean.core.subscriber import BaseSubscriber
from protean.globals import current_domain


Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/broker/celery_broker/test_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import pytest

from celery import Task
from protean.globals import current_domain
from protean.adapters import CeleryBroker, ProteanTask
from protean.globals import current_domain
from tests.adapters.broker.celery_broker.elements import NotifySSOSubscriber, Person


Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/broker/celery_broker/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import pytest

from mock import patch
from protean.globals import current_domain
from protean.adapters import CeleryBroker
from protean.globals import current_domain
from tests.adapters.broker.celery_broker.elements import (
NotifySSOSubscriber,
Person,
Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/email/sendgrid_email/elements.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Protean
from protean.core.aggregate import BaseAggregate
from protean.core.subscriber import BaseSubscriber
from protean.core.domain_event import BaseDomainEvent
from protean.core.email import BaseEmail
from protean.core.exceptions import InsufficientDataError, InvalidDataError
from protean.core.field.basic import Integer, String
from protean.core.field.embedded import AggregateField
from protean.core.subscriber import BaseSubscriber
from protean.globals import current_domain


Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/model/dict_model/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from protean.core.aggregate import BaseAggregate
from protean.core.field.basic import Integer, String, Text
from protean.core.field.embedded import ValueObjectField
from protean.core.repository import BaseRepository
from protean.core.model import BaseModel
from protean.core.repository import BaseRepository
from protean.core.value_object import BaseValueObject
from protean.globals import current_domain

Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/model/elasticsearch_model/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

# Protean
from elasticsearch_dsl import Keyword, Text
from protean.adapters import ElasticsearchModel
from protean.core.aggregate import BaseAggregate
from protean.core.field.basic import DateTime, Integer, String
from protean.core.field.basic import Text as ProteanText
from protean.core.field.embedded import ValueObjectField
from protean.core.value_object import BaseValueObject
from protean.adapters import ElasticsearchModel


class Person(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Protean
import pytest

from protean.adapters.repository.sqlalchemy import Any, Contains, In, Overlap
from protean.core.aggregate import BaseAggregate
from protean.core.field.basic import List, String
from protean.adapters.repository.sqlalchemy import Any, Contains, In, Overlap


class GenericPostgres(BaseAggregate):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from elasticsearch import Elasticsearch
from elasticsearch_dsl.response import Response
from protean.adapters import Providers, ESProvider
from protean.adapters import ESProvider, Providers

# Local/Relative Imports
from .elements import Alien, Person
Expand Down
Loading

0 comments on commit 2cd1004

Please sign in to comment.