[project]
name = "{{ project.name }}"
version = "{{ project.version }}"
description = "{{ project.description }}"
{% if project.authors %}
authors = [{% for author in project.authors %}{name = "{{ author.split('<')[0].strip() }}"{% if '<' in author %}, email = "{{ author.split('<')[1].replace('>', '').strip() }}"{% endif %}}{% if not loop.last %}, {% endif %}{% endfor %}]
{% else %}
authors = [{name = "Your Name", email = "you@example.com"}]
{% endif %}
readme = "{{ project.readme }}"
requires-python = ">={{ project.python_version }}"
{% if project.license %}
license = "{{ project.license }}"
{% endif %}
dependencies = [
{% for pkg in dependencies.main %}
    "{{ pkg }}",
{% endfor %}
]

{% if entry_points %}
[project.scripts]
{% for ep in entry_points %}
{{ ep.name }} = "{{ ep.module }}"
{% endfor %}
{% endif %}

{% if testing.enabled or formatting.enabled or dependencies.dev %}
[dependency-groups]
dev = [
{% if testing.enabled %}
{% if testing.framework == "pytest" %}
    "pytest>=8.3.0",
{% if testing.coverage %}
    "pytest-cov>=4.1.0",
{% endif %}
{% endif %}
{% endif %}
{% if formatting.enabled %}
{% if formatting.tool == "ruff" %}
    "ruff>=0.8.0",
{% elif formatting.tool == "black" %}
    "black>=24.0.0",
{% endif %}
{% endif %}
{% if typing_level in ["basic", "strict"] %}
{% if formatting.type_checker == "mypy" %}
    "mypy>=1.13.0",
{% elif formatting.type_checker == "pyright" %}
    "pyright>=1.1.400",
{% elif formatting.type_checker == "ty" %}
    "ty>=0.0.1a7",
{% endif %}
{% endif %}
{% if formatting.radon %}
    "radon>=6.0.0",
{% endif %}
{% if formatting.version_bumping %}
    "bump-my-version>=0.31.0",
{% endif %}
{% for pkg in dependencies.dev %}
    "{{ pkg }}",
{% endfor %}
]
{% endif %}

{% if formatting.enabled and formatting.tool == "ruff" %}
[tool.ruff]
line-length = {{ formatting.line_length }}
target-version = "py{{ project.python_version | replace('.', '') }}"

[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B", "SIM"{% if typing_level == "strict" %}, "TCH"{% endif %}]
{% endif %}

{% if typing_level in ["basic", "strict"] %}
{% if formatting.type_checker == "mypy" %}
[tool.mypy]
python_version = "{{ project.python_version }}"
{% if typing_level == "strict" %}
strict = true
warn_return_any = true
warn_unused_ignores = true
{% else %}
check_untyped_defs = true
{% endif %}
{% elif formatting.type_checker == "pyright" %}
[tool.pyright]
pythonVersion = "{{ project.python_version }}"
{% if typing_level == "strict" %}
typeCheckingMode = "strict"
{% else %}
typeCheckingMode = "basic"
{% endif %}
{% elif formatting.type_checker == "ty" %}
[tool.ty]
python-version = "{{ project.python_version }}"
{% endif %}
{% endif %}

{% if formatting.radon %}
[tool.radon]
cc_min = "B"
show_complexity = true
{% endif %}

{% if formatting.version_bumping %}
[tool.bumpversion]
current_version = "{{ project.version }}"
commit = true
tag = true
tag_name = "v{new_version}"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = 'version = "{current_version}"'
replace = 'version = "{new_version}"'

{% if layout == "src" %}
[[tool.bumpversion.files]]
filename = "src/{{ project.package_name }}/__init__.py"
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
{% else %}
[[tool.bumpversion.files]]
filename = "{{ project.package_name }}/__init__.py"
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
{% endif %}
{% endif %}

{% if testing.enabled and testing.framework == "pytest" %}
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
{% if testing.coverage %}
addopts = "--cov={{ project.package_name }} --cov-report=term-missing"
{% endif %}
{% endif %}

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
{% if layout == "src" %}

[tool.hatch.build.targets.wheel]
packages = ["src/{{ project.package_name }}"]
{% endif %}
