{%- if package_manager == "poetry" %}
[build-system]
requires = ["poetry-core>=1.9.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "{{ name }}"
version = "0.1.0"
description = "{{ name|capitalize }} backend project with {{ design|upper }} design pattern and {{ 'SQLAlchemy' if orm == 'sqlalchemy' else orm|capitalize }} ORM"
readme = "README.md"
packages = [{ include = "app", from = "src" }]

[tool.poetry.dependencies]
python = ">=3.11,<4.0"
robyn = ">=0.58.0"
asyncpg = ">=0.29.0"
redis = { version = ">=5.0.4", extras = ["hiredis"] }
pydantic = { version = ">=2.6.4", extras = ["email"] }
pydantic-settings = ">=2.2.1"
msgspec = ">=0.18.6"
PyJWT = ">=2.8.0"
loguru = ">=0.7.2"
passlib = ">=1.7.4"
bcrypt = "4.0.1"
aiosmtplib = ">=3.0.1"
starlette = ">=0.37.2"
sqlalchemy = { version = ">=2.0.29", extras = ["asyncio", "mypy"] }
alembic = ">=1.13.2"
tortoise-orm = ">=0.20.0"
aerich = { version = ">=0.9.2", extras = ["toml"] }

[tool.poetry.group.dev.dependencies]
black = ">=24.10.0"
isort = ">=6.0.0"
ruff = ">=0.4.1"
pytest = ">=7.4.0"
pytest-cov = ">=4.1.0"
coverage = { version = ">=7.5.0", extras = ["toml"] }
mypy = ">=1.10.0"
flake8 = ">=7.1.0"
aiosqlite = ">=0.21.0"
fakeredis = ">=2.22.4"
py-spy = ">=0.4.1"
{%- else %}
[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"

[project]
name = "{{ name }}"
version = "0.1.0"
description = "{{ name|capitalize }} backend project with {{ design|upper }} design pattern and {{ 'SQLAlchemy' if orm == 'sqlalchemy' else orm|capitalize }} ORM"
readme = "README.md"
requires-python = ">=3.11,<4.0"
dependencies = [
  "robyn>=0.58.0",
  "asyncpg>=0.29.0",
  "redis[hiredis]>=5.0.4",
  "pydantic[email]>=2.6.4",
  "pydantic-settings>=2.2.1",
  "msgspec>=0.18.6",
  "PyJWT>=2.8.0",
  "loguru>=0.7.2",
  "passlib>=1.7.4",
  "bcrypt==4.0.1",
  "aiosmtplib>=3.0.1",
  "starlette>=0.37.2",
  "SQLAlchemy[asyncio,mypy]>=2.0.29",
  "alembic>=1.13.2",
  "tortoise-orm>=0.20.0",
  "aerich[toml]>=0.9.2"
]

[project.optional-dependencies]
dev = [
  "black>=24.10.0",
  "isort>=6.0.0",
  "ruff>=0.4.1",
  "pytest>=7.4.0",
  "pytest-cov>=4.1.0",
  "coverage[toml]>=7.5.0",
  "mypy>=1.10.0",
  "flake8>=7.1.0",
  "aiosqlite>=0.21.0",
  "fakeredis>=2.22.4",
  "py-spy>=0.4.1"
]
{%- endif %}

{%- if package_manager != "poetry" %}
[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]
{%- endif %}

[tool.flake8]
max-line-length = 88
extend-ignore = "E203, E501"

[tool.ruff]
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "__pycache__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "venv",
    "migrations",
]
line-length = 79
src = ["src"]

[tool.ruff.lint]
select = ["E", "F"]
ignore = ["E501", "F403", "F811"]
fixable = [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "I",
    "N",
    "Q",
    "S",
    "T",
    "W",
    "ANN",
    "ARG",
    "BLE",
    "COM",
    "DJ",
    "DTZ",
    "EM",
    "ERA",
    "EXE",
    "FBT",
    "ICN",
    "INP",
    "ISC",
    "NPY",
    "PD",
    "PGH",
    "PIE",
    "PL",
    "PT",
    "PTH",
    "PYI",
    "RET",
    "RSE",
    "RUF",
    "SIM",
    "SLF",
    "TCH",
    "TID",
    "TRY",
    "UP",
    "YTT",
]
unfixable = []
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.black]
target-version = ["py312"]
line-length = 79
exclude = '''
(
  /(
      \.eggs         # exclude a few common directories in the
    | \.git          # root of the project
    | \.hg
    | \.mypy_cache
    | \.tox
    | \.venv
    | venv
    | _build
    | buck-out
    | build
    | dist
    | .tox
  )/
                     # the root of the project
)
'''

[tool.isort]
profile = "black"
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 79
skip = ["venv"]
src_paths = ["src"]

[tool.pytest.ini_options]
addopts = "-s -vvv --cache-clear --cov=./src/app --cov-report=term-missing --cov-report=html"
pythonpath = ["src", "."]
testpaths = ["tests"]
cache_dir = "/tmp/pytest_cache"
python_files = "test_*.py *_test.py"
python_functions = "test_* *_test"
filterwarnings = [
  "ignore::RuntimeWarning",
  "ignore::UserWarning",
  "ignore::DeprecationWarning",
]
markers = [
    "integration: marks tests as integration tests",
]

[tool.pyright]
exclude = ["**/__pycache__", "**/venv/*", "**/.tox/*"]
typeCheckingMode = "off"
useLibraryCodeForTypes = true

[tool.mypy]
ignore_missing_imports = true
explicit_package_bases = true
exclude = "(^|/)(migrations)(/|$)"
disable_error_code = ["no-redef"]

[tool.coverage.report]
omit = [
  "*/tests.py",
  "*/migrations/*",
  "asgi.py",
  "wsgi.py",
  "settings.py",
  "manage.py",
]

{%- if orm == "tortoise" %}
[tool.aerich]
tortoise_orm = "{{ tortoise_orm_path }}"
location = "{{ tortoise_migrations_location }}"
src_folder = "./."
{%- endif %}

[tool.robyn-config]
design = "{{ design }}"
orm = "{{ orm }}"
package_manager = "{{ package_manager }}"

{%- if design == "ddd" %}
[tool.robyn-config.add]
domain_path = "src/app/domain"
operational_path = "src/app/operational"
presentation_path = "src/app/presentation"
database_repository_path = "src/app/infrastructure/database/repository"
database_table_path = "src/app/infrastructure/database/tables.py"
{%- elif design == "mvc" %}
[tool.robyn-config.add]
views_path = "src/app/views"
database_repository_path = "src/app/models/repository.py"
database_table_path = "src/app/models/models.py"
{%- endif %}
