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

[project]
name = "dagger-io"
dynamic = ["version"]
description = "A client package for running Dagger pipelines in Python."
readme = "README.md"
license = "Apache-2.0"
authors = [
    {name = "Dagger", email = "hello@dagger.io"},
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "Framework :: AnyIO",
    "Framework :: Pytest",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3 :: Only",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "License :: OSI Approved :: Apache Software License",
    "Operating System :: OS Independent",
    "Typing :: Typed",
]
requires-python = ">=3.10"
dependencies = [
    "anyio>=3.6.2",
    "cattrs>=22.2.0",
    "graphql-core>=3.2.3",
    "gql[httpx]>=3.5.0",
    "beartype>=0.11.0",
    "platformdirs>=2.6.2",
    "typing_extensions>=4.8.0",
    "rich>=10.11.0",
]

[project.urls]
"Homepage" = "https://dagger.io"
"Documentation" = "https://docs.dagger.io/sdk/python"
"Repository" = "https://github.com/dagger/dagger/tree/main/sdk/python"
"Tracker" = "https://github.com/dagger/dagger/issues"
"Release Notes" = "https://github.com/dagger/dagger/releases?q=tag%3Asdk%2Fpython%2Fv0"
"Community" = "https://discord.gg/ufnyBtc8uY"
"Twitter" = "https://twitter.com/dagger_io"

[tool.hatch.version]
source = "vcs"
fallback-version = "0.0.0"

[tool.hatch.build.targets.sdist]
only-include = [
    "src",
    "tests",
    "docs",
    "CHANGELOG.md",
]

[tool.hatch.build.targets.wheel]
packages = ["src/dagger"]

[tool.pytest.ini_options]
testpaths = ["tests/"]
addopts = [
    "--import-mode=importlib",
]
markers = [
    "slow: mark test as slow (integration)",
    "provision: mark provisioning tests",
]

[tool.mypy]
disallow_untyped_defs = false
follow_imports = "normal"
# ignore_missing_imports = true
install_types = true
non_interactive = true
warn_redundant_casts = true
pretty = true
show_column_numbers = true
warn_no_return = false
warn_unused_ignores = true

[tool.black]
include = '\.pyi?$'
target-version = ["py310", "py311"]

[tool.ruff]
src = ["src", "tests", "dev/src"]
ignore-init-module-imports = true
target-version = "py310"
select = ["ALL"]
ignore = [
    # Type inferrance is ok in a lot of places.
    "ANN",
    # This rule doesn't know to ignore a subclass override
    # so we get false positives for unused arguments.
    "ARG002",
    # Black can handle trailing commas automatically.
    "COM812",
    # Can't control using a library with boolean arguments.
    "FBT",
    # TODO: Document public modules and packages.
    "D100",
    "D104",
    # Imperative mood only makes sense in functions, not classes.
    "D401",
    # Not using timezones in this project.
    "DTZ",
    # Allow logging with default %. You need custom setup to use `extra`.
    "G002",
    # Valid use in pytest, docs and examples.
    "INP001",
    # Unnecessary variable assignment before `return` statement
    # doesn't seem to work as expected.
    "RET504",
    # We don't use asserts as runtime validation guarantees.
    "S101",
    # Don't guard types. Don't want to stringize them.
    "TCH",
    # Don't require author and link in TODO comments.
    "TD002",
    "TD003",
    "FIX002",
    # Pandas
    "PD",
]
unfixable = [
    # Don't remove `print` statements, just warn.
    "T201",
]

[tool.ruff.isort]
known-first-party = ["dagger"]

[tool.ruff.per-file-ignores]
"./docs/*" = ["D1"]
"./runtime/*" = ["D1"]
"./src/dagger/client/gen.py" = [
    # Not much control over field names and docs coming from the API.
    # Note: We could detect built-in shadowing like the reserved
    # keywords but these built-ins aren't being used in the generated
    # code so no need to bother.
    "A",
    "D",
    # Too hard to properly wrap long lines in codegen.
    "E501",
    # Allow access to private members as it's controlled by our own library.
    "SLF001",
    # Too many arguments to function call.
    "PLR0913",
    # `Optional` is preferred over `| None` because of how
    # beartype handles forward references.
    "UP007",
]
# Ignore built-in shadowing in test mocks.
"./tests/client/test_inputs.py" = ["A", "ERA001"]
"./tests/*.py" = [
    # Ignore security issues in tests.
    "S",
    # Magic value comparison doesn't apply to tests.
    "PLR2004",
    # Allow more than one statement in pytest.raises.
    "PT012",
    # No public interfaces.
    "D1",
    # Allow accessing private fields in tests.
    "SLF001",
    # Allow covering `Optional` in tests.
    "UP007",
]
# Allow alias imports in __init__.
"./**/__init__.py" = ["PLC0414"]
# Allow some patterns to redefine imports in __init__.
"./src/**/__init__.py" = ["I001", "F403", "PLC0414"]
# Typer uses boolean parameters for the CLI. Let it.
"./src/**/cli.py" = ["FBT"]

[tool.ruff.pydocstyle]
convention = "numpy"
