[build-system]
requires = ["flit-core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]

classifiers = [
    "Development Status :: 5 - Production/Stable",
    "Intended Audience :: Developers",
    "Framework :: Pytest",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Topic :: Utilities",
    "Topic :: Software Development :: Testing",
    "License :: OSI Approved :: MIT License",
]

keywords = ["testing", "pytest"]

name = "tavern"
description = "Simple testing of RESTful APIs"
version = "3.6.1"

dependencies = [
    "PyYAML>=6.0.1,<7",
    "jmespath>=1,<2",
    "jsonschema>=4,<5",
    "pyjwt>=2.5.0,<3",
    "pykwalify>=1.8.0,<2",
    "pytest>=8,<10",
    "python-box>=6,<7",
    "requests>=2.22.0,<3",
    "simpleeval>=1.0.3",
    "stevedore>=4,<5",
]

requires-python = ">=3.11"

[[project.authors]]
name = "Michael Boulton"

[project.license]
file = "LICENSE"

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.urls]
Home = "https://taverntesting.github.io/"
Documentation = "https://tavern.readthedocs.io/en/latest/"
Source = "https://github.com/taverntesting/tavern"

[project.optional-dependencies]
grpc = [
    "grpcio",
    "grpcio-reflection",
    "grpcio-status",
    "google-api-python-client",
    "protobuf>=5,<6",
    "proto-plus",
]

mqtt = [
    "paho-mqtt>=1.3.1,<=1.6.1",
]

graphql = [
    "aiohttp",
    "websockets",
    "gql>=4.0.0",
]

[dependency-groups]
dev = [
    "Faker",
    "allure-pytest",
    "colorlog",
    "flask>=3,<4",
    "fluent-logger",
    "itsdangerous",
    "coverage[toml]",
    "flit >=3.2,<4",
    "wheel",
    "pre-commit",
    "pytest-cov",
    "pytest-xdist",
    "py",
    "tox>4.20,<5",
    "ruff",
    "uv>=0.9.2",
    "types-PyYAML",
    # See https://pypi.org/project/protobuf/#history for compatability between these two
    "types-protobuf>=5,<6",
    "protobuf-protoc-bin==29.5",
    "grpcio-tools",
    "types-requests",
    "types-jsonschema",
    "types-paho-mqtt",
    "types-jmespath",
    "grpc-interceptor",
    # for pytest
    "exceptiongroup",
    "tomli",
    "tbump>=6.10.0",
    "tox-uv>=1.28.0",
    "pytest-asyncio>=1.3.0",
    "hypothesis>=6,<7",
    "pydantic",
    "flask-httpauth>=4.8.1,<6",
]

# When this is fixed, enable this https://github.com/jupyter-book/mystmd/issues/2082
# docs = ["mystmd"]

[project.scripts]

tavern-ci = "tavern.entry:main"

[project.entry-points.pytest11]

tavern = "tavern._core.pytest"

[project.entry-points.tavern_http]
requests = "tavern._plugins.rest.tavernhook:TavernRestPlugin"

[project.entry-points.tavern_mqtt]
paho-mqtt = "tavern._plugins.mqtt.tavernhook"

[project.entry-points.tavern_grpc]
grpc = "tavern._plugins.grpc.tavernhook"

[project.entry-points.tavern_graphql]
gql = "tavern._plugins.graphql.tavernhook"

[tool.mypy]
python_version = "3.11"

# See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules
explicit_package_bases = true

exclude = [
    '_pb2.pyi?$', # generated proto files
    'bazel-*',
    'venv/',
]

[tool.coverage.run]
branch = false
omit = [
    "tests/*",
    ".eggs/*",
    "env/*",
    "build/*",
    "dist/*",
]
source = ["tavern"]

[tool.coverage.paths]
tavern = [
    "tavern/",
    ".tox/py311-generic/lib/python3.11/site-packages/tavern/",
    ".tox/py311-mqtt/lib/python3.11/site-packages/tavern",
]

[tool.pytest.ini_options]
testpaths = ["tavern", "tests/unit"]
addopts = [
    "--doctest-modules",
    "-r", "xs",
    "-vv",
    "--strict-markers",
    "--tb=short",
    "--color=yes",
    "-m", "not do_not_run"
]
norecursedirs = [
    ".git",
    ".tox",
    ".venv",
    "example",
    "node_modules",
    "dist",
    "docs",
]
markers = [
    "slow: A test marker to check if markers work with custom markers",
    "xdist_group('group1'): A test marker to check if markers work with args",
    "do_not_run: Test marker for tests that should not be run",
]

[tool.ruff]
target-version = "py311"
extend-exclude = [
    "tests/unit/tavern_grpc/test_services_pb2*",
    "example/grpc/helloworld_v1_precompiled_pb2*"
]

[tool.ruff.lint]
ignore = [
    "UP045", "UP007", # Optional/Union
    "E501", # line length
    "RUF005", # union types only valid from 3.10+
    "B905", # zip(..., strict=True) only valid from 3.10+
    "PLR0912", "PLR0915", "PLR0911", "PLR0913", # too many branches/variables/return values - sometimes this is just unavoidable
    "PLR2004", # 'magic numbers'
    "PLW2901", # Loop variable overridden
    "PLC0415", # import not at top of file
]
select = ["E", "F", "B", "W", "I", "S", "C4", "ICN", "T20", "PLE", "RUF", "SIM105", "PL", "U"]

[tool.ruff.lint.per-file-ignores]
"example/*" = ["S"]
"tests/*" = ["S", "RUF"]
"scripts/*" = ["S603", "S607"]
"tests/unit/tavern_grpc/test_grpc.py" = ["E402"]

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

[tool.ruff.format]
exclude = ["*_pb2.py", "*_pb2_grpc.py", "*_pb2.pyi"]
docstring-code-format = true

[tool.tbump.version]
current = "3.6.1"

regex = '''
  (?P<major>\d+)
  \.
  (?P<minor>\d+)
  \.
  (?P<patch>\d+)
  ((?P<release>[a-zA-Z]+)(?P<build>\d+))?
  '''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "{new_version}"

[[tool.tbump.file]]
src = "tavern/__init__.py"

[[tool.tbump.file]]
src = "pyproject.toml"


[[tool.tbump.before_commit]]
name = "Update changelog"
cmd = "./scripts/update_changelog.py"
[[tool.tbump.before_commit]]
name = "Update lock"
cmd = "uv lock"

# TODO: enable
# [[tool.tbump.after_push]]
# name = "publish"
# cmd = "./scripts/release.sh"

[tool.tox]
runner = "uv-venv-lock-runner"
skip_missing_interpreters = true
isolated_build = true
base_python = "3.11"

[tool.uv]
constraint-dependencies = ["ruamel-yaml<0.19.0"]

[tool.uv.workspace]
members = [
    "example/mqtt",
    "example/grpc",
    "example/http",
    "example/graphql",
]
[tool.uv.sources]
tavern = { workspace = true }
tavern_mqtt_example = { workspace = true }
tavern_grpc_example = { workspace = true }
tavern_http_example = { workspace = true }
tavern_graphql_example = { workspace = true }
