[build-system]
requires = ["hatchling>=1.18.0", "hatch-vcs>=0.3.0"]
build-backend = "hatchling.build"

[project]
name = "openrouter-inspector"
dynamic = ["version"]
description = "A command-line tool for querying OpenRouter AI models and providers"
readme = "README.md"
license = {file = "LICENSE"}
authors = [
    {name = "Mateusz B.", email = "matdev83@github.com"}
]
maintainers = [
    {name = "Mateusz B.", email = "matdev83@github.com"}
]
keywords = ["openrouter", "ai", "cli", "models", "api"]
classifiers = [
    "Development Status :: 3 - Alpha",
    "Environment :: Console",
    "Intended Audience :: Developers",
    "Intended Audience :: System Administrators",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
    "Topic :: Scientific/Engineering :: Artificial Intelligence",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Topic :: System :: Monitoring",
    "Topic :: Utilities",
    "Typing :: Typed",
]
requires-python = ">=3.10"
dependencies = [
    "click>=8.0.0",
    "httpx>=0.24.0",
    "pydantic>=2.0.0",
    "rich>=13.0.0",
    "tiktoken>=0.5.0",
    "tomli>=2.0.1; python_version < \"3.11\"",
]

[project.optional-dependencies]
# Development dependencies
dev = [
    "black>=23.0.0",
    "ruff>=0.1.0",
    "mypy>=1.0.0",
    "pre-commit>=3.0.0",
    "vulture>=2.0",
    "bandit[toml]>=1.7.5",
    "safety>=3.2.0",
]

# Testing dependencies
test = [
    "pytest>=7.0.0",
    "pytest-asyncio>=0.21.0",
    "pytest-cov>=4.0.0",
    "pytest-httpx>=0.21.0",
    "hypothesis>=6.0.0",
]

# Documentation dependencies
docs = [
    "mkdocs>=1.5.0",
    "mkdocs-material>=9.0.0",
    "mkdocstrings[python]>=0.20.0",
]

# Build and release dependencies
build = [
    "build>=0.10.0",
    "twine>=4.0.0",
    "wheel>=0.40.0",
    "hatch>=1.9.0",
    "hatchling>=1.18.0",
    "hatch-vcs>=0.3.0",
]

# Security tooling
security = [
    "bandit[toml]>=1.7.5",
    "safety>=3.2.0",
]

# Complete development environment
complete = [
    "black>=23.0.0",
    "ruff>=0.1.0", 
    "mypy>=1.0.0",
    "pre-commit>=3.0.0",
    "vulture>=2.0",
    "bandit[toml]>=1.7.5",
    "safety>=3.2.0",
    "pytest>=7.0.0",
    "pytest-asyncio>=0.21.0",
    "pytest-cov>=4.0.0",
    "pytest-httpx>=0.21.0",
    "hypothesis>=6.0.0",
    "mkdocs>=1.5.0",
    "mkdocs-material>=9.0.0",
    "mkdocstrings[python]>=0.20.0",
    "build>=0.10.0",
    "twine>=4.0.0",
    "wheel>=0.40.0",
    "hatch>=1.9.0",
    "hatchling>=1.18.0",
    "hatch-vcs>=0.3.0",
]

# Legacy alias for backwards compatibility
all = [
    "black>=23.0.0",
    "ruff>=0.1.0", 
    "mypy>=1.0.0",
    "pre-commit>=3.0.0",
    "vulture>=2.0",
    "bandit[toml]>=1.7.5",
    "safety>=3.2.0",
    "pytest>=7.0.0",
    "pytest-asyncio>=0.21.0",
    "pytest-cov>=4.0.0",
    "pytest-httpx>=0.21.0",
    "hypothesis>=6.0.0",
    "mkdocs>=1.5.0",
    "mkdocs-material>=9.0.0",
    "mkdocstrings[python]>=0.20.0",
    "build>=0.10.0",
    "twine>=4.0.0",
    "wheel>=0.40.0",
    "hatch>=1.9.0",
    "hatchling>=1.18.0",
    "hatch-vcs>=0.3.0",
]

[project.urls]
Homepage = "https://github.com/matdev83/openrouter-inspector/"
Repository = "https://github.com/matdev83/openrouter-inspector/"
Documentation = "https://github.com/matdev83/openrouter-inspector#readme"
"Bug Tracker" = "https://github.com/matdev83/openrouter-inspector/issues"

[project.scripts]
openrouter-inspector = "openrouter_inspector.__main__:main"

# Hatchling build configuration
[tool.hatch.build.targets.wheel]
packages = ["openrouter_inspector"]

[tool.hatch.build.targets.sdist]
include = [
    "/openrouter_inspector",
    "/tests",
    "/README.md",
    "/LICENSE",
    "/pyproject.toml",
]
exclude = [
    "/.github",
    "/.venv",
    "/dist",
    "/build",
    "**/__pycache__",
    "**/*.pyc",
    "**/*.pyo",
    "**/.pytest_cache",
    "**/.mypy_cache",
    "**/.coverage",
    "**/htmlcov",
]

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
# Extract version from tags like v1.2.3
tag-pattern = "^v(?P<version>.*)$"
version-file = "openrouter_inspector/_version.py"

