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

[project]
name = "tablesleuth"
version = "0.6.1"
description = "TableSleuth - a Textual TUI for Open Table Format forensics (Iceberg, Delta Lake) with data profiling."
readme = "README.md"
requires-python = ">=3.13,<3.15"
license = { text = "Apache-2.0" }
authors = [
    { name = "James Conner", email = "jamesbconner@gmail.com" }
]
keywords = [
    "iceberg",
    "delta-lake",
    "parquet",
    "duckdb",
    "tui",
    "textual",
    "data-engineering",
    "s3",
    "s3tables",
    "aws",
    "data-profiling",
    "data-quality",
    "metadata",
    "schema",
    "analytics",
    "lakehouse",
    "data-lake",
    "pyarrow",
    "terminal",
    "cli",
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Environment :: Console",
    "Intended Audience :: Developers",
    "Intended Audience :: System Administrators",
    "License :: OSI Approved :: Apache Software License",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.13",
    "Programming Language :: Python :: 3.14",
    "Programming Language :: Python :: 3 :: Only",
    "Topic :: Database",
    "Topic :: File Formats",
    "Topic :: Scientific/Engineering",
    "Topic :: Scientific/Engineering :: Information Analysis",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Topic :: System :: Benchmark",
    "Topic :: System :: Distributed Computing",
    "Topic :: System :: Monitoring",
    "Topic :: Utilities",
    "Typing :: Typed",
]

# Table format support
dependencies = [
    "pyiceberg[s3fs,sql-sqlite,glue]>=0.11.0",
    "deltalake>=1.4.2",
    "textual>=0.86.2",
    "pyarrow>=23.0.0",
    "pandas>=3.0.1",
    "adbc-driver-flightsql>=1.10.0",
    "click>=8.3.1",
    "pydantic>=2.12.5",
    "pyyaml>=6.0.0",
    "rich>=14.3.3",
    "sqlalchemy>=2.0.46",
    "duckdb>=1.4.4",
    "boto3>=1.35.0",
    "pip>=25.0",
    "uv>=0.10.4",
]

[project.optional-dependencies]
web = [
    "fastapi>=0.131.0",
    "uvicorn[standard]>=0.32.0",
    "python-multipart>=0.0.12",
    "fastavro>=1.9.0",
]

dev = [
    "pytest>=8.4.2,<9.0.0",
    "httpx>=0.27.0",
    "pytest-asyncio>=0.26.0,<1.0.0",
    "pytest-cov>=6.0.0,<7.0.0",
    "hypothesis>=6.100.0,<7.0.0",
    "ruff>=0.14.4,<0.15.0",
    "mypy>=1.18.2,<2.0.0",
    "textual-dev>=1.7.0,<2.0.0",
    "types-toml",
    "types-PyYAML",
    "pre-commit>=4.4.0,<5.0.0",
    "bandit[toml]>=1.8.6,<2.0.0",
    "twine>=5.0.0,<6.0.0",
    "build>=1.0.0,<2.0.0",
]

[project.scripts]
tablesleuth = "tablesleuth.cli:entry_point"

[project.urls]
Homepage = "https://tablesleuth.com"
Repository = "https://github.com/jamesbconner/TableSleuth"
Documentation = "https://github.com/jamesbconner/TableSleuth/tree/main/docs"
"Bug Reports" = "https://github.com/jamesbconner/TableSleuth/issues"
Changelog = "https://github.com/jamesbconner/TableSleuth/blob/main/CHANGELOG.md"

# Hatchling configuration for src layout
[tool.hatch.build.targets.wheel]
packages = ["src/tablesleuth"]
exclude = ["src/tablesleuth/web/.gitkeep"]

[tool.hatch.build.targets.wheel.force-include]
"src/tablesleuth/web" = "tablesleuth/web"

[tool.hatch.build.targets.sdist.force-include]
"src/tablesleuth/web" = "src/tablesleuth/web"

# -----------------------
# Ruff configuration
# -----------------------
[tool.ruff]
target-version = "py313"
src = ["src", "tests"]
line-length = 100
indent-width = 4

[tool.ruff.lint]
select = [
  "E",   # pycodestyle errors
  "F",   # pyflakes
  "I",   # import sorting
  "B",   # bugbear
  "UP",  # pyupgrade
]
ignore = [
  "E203",  # whitespace before :
  "E501",  # line length (handled by formatter / your judgment)
  "F401",  # unused imports (common in stubs/WIP)
  "F841",  # unused variables (common in stubs/WIP)
  "F811",  # redefinition of unused name
  "B008",  # function calls in argument defaults
  "UP007", # use X | Y for type annotations (prefer Optional for clarity)
  "UP035", # typing.Dict/List -> dict/list (allow both styles)
]

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

# -----------------------
# mypy configuration
# -----------------------
[tool.mypy]
python_version = "3.13"
mypy_path = "src"
namespace_packages = true
explicit_package_bases = true

# Strict type checking
check_untyped_defs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_calls = true
disallow_untyped_decorators = false  # Allow untyped decorators (e.g., @click.command)
no_implicit_optional = true
strict_optional = true

# Warnings
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
warn_return_any = true
warn_unreachable = true

# Error reporting
show_error_codes = true
show_error_context = true
pretty = true

# Disable for third-party libraries without stubs
ignore_missing_imports = false

# Per-module overrides for third-party libraries
[[tool.mypy.overrides]]
module = [
    "pyiceberg.*",
    "deltalake.*",
    "adbc_driver_flightsql.*",
    "textual.*",
    "boto3.*",
    "botocore.*",
    "pyarrow.*",
    "fastavro.*",
    "fsspec.*",
    "s3fs.*",
    "fastapi.*",
    "uvicorn.*",
]
ignore_missing_imports = true

# -----------------------
# pytest configuration
# -----------------------
[tool.pytest.ini_options]
minversion = "8.0"
addopts = "-ra -q"
testpaths = ["tests"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
pythonpath = ["src"]

# Optional markers you might use later
markers = [
  "integration: marks tests as integration tests",
  "slow: marks tests as slow",
]

# Filter out third-party deprecation warnings from dependencies
# This error is being emitted from the pyiceberg 0.10.0 library
# TODO: Review this filter in the future when pyiceberg is upated
filterwarnings = [
  "ignore::pydantic.warnings.PydanticDeprecatedSince212",
  # Ignore unclosed database warnings from Textual's internal caching mechanisms
  # This is a known issue with Textual's internal SQLite caching (FIFOCache, etc.)
  # The connections are cleaned up by garbage collection but warnings appear in test runs
  "ignore:unclosed database:ResourceWarning",
]

# -----------------------
# bandit configuration
# -----------------------
[tool.bandit]
targets = ["src"]
exclude_dirs = ["tests", ".venv", "venv"]
skips = ["B101"]  # Skip assert_used check (common in tests)
