Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ relative_files = true
source = ["src"]
omit = [
"**/__init__.py",
"src/app/config/logging_.py",
"src/app/main/**",
"**/health/**",
"**/alembic/**",
Expand Down Expand Up @@ -97,14 +96,13 @@ type = "layers"
containers = ["app"]
layers = [
"(main)",
"(config)",
"presentation",
"infrastructure",
"core",
]
ignore_imports = [
"app.infrastructure.persistence_sqla.alembic.env -> app.config.loader",
"app.infrastructure.persistence_sqla.alembic.env -> app.config.settings",
"app.infrastructure.persistence_sqla.alembic.env -> app.main.config.loader",
"app.infrastructure.persistence_sqla.alembic.env -> app.main.config.settings",
]

[[tool.importlinter.contracts]]
Expand Down
4 changes: 2 additions & 2 deletions src/app/infrastructure/persistence_sqla/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from sqlalchemy.engine import Connection
from sqlalchemy.ext.asyncio import async_engine_from_config

from app.config.loader import load_postgres_settings
from app.config.settings import PostgresSettings
from app.main.config.loader import load_postgres_settings
from app.main.config.settings import PostgresSettings
from app.infrastructure.persistence_sqla.mappings.all import map_tables
from app.infrastructure.persistence_sqla.registry import mapper_registry

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/app/config/loader.py → src/app/main/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic_settings import BaseSettings, SettingsConfigDict

from app.config.settings import (
from app.main.config.settings import (
AppSettings,
CookieSettings,
JwtSettings,
Expand All @@ -13,7 +13,7 @@
SqlaSettings,
)

BASE_DIR: Final[Path] = Path(__file__).resolve().parents[3]
BASE_DIR: Final[Path] = Path(__file__).resolve().parents[4]
_ENV_FILE: Final[Path] = BASE_DIR.joinpath(".env")
_DEFAULT_CONFIG_DICT: Final[SettingsConfigDict] = SettingsConfigDict(
env_file=_ENV_FILE,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import BaseModel, Field, PostgresDsn

from app.config.logging_ import LoggingLevel
from app.infrastructure.auth_ctx.jwt_types import JwtAlgorithm
from app.main.config.logging_ import LoggingLevel


class AppSettings(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion src/app/main/ioc/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from dishka import Provider, Scope, provide

from app.config.settings import PasswordHasherSettings
from app.core.commands.activate_user import ActivateUser
from app.core.commands.create_user import CreateUser
from app.core.commands.deactivate_user import DeactivateUser
Expand Down Expand Up @@ -31,6 +30,7 @@
from app.infrastructure.adapters.sqla_user_reader import SqlaUserReader
from app.infrastructure.adapters.sqla_user_tx_storage import SqlaUserTxStorage
from app.infrastructure.adapters.system_utc_timer import SystemUtcTimer
from app.main.config.settings import PasswordHasherSettings


class CoreProvider(Provider):
Expand Down
16 changes: 8 additions & 8 deletions src/app/main/ioc/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker, create_async_engine
from starlette.requests import Request

from app.config.settings import (
CookieSettings,
JwtSettings,
PasswordHasherSettings,
PostgresSettings,
SessionSettings,
SqlaSettings,
)
from app.infrastructure.adapters.bcrypt_password_hasher import HasherSemaphore, HasherThreadPoolExecutor
from app.infrastructure.auth_ctx.cookie_manager import CookieManager, CookieName
from app.infrastructure.auth_ctx.handlers.change_password import ChangePassword
Expand All @@ -29,6 +21,14 @@
from app.infrastructure.auth_ctx.sqla_user_tx_storage import AuthSqlaUserTxStorage
from app.infrastructure.auth_ctx.types_ import AuthAsyncSession
from app.infrastructure.auth_ctx.utc_timer import AuthSessionUtcTimer
from app.main.config.settings import (
CookieSettings,
JwtSettings,
PasswordHasherSettings,
PostgresSettings,
SessionSettings,
SqlaSettings,
)

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions src/app/main/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from dishka.integrations.fastapi import setup_dishka
from fastapi import FastAPI

from app.config.loader import (
from app.infrastructure.persistence_sqla.mappings.all import map_tables
from app.main.config.loader import (
load_app_settings,
load_cookie_settings,
load_jwt_settings,
Expand All @@ -14,7 +15,7 @@
load_session_settings,
load_sqla_settings,
)
from app.config.settings import (
from app.main.config.settings import (
AppSettings,
CookieSettings,
JwtSettings,
Expand All @@ -23,7 +24,6 @@
SessionSettings,
SqlaSettings,
)
from app.infrastructure.persistence_sqla.mappings.all import map_tables
from app.main.ioc.provider_registry import get_providers
from app.main.setup import setup_global_exception_handlers, setup_logging, setup_middlewares
from app.presentation.http.root_router import make_fastapi_root_router
Expand Down
4 changes: 2 additions & 2 deletions src/app/main/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from fastapi import FastAPI

from app.config.logging_ import DATEFMT, FMT, LoggingLevel
from app.config.settings import CookieSettings
from app.main.config.logging_ import DATEFMT, FMT, LoggingLevel
from app.main.config.settings import CookieSettings
from app.presentation.http.auth_cookie_middleware import AuthCookieMiddleware

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/with_infra/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker

from app.config.settings import AppSettings
from app.core.common.services.user import UserService
from app.infrastructure.persistence_sqla.registry import mapper_registry
from app.main.config.settings import AppSettings
from app.main.run import make_app

LIFESPAN_MANAGER_STARTUP_TIMEOUT_S: Final[int] = 30
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/with_infra/test_stairway.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from alembic.config import Config
from alembic.script import Script, ScriptDirectory

from app.config.loader import BASE_DIR, load_postgres_settings
from app.config.settings import PostgresSettings
from app.main.config.loader import BASE_DIR, load_postgres_settings
from app.main.config.settings import PostgresSettings

ALEMBIC_INI_PATH: Final[str] = str(BASE_DIR / "alembic.ini")

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.config.loader import BASE_DIR
from app.main.config.loader import BASE_DIR


def test_base_dir_points_to_root() -> None:
Expand Down
Empty file added tests/unit/main/__init__.py
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from app.config.loader import (
from app.main.config.loader import (
load_app_settings,
load_cookie_settings,
load_jwt_settings,
Expand All @@ -9,7 +9,7 @@
load_session_settings,
load_sqla_settings,
)
from app.config.logging_ import LoggingLevel
from app.main.config.logging_ import LoggingLevel


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from app.config.settings import SessionSettings
from app.main.config.settings import SessionSettings


@pytest.mark.parametrize(
Expand Down