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

[project]
name = "python-jsonpath"
description = 'JSONPath, JSON Pointer and JSON Patch for Python.'
readme = "README.md"
requires-python = ">=3.8"
license = "MIT"
keywords = ["JSON", "JSONPath", "JSON Path", "JSON Pointer", "JSON Patch", "RFC 9535"]
authors = [{ name = "James Prior", email = "jamesgr.prior@gmail.com" }]
classifiers = [
  "Development Status :: 5 - Production/Stable",
  "Intended Audience :: Developers",
  "License :: OSI Approved :: MIT License",
  "Programming Language :: Python",
  "Programming Language :: Python :: 3.8",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Programming Language :: Python :: 3.13",
  "Programming Language :: Python :: 3.14",
  "Programming Language :: Python :: Implementation :: CPython",
  "Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = []
dynamic = ["version"]

[project.urls]
Documentation = "https://jg-rp.github.io/python-jsonpath/"
Issues = "https://github.com/jg-rp/python-jsonpath/issues"
Source = "https://github.com/jg-rp/python-jsonpath"

[project.optional-dependencies]
strict = ["regex", "iregexp-check>=0.1.4"]

[tool.hatch.version]
path = "jsonpath/__about__.py"

[project.scripts]
json = "jsonpath.cli:main"

[tool.hatch.build.targets.sdist]
include = ["/jsonpath"]

[tool.hatch.build.targets.wheel]
include = ["/jsonpath"]

[tool.hatch.envs.default]
dependencies = [
  "pytest",
  "pytest-cov",
  "mypy",
  "regex",
  "iregexp-check",
  "pyyaml",
  "types-pyyaml",
  "types-regex",
  "twine",
  "ruff",
]

[tool.hatch.envs.default.scripts]
cov = [
  "hatch run no-regex:cov",
  "pytest --cov-append --cov-report=term-missing --cov-config=pyproject.toml --cov=jsonpath --cov=tests {args}"
]
cov-html = [
  "hatch run no-regex:cov",
  "pytest --cov-append --cov-report=html --cov-config=pyproject.toml --cov=jsonpath --cov=tests {args}",
]
no-cov = "cov --no-cov {args}"
test = "pytest {args}"
lint = "ruff check ."
typing = "mypy"

[[tool.hatch.envs.test.matrix]]
python = ["38", "39", "310", "311", "312", "313", "314", "pypy38", "pypy39"]

[tool.hatch.envs.test.scripts]
test = "pytest {args}"

[tool.hatch.envs.docs]
dependencies = ["black", "mkdocs", "mkdocstrings[python]", "mkdocs-material"]

[tool.hatch.envs.docs.scripts]
build = "mkdocs build --clean --strict"
serve = "mkdocs serve --dev-addr localhost:8000"

[tool.hatch.envs.no-regex]
dependencies = ["pytest", "pytest-cov"]

[tool.hatch.envs.no-regex.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=jsonpath --cov=tests tests/test_compliance.py {args}"


[tool.coverage.run]
branch = true
parallel = true
omit = ["jsonpath/__about__.py", "tests/compliance.py", "tests/consensus.py"]

[tool.coverage.report]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]

[tool.mypy]
files = ["jsonpath", "tests"]
exclude = ["tests/nts", "tests/cts"]
python_version = "3.11"
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
no_implicit_optional = true
local_partial_types = true
no_implicit_reexport = true
strict = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = false
warn_return_any = true
warn_unreachable = true


[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
  ".bzr",
  ".direnv",
  ".eggs",
  ".git",
  ".hg",
  ".mypy_cache",
  ".nox",
  ".pants.d",
  ".pytype",
  ".ruff_cache",
  ".svn",
  ".tox",
  ".venv",
  "__pypackages__",
  "_build",
  "buck-out",
  "build",
  "dist",
  "node_modules",
  "venv",
]

# Same as Black.
line-length = 88


# Assume Python 3.10.
target-version = "py310"

[tool.ruff.lint]
select = [
  "A",
  "ARG",
  "B",
  "BLE",
  "C4",
  "D",
  "E",
  "F",
  "FBT",
  "I",
  "ICN",
  "ISC",
  "N",
  "PIE",
  "PL",
  "PT",
  "Q",
  "RET",
  "RSE",
  "S",
  "SIM",
  "SLF",
  "T10",
  "T20",
  "TCH",
  "TID",
  "YTT",
]

ignore = ["S105", "S101", "D107", "D105", "PLR0913", "SIM108", "PT001", "A005"]

fixable = ["I"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.lint.isort]
force-single-line = true

[tool.ruff.lint.pydocstyle]
convention = "google"


[tool.ruff.lint.per-file-ignores]
"jsonpath/__about__.py" = ["D100"]
"jsonpath/__init__.py" = ["D104"]
"jsonpath/selectors.py" = ["D102"]
"jsonpath/filter.py" = ["D102", "PLW1641"]
"jsonpath/unescape.py" = ["PLR2004"]
"tests/*" = ["D100", "D101", "D104", "D103"]
