[project]
name = "symphra-modules"
version = "0.1.0"
description = "高性能、高质量的 Python 模块管理库，支持动态加载、生命周期管理、依赖解析和异步操作"
readme = "README.md"
authors = [
    { name = "mpf", email = "rafit@qq.com" }
]
requires-python = ">=3.11"
dependencies = []
license = { text = "MIT" }
keywords = ["module", "plugin", "loader", "manager", "async"]
classifiers = [
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: MIT License",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Topic :: Software Development :: Libraries :: Python Modules",
]

[project.urls]
Homepage = "https://github.com/getaix/symphra-modules"
Documentation = "https://getaix.github.io/symphra-modules"
Repository = "https://github.com/getaix/symphra-modules.git"
Issues = "https://github.com/getaix/symphra-modules/issues"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
    "pytest>=8.0.0",
    "pytest-asyncio>=0.23.0",
    "pytest-cov>=4.1.0",
    "pytest-mock>=3.12.0",
    "ruff>=0.8.0",
    "mypy>=1.8.0",
    "pre-commit>=3.6.0",
    "mkdocs>=1.5.0",
    "mkdocs-material>=9.5.0",
    "mkdocstrings[python]>=0.24.0",
    "mkdocs-i18n>=0.4.0",
]

# Ruff 配置
[tool.ruff]
target-version = "py311"
line-length = 120

[tool.ruff.lint]
select = [
    "E",   # pycodestyle errors
    "W",   # pycodestyle warnings
    "F",   # pyflakes
    "I",   # isort
    "N",   # pep8-naming
    "UP",  # pyupgrade
    "B",   # flake8-bugbear
    "C4",  # flake8-comprehensions
    "SIM", # flake8-simplify
    "TCH", # flake8-type-checking
]
ignore = [
    "E501",  # 行长度由 formatter 处理
    "B008",  # 函数调用中的默认参数
    "N818",  # 异常命名约定（我们允许 NotFoundException）
    "B027",  # 空方法但无 abstract 装饰器（我们的设计是可选覆盖）
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]  # 允许未使用的导入
"tests/**/*.py" = ["S101"]  # 允许测试中使用 assert

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

# Mypy 配置
[tool.mypy]
python_version = "3.11"
strict = true
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_incomplete_defs = true
check_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true

[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false

# Pytest 配置
[tool.pytest.ini_options]
minversion = "8.0"
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
    "-ra",
    "--strict-markers",
    "--strict-config",
    "--cov=symphra_modules",
    "--cov-report=term-missing",
    "--cov-report=html",
    "--cov-report=xml",
]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"

# Coverage 配置
[tool.coverage.run]
source = ["src"]
branch = true
omit = [
    "tests/*",
    "*/conftest.py",
]

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "def __repr__",
    "raise AssertionError",
    "raise NotImplementedError",
    "if __name__ == .__main__.:",
    "if TYPE_CHECKING:",
    "class .*\\bProtocol\\):",
    "@(abc\\.)?abstractmethod",
    "def __getattr__",  # 排除懒加载函数
    "raise AttributeError",  # 排除属性错误
]
precision = 2
fail_under = 80  # 降低到合理的80%
