[build-system]
requires = ["setuptools>=42", "wheel", "setuptools-git-versioning"]
build-backend = "setuptools.build_meta"

[project]
name = "dara-xrd"
description = "Data-driven automated Rietveld analysis using BGMN."
readme = "README.md"
version = "1.1.8"
keywords = [
    "rietveld",
    "search-match",
    "crystallography",
    "xrd",
    "bgmn",
    "x-ray",
]
license = "MIT"
authors = [
    { name = "Yuxing Fei", email = "yuxingfei@berkeley.edu" },
    { name = "Matthew McDermott", email = "mcdermott@lbl.gov" }
]
classifiers = [
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Intended Audience :: Science/Research",
    "Operating System :: OS Independent",
    "Topic :: Scientific/Engineering :: Information Analysis",
    "Topic :: Scientific/Engineering :: Physics",
    "Topic :: Scientific/Engineering :: Chemistry",
    "Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.10"
dependencies = [
    "pymatgen>=2025.1.1",
    "asteval>=0.9.31",
    "xmltodict>=0.12.0",
    "plotly>=5.3.1",
    "toml>=0.10.2",
    "jenkspy>=0.4.0",
    "dict2xml>=1.7.0",
    "treelib>=1.7.0",
    "scikit-learn>=1.3.2",
    "pydantic>=2.11.7",
    "pydantic-settings>=2.10.1",
    "ray>=2.44.0",
    "pybaselines>=1.1.0",
    "spglib>=2.5.0",
    "jobflow>=0.2.0",
    "montydb>=2.5.3",
    "fastapi>=0.115.6",
    "reaction-network>=8.3.0",
    "mp_api>=0.45.0",
    "python-multipart>=0.0.19",
    "uvicorn>=0.34.0",
]

[project.optional-dependencies]
tests = [
    "pytest==7.4.3",
    "pytest-cov==4.1.0",
    "pytest-xdist==3.3.1",
]
strict = [
    "pymatgen==2025.5.1",
    "asteval==0.9.31",
    "xmltodict==0.13.0",
    "dict2xml==1.7.4",
    "plotly==5.18.0",
    "jenkspy==0.4.0",
    "treelib==1.7.0",
    "scikit-learn==1.3.2",
    "pydantic==2.11.7",
    "pydantic-settings==2.10.1",
    "ray==2.44.0",
    "numpy==1.26.4",
    "pybaselines==1.1.0",
    "spglib==2.5.0",
    "fastapi==0.116.1",
    "python-multipart==0.0.19",
    "uvicorn==0.34.0",
]
docs = [
    "sphinx==7.3.7",
    "myst-parser==3.0.1",
    "sphinx_autodoc_typehints==2.2.2",
    "sphinx-book-theme==1.1.3",
    "autodoc_pydantic==2.2.0",
    "myst-nb==1.1.0",
    "sphinx_design==0.6.0",
    "sphinx-copybutton==0.5.2",
    "ipywidgets==8.1.3",
    "kaleido==0.2.1"
]

[project.urls]
homepage = "https://github.com/idocx/dara"
documentation = "https://idocx.github.io/dara/"

[project.scripts]
dara = "dara.cli:main"


[tool.coverage.run]
include = ["src/*"]
parallel = true
branch = false

[tool.coverage.paths]
source = ["src/"]

[tool.coverage.report]
show_missing = true
skip_covered = true
exclude_also = [
    '\#\s*pragma: no cover',
    '^\s*assert False(,|$)',
    'if typing.TYPE_CHECKING:',
    '^\s*@overload( |$)',
    'if TYPE_CHECKING:',
]

[tool.ruff]
target-version = "py39"
line-length = 120

[tool.ruff.lint]
select = [
    "B", # flake8-bugbear
    "C4", # flake8-comprehensions
    "D", # pydocstyle
    "E", # pycodestyle error
    "EXE", # flake8-executable
    "F", # pyflakes
    "FA", # flake8-future-annotations
    "FBT003", # boolean-positional-value-in-call
    "FLY", # flynt
    "I", # isort
    "ICN", # flake8-import-conventions
    "ISC", # flake8-implicit-str-concat
    "PD", # pandas-vet
    "PERF", # perflint
    "PIE", # flake8-pie
    "PL", # pylint
    "PT", # flake8-pytest-style
    "PYI", # flakes8-pyi
    "Q", # flake8-quotes
    "RET", # flake8-return
    "RSE", # flake8-raise
    "RUF", # Ruff-specific rules
    "SIM", # flake8-simplify
    "SLOT", # flake8-slots
    "TCH", # flake8-type-checking
    "TID", # flake8-tidy-imports
    "UP", # pyupgrade
    "W", # pycodestyle warning
    "YTT", # flake8-2020
]
ignore = [
    "B023", # Function definition does not bind loop variable
    "B028", # No explicit stacklevel keyword argument found
    "B904", # Within an except clause, raise exceptions with ...
    "C408", # unnecessary-collection-call
    "D", # Missing docstring in magic method
    "PD011", # pandas-use-of-dot-values
    "PD901", # pandas-df-variable-name
    "PERF203", # try-except-in-loop
    "PERF401", # manual-list-comprehension (TODO fix these or wait for autofix)
    "PLC0415", # `import` should be at the top of the file
    "PLR", # pylint-refactor
    "PLW2901", # Outer for loop variable overwritten by inner assignment target
    "PT006", # pytest-parametrize-names-wrong-type
    "PT013", # pytest-incorrect-pytest-import
    "PT009", # pytest-assertion-rewrite
    "PYI024", # collections-named-tuple (TODO should maybe fix these)
    "RUF001", # String contains ambiguous `–` (EN DASH). Did you mean `-` (HYPHEN-MINUS)?
    "RUF012", # Disable checks for mutable class args. This is a non-problem.
    "RUF013", # implicit-optional
    "RUF015",
    "RUF017",
    "SIM105", # Use contextlib.suppress(OSError) instead of try-except-pass
    "TC",
    "UP",
]
pydocstyle.convention = "numpy"

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"**/tests/*" = ["D"]
"**/schemas/*" = ["FA", "TCH", "UP007"]
"**/schema.py" = ["FA", "TCH", "UP007"]

[tool.mypy]
ignore_missing_imports = true
namespace_packages = true
explicit_package_bases = true
no_implicit_optional = false
follow_imports = "skip"
disable_error_code = "annotation-unchecked"

[tool.pytest]
addopts = "--durations=10"

[tool.pytest.ini_options]
testpaths = "tests"

[tool.setuptools.package-data]
"dara.data" = ["**"]
"dara" = ["py.typed"]
"dara.server.ui.public" = ["**"]

[tool.setuptools-git-versioning]
enabled = true