# Hatch environments for development tasks
[tool.hatch.envs.default]
dependencies = [
    "black>=23.0.0",
    "ruff>=0.1.0", 
    "mypy>=1.0.0",
    "vulture>=2.0",
    "pre-commit>=3.0.0",
    "pytest>=7.0.0",
    "pytest-asyncio>=0.21.0",
    "pytest-cov>=4.0.0",
    "pytest-httpx>=0.21.0",
    "hypothesis>=6.0.0",
]

[tool.hatch.envs.default.scripts]
# Testing
test = "pytest {args:tests}"
test-cov = "pytest --cov=openrouter_inspector --cov-report=html --cov-report=term {args:tests}"
test-fast = "pytest -x {args:tests}"

# Code quality
lint = "ruff check {args:.}"
lint-fix = "ruff check --fix {args:.}"
format = "black {args:.}"
format-check = "black --check --diff {args:.}"
type-check = "mypy {args:openrouter_inspector}"
vulture-check = "vulture --min-confidence 80 {args:openrouter_inspector}"

# Combined QA
qa = ["format-check", "lint", "type-check", "vulture-check", "test"]
qa-fix = ["format", "lint-fix", "type-check", "vulture-check", "test"]

# Pre-commit
pre-commit-install = "pre-commit install"
pre-commit-run = "pre-commit run --all-files"

[tool.hatch.envs.build]
dependencies = [
    "build>=0.10.0",
    "twine>=4.0.0",
    "wheel>=0.40.0",
]

[tool.hatch.envs.build.scripts]
# Clean build artifacts
clean = [
    "python -c \"import shutil; import os; [shutil.rmtree(p, ignore_errors=True) for p in ['dist', 'build'] + [d for d in os.listdir('.') if d.endswith('.egg-info')]]\"",
]

# Build packages
build-wheel = "python -m build --wheel"
build-sdist = "python -m build --sdist" 
build-all = "python -m build"

# Validate packages
check = "twine check dist/*"
check-wheel = "python -m pip install --force-reinstall --no-deps dist/*.whl && python -c 'import openrouter_inspector; print(f\"Version: {openrouter_inspector.__version__}\")'"

# Upload packages
upload-test = "twine upload --repository testpypi dist/*"
upload = "twine upload dist/*"

# Complete build and check workflow
release-check = ["clean", "build-all", "check", "check-wheel"]

# Black configuration
[tool.black]
line-length = 88
target-version = ['py310']
include = '\.pyi?$'
extend-exclude = '''
/(
  # directories
  \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | build
  | dist
)/
'''

# Ruff configuration
[tool.ruff]
target-version = "py310"
line-length = 88

[tool.ruff.lint]
select = [
    "E",  # pycodestyle errors
    "W",  # pycodestyle warnings
    "F",  # pyflakes
    "I",  # import sorting
    "B",  # flake8-bugbear
    "C4", # flake8-comprehensions
    "UP", # pyupgrade
]
ignore = [
    "E501",  # line too long, handled by black
    "B008",  # do not perform function calls in argument defaults
    "C901",  # too complex
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"tests/integration/test_error_handling.py" = ["F821"]
"tests/unit/test_enhanced_services.py" = ["F821"]
".vulture_whitelist.py" = ["F821", "B018"]
# MyPy configuration
[tool.mypy]
python_version = "3.10"
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
strict_equality = true

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


# Pytest configuration
[tool.pytest.ini_options]
minversion = "7.0"
# By default, skip tests that require real network/API access.
addopts = "-ra -q --strict-markers --strict-config -m 'not network'"
testpaths = ["tests"]
markers = [
    "slow: marks tests as slow (deselect with '-m \"not slow\"')",
    "integration: marks tests as integration tests",
    "network: marks tests that perform real network/API calls (deselected by default)",
]
asyncio_default_fixture_loop_scope = "function"

# Coverage configuration
[tool.coverage.run]
source = ["openrouter_inspector"]
branch = true

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "def __repr__",
    "if self.debug:",
    "if settings.DEBUG",
    "raise AssertionError",
    "raise NotImplementedError",
    "if 0:",
    "if __name__ == .__main__.:",
    "class .*\\bProtocol\\):",
    "@(abc\\.)?abstractmethod",
]
show_missing = true
skip_covered = false
fail_under = 60
# Vulture configuration
[tool.vulture]
paths = ["openrouter_inspector"]
exclude = ["tests/"]
ignore_decorators = ["@click.command", "@click.group", "@click.option", "@click.argument"]
ignore_names = ["_*", "test_*"]
make_whitelist = true
min_confidence = 80
sort_by_size = true
# Bandit security configuration
[tool.bandit]
exclude_dirs = ["tests", ".venv", "build", "dist"]
skips = ["B101", "B601"]  # Skip assert_used and shell_injection_process_args

# Safety configuration for dependency vulnerability scanning
[tool.safety]
ignore = []