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

requires = [ "hatch-vcs", "hatchling" ]

[project]
name = "aleph-sdk-python"
description = "Lightweight Python Client library for the Aleph.im network"
readme = "README.md"
license = { file = "LICENSE.txt" }
authors = [
  { name = "Aleph.im Team", email = "hello@aleph.im" },
]
classifiers = [
  "Development Status :: 4 - Beta",
  "Framework :: aiohttp",
  "Intended Audience :: Developers",
  "License :: OSI Approved :: MIT License",
  "Operating System :: MacOS :: MacOS X",
  "Operating System :: POSIX :: Linux",
  "Programming Language :: Python :: 3 :: Only",
  "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",
  "Topic :: Software Development :: Libraries",
]
dynamic = [ "version" ]
dependencies = [
  "aiohttp>=3.8.3",
  "aioresponses>=0.7.6",
  "aleph-message>=1.0.5",
  "aleph-superfluid>=0.3",
  "base58==2.1.1",                         # Needed now as default with _load_account changement
  "coincurve; python_version>='3.9'",
  "coincurve>=19; python_version>='3.9'",
  "eth-abi>=5.0.1; python_version>='3.9'",
  "eth-typing>=5.0.1",
  "jwcrypto==1.5.6",
  "pydantic>=2,<3",
  "pydantic-settings>=2",
  "pynacl==1.5",                           # Needed now as default with _load_account changement
  "python-magic",
  "typing-extensions",
  "web3>=7.10",
]

optional-dependencies.all = [
  "aleph-sdk-python[cosmos,dns,docs,ledger,mqtt,nuls2,substrate,solana,tezos,encryption]",
]
optional-dependencies.cosmos = [
  "cosmospy",
]
optional-dependencies.dns = [
  "aiodns",
]
optional-dependencies.docs = [
  "sphinxcontrib-plantuml",
]
optional-dependencies.encryption = [
  "eciespy; python_version<'3.11'",
  "eciespy>=0.3.13; python_version>='3.11'",
]
optional-dependencies.ledger = [
  "ledgereth==0.10",
]
optional-dependencies.mqtt = [
  "aiomqtt<=0.1.3",
  "certifi",
  "click",
]
optional-dependencies.nuls2 = [
  "aleph-nuls2",
]
optional-dependencies.solana = [
  "base58",
  "pynacl",
]
optional-dependencies.substrate = [
  "py-sr25519-bindings",
  "substrate-interface",
]
optional-dependencies.tezos = [
  "pytezos-crypto==3.13.4.1",
]
urls.Documentation = "https://aleph.im/"
urls.Homepage = "https://github.com/aleph-im/aleph-sdk-python"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.targets.wheel]
packages = [
  "src/aleph",
  "pyproject.toml",
  "README.md",
  "LICENSE.txt",
]

[tool.hatch.build.targets.sdist]
include = [
  "src/aleph",
  "pyproject.toml",
  "README.md",
  "LICENSE.txt",
]

[[tool.hatch.envs.all.matrix]]
python = [ "3.9", "3.10", "3.11" ]

[tool.hatch.envs.testing]
features = [
  "cosmos",
  "dns",
  "ledger",
  "nuls2",
  "substrate",
  "solana",
  "tezos",
  "encryption",
]
dependencies = [
  "pytest==8.0.1",
  "pytest-cov==4.1.0",
  "pytest-mock==3.12.0",
  "pytest-asyncio==0.23.5",
  "pytest-aiohttp==1.0.5",
  "aioresponses==0.7.6",
  "fastapi",
  "httpx",
  "secp256k1",
]
[tool.hatch.envs.testing.scripts]
test = "pytest {args:} ./src/ ./tests/ ./examples/"
test-cov = "pytest --cov {args:} ./src/ ./tests/ ./examples/"
cov-report = [
  "- coverage combine",
  "coverage report",
]
cov = [
  "test-cov",
  "cov-report",
]

[tool.hatch.envs.linting]
detached = true
dependencies = [
  "black==24.2.0",
  "mypy==1.9.0",
  "mypy-extensions==1.0.0",
  "ruff==0.4.8",
  "isort==5.13.2",
  "pyproject-fmt==2.2.1",
]
[tool.hatch.envs.linting.scripts]
typing = "mypy --config-file=pyproject.toml {args:} ./src/ ./tests/ ./examples/"
style = [
  "ruff check {args:.} ./src/ ./tests/ ./examples/",
  "black --check --diff {args:} ./src/ ./tests/ ./examples/",
  "isort --check-only --profile black {args:} ./src/ ./tests/ ./examples/",
  "pyproject-fmt --check pyproject.toml",
]
fmt = [
  "black {args:} ./src/ ./tests/ ./examples/",
  "ruff check --fix {args:.} ./src/ ./tests/ ./examples/",
  "isort --profile black {args:} ./src/ ./tests/ ./examples/",
  "pyproject-fmt pyproject.toml",
  "style",
]
all = [
  "style",
  "typing",
]

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
minversion = "6.0"
pythonpath = [ "src" ]
addopts = "-vv -m \"not ledger_hardware\""
norecursedirs = [ "*.egg", "dist", "build", ".tox", ".venv", "*/site-packages/*" ]
testpaths = [ "tests/unit" ]
markers = { ledger_hardware = "marks tests as requiring ledger hardware" }

[tool.coverage.run]
branch = true
parallel = true
source = [
  "src/",
]
omit = [
  "*/site-packages/*",
]

[tool.coverage.paths]
source = [
  "src/",
]
omit = [
  "*/site-packages/*",
]

[tool.coverage.report]
show_missing = true
skip_empty = true
exclude_lines = [
  # Have to re-enable the standard pragma
  "pragma: no cover",

  # Don't complain about missing debug-only code:
  "def __repr__",
  "if self\\.debug",

  # Don't complain if tests don't hit defensive assertion code:
  "raise AssertionError",
  "raise NotImplementedError",

  # Don't complain if non-runnable code isn't run:
  "if 0:",
  "if __name__ == .__main__.:",

  # Don't complain about ineffective code:
  "pass",
]

[tool.mypy]
python_version = 3.9
mypy_path = "src"
exclude = [
  "conftest.py",
]
show_column_numbers = true
check_untyped_defs = true

# Import discovery
# Install types for third-party library stubs (e.g. from typeshed repository)
install_types = true
non_interactive = true
# Suppresses error messages about imports that cannot be resolved (no py.typed file, no stub file, etc).
ignore_missing_imports = true
# Don't follow imports
follow_imports = "silent"

# Miscellaneous strictness flags
# Allows variables to be redefined with an arbitrary type, as long as the redefinition is in the same block and nesting level as the original definition.
allow_redefinition = true
