Skip to content

Commit

Permalink
merge to main
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstenBreuer committed Oct 6, 2023
2 parents 549baeb + df04920 commit 2d42898
Show file tree
Hide file tree
Showing 38 changed files with 162 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- name: Verify Package Version vs Tag Version
run: |
PKG_VER="$(python setup.py -V)"
PKG_VER="$(grep -oP 'version = "\K[^"]+' pyproject.toml)"
TAG_VER="${GITHUB_REF##*/}"
echo "Package version is $PKG_VER" >&2
echo "Tag version is $TAG_VER" >&2
Expand Down
4 changes: 2 additions & 2 deletions examples/stream_calc/sc_tests/integration/test_event_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

import pytest
from kafka import KafkaConsumer, KafkaProducer
from stream_calc.config import Config
from stream_calc.main import main
from testcontainers.kafka import KafkaContainer

from hexkit.custom_types import JsonObject
from stream_calc.config import Config
from stream_calc.main import main

DEFAULT_CONFIG = Config()

Expand Down
1 change: 1 addition & 0 deletions examples/stream_calc/sc_tests/unit/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from unittest.mock import AsyncMock

import pytest

from stream_calc.core.calc import StreamCalculator


Expand Down
4 changes: 2 additions & 2 deletions examples/stream_calc/sc_tests/unit/test_eventpub.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"""Testing the `translators.eventpub` module."""

import pytest

from hexkit.providers.testing.eventpub import InMemEventPublisher
from stream_calc.translators.eventpub import (
EventResultEmitter,
EventResultEmitterConfig,
)

from hexkit.providers.testing.eventpub import InMemEventPublisher


@pytest.mark.asyncio
async def test_emit_result():
Expand Down
4 changes: 2 additions & 2 deletions examples/stream_calc/sc_tests/unit/test_eventsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
from unittest.mock import AsyncMock

import pytest

from hexkit.custom_types import JsonObject
from stream_calc.translators.eventsub import (
EventProblemReceiver,
EventProblemReceiverConfig,
)

from hexkit.custom_types import JsonObject


@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions examples/stream_calc/stream_calc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

"""Config parameters."""

from hexkit.providers.akafka import KafkaConfig
from stream_calc.translators.eventpub import EventResultEmitterConfig
from stream_calc.translators.eventsub import EventProblemReceiverConfig

from hexkit.providers.akafka import KafkaConfig

try: # workaround for https://github.com/pydantic/pydantic/issues/5821
from typing_extensions import Literal
except ImportError:
Expand Down
5 changes: 2 additions & 3 deletions examples/stream_calc/stream_calc/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
"""Module hosting the dependency injection container."""

# pylint: disable=wrong-import-order
from hexkit.inject import ContainerBase, get_configurator, get_constructor
from hexkit.providers.akafka import KafkaEventPublisher, KafkaEventSubscriber
from stream_calc.config import Config
from stream_calc.core.calc import StreamCalculator
from stream_calc.translators.eventpub import EventResultEmitter
from stream_calc.translators.eventsub import EventProblemReceiver

from hexkit.inject import ContainerBase, get_configurator, get_constructor
from hexkit.providers.akafka import KafkaEventPublisher, KafkaEventSubscriber


class Container(ContainerBase):
"""DI Container"""
Expand Down
4 changes: 2 additions & 2 deletions examples/stream_calc/stream_calc/translators/eventpub.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"""Translators that target the event publishing protocol."""

from pydantic import BaseSettings
from stream_calc.ports.result_emitter import CalcResultEmitterPort

from hexkit.custom_types import JsonObject
from hexkit.protocols.eventpub import EventPublisherProtocol
from stream_calc.ports.result_emitter import CalcResultEmitterPort


class EventResultEmitterConfig(BaseSettings):
Expand All @@ -39,7 +39,7 @@ def __init__(
self,
*,
config: EventResultEmitterConfig,
event_publisher: EventPublisherProtocol
event_publisher: EventPublisherProtocol,
) -> None:
"""Configure with provider for the the EventPublisherProto"""

Expand Down
2 changes: 1 addition & 1 deletion examples/stream_calc/stream_calc/translators/eventsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"""Translators that target the event publishing protocol."""

from pydantic import BaseSettings
from stream_calc.ports.problem_receiver import ArithProblemHandlerPort

from hexkit.custom_types import Ascii, JsonObject
from hexkit.protocols.eventsub import EventSubscriberProtocol
from stream_calc.ports.problem_receiver import ArithProblemHandlerPort


class EventProblemReceiverConfig(BaseSettings):
Expand Down
3 changes: 1 addition & 2 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# common requirements for development and testing
-r requirements-dev-common.in

# additional requirements for testing hexkit providers
hexkit[test-all]
# additional requirements can be listed her
82 changes: 0 additions & 82 deletions setup.cfg

This file was deleted.

4 changes: 3 additions & 1 deletion src/hexkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@

"""A Toolkit for Building Microservices using the Hexagonal Architecture"""

__version__ = "0.10.2"
from importlib.metadata import version

__version__ = version(__package__)
7 changes: 3 additions & 4 deletions src/hexkit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os
from pathlib import Path
from typing import Any, Callable, Dict, Final, Optional
from typing import Any, Callable, Final, Optional

import yaml
from pydantic import BaseSettings
Expand Down Expand Up @@ -155,9 +155,8 @@ def constructor_wrapper(
# get default path if config_yaml not specified:
if config_yaml is None:
config_yaml = get_default_config_yaml(prefix)
else:
if not config_yaml.is_file():
raise ConfigYamlDoesNotExist(path=config_yaml)
elif not config_yaml.is_file():
raise ConfigYamlDoesNotExist(path=config_yaml)

class ModSettings(settings):
"""Modifies the orginal Settings class provided by the user"""
Expand Down
2 changes: 2 additions & 0 deletions src/hexkit/protocols/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
with the database.
"""

# ruff: noqa: PLR0913

import typing
from abc import ABC, abstractmethod
from collections.abc import AsyncGenerator, AsyncIterator, Collection, Mapping
Expand Down
1 change: 1 addition & 0 deletions src/hexkit/protocols/objstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

"""Protocol for interacting with S3-like Object Storages."""

# ruff: noqa: PLR0913

import re
from abc import ABC, abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion src/hexkit/providers/akafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from .provider import (
KafkaConfig,
KafkaEventPublisher, # noqa: F401
KafkaEventPublisher,
KafkaEventSubscriber,
)

Expand Down
2 changes: 1 addition & 1 deletion src/hexkit/providers/akafka/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def get_event_type(event: ConsumerEvent) -> str:
class KafkaConsumerCompatible(Protocol):
"""A python duck type protocol describing an AIOKafkaConsumer or equivalent."""

def __init__(
def __init__( # noqa: PLR0913
self,
*topics: Ascii,
bootstrap_servers: str,
Expand Down
2 changes: 1 addition & 1 deletion src/hexkit/providers/mongodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
and associated utilities.
"""

from .provider import MongoDbConfig, MongoDbDaoFactory # noqa: F401
from .provider import MongoDbConfig, MongoDbDaoFactory

__all__ = ["MongoDbConfig", "MongoDbDaoFactory"]
19 changes: 9 additions & 10 deletions src/hexkit/providers/mongodb/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
Utilities for testing are located in `./testutils.py`.
"""

# ruff: noqa: PLR0913

import json
from abc import ABC
from collections.abc import AsyncGenerator, AsyncIterator, Collection, Mapping
from contextlib import AbstractAsyncContextManager
from typing import Any, Generic, Optional, Union, overload

from motor.motor_asyncio import (
AsyncIOMotorClient,
AsyncIOMotorClientSession,
AsyncIOMotorCollection,
)
from motor.core import AgnosticClientSession, AgnosticCollection
from motor.motor_asyncio import AsyncIOMotorClient
from pydantic import BaseSettings, Field, SecretStr

from hexkit.protocols.dao import (
Expand Down Expand Up @@ -59,8 +58,8 @@ def __init__(
*,
dto_model: type[Dto],
id_field: str,
collection: AsyncIOMotorCollection,
session: Optional[AsyncIOMotorClientSession] = None,
collection: AgnosticCollection,
session: Optional[AgnosticClientSession] = None,
):
"""Initialize the DAO.
Expand Down Expand Up @@ -260,9 +259,9 @@ def __init__(
dto_model: type[Dto],
dto_creation_model: type[DtoCreation_contra],
id_field: str,
collection: AsyncIOMotorCollection,
collection: AgnosticCollection,
id_generator: AsyncGenerator[str, None],
session: Optional[AsyncIOMotorClientSession] = None,
session: Optional[AgnosticClientSession] = None,
):
"""Initialize the DAO.
Expand Down Expand Up @@ -408,7 +407,7 @@ def __init__(
)
self._db = self._client[self._config.db_name]

def __repr__(self) -> str:
def __repr__(self) -> str: # noqa: D105
return f"{self.__class__.__qualname__}(config={repr(self._config)})"

@overload
Expand Down
2 changes: 1 addition & 1 deletion src/hexkit/providers/s3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"""

# shortcuts:
from hexkit.providers.s3.provider import S3Config, S3ObjectStorage # noqa: F401
from hexkit.providers.s3.provider import S3Config, S3ObjectStorage

__all__ = ["S3Config", "S3ObjectStorage"]
Loading

0 comments on commit 2d42898

Please sign in to comment.