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

[project]
name = "sain"
version = "1.4.0"
description = "Write safe Python code like Rust"
authors = [{ name = "nxtlo", email = "dhmony-99@hotmail.com" }]
readme = "README.md"
license = { file = "LICENSE" }
keywords = ["rust", "utilities", "collections", "buffer", "vec"]
requires-python = ">=3.10.0"
classifiers = [
    "Development Status :: 5 - Production/Stable",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: BSD License",
    "Natural Language :: English",
    "Operating System :: OS Independent",
    "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",
    "Topic :: Software Development :: Libraries",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Typing :: Typed",
]
dependencies = ["typing-extensions>=4.13.2"]

[project.urls]
Repository = "https://github.com/nxtlo/sain"
Documentation = "https://nxtlo.github.io/sain/sain.html"
Changelog = "https://github.com/nxtlo/sain/blob/master/CHANGELOG.md"


[dependency-groups]
nox = ["nox[uv]>=2025.5.1", { include-group = "type-checking" }]
docs = ["pdoc>=15.0.3", { include-group = "type-checking" }]
lint = [
    "codespell>=2.4.1",
    "slotscheck>=0.19.1",
    "ruff>=0.11.11",
    { include-group = "type-checking" },
]
fmt = ["ruff>=0.11.11", "isort>=6.0.1", { include-group = "type-checking" }]
tests = ["pytest>=8.3.5", { include-group = "type-checking" }]
type-checking = ["typing-extensions>=4.13.2", "pyright>=1.1.401"]


[tool.ruff]
# Exclude a variety of commonly ignored directories.
src = ["tests", "examples", "sain"]
exclude = [
    ".git",
    ".mypy_cache",
    ".nox",
    ".ruff_cache",
    ".venv",
    "__pypackages__",
    "dist",
    "node_modules",
    "venv",
]

# Same as Black.
line-length = 88
indent-width = 4

target-version = "py312"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

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

[tool.hatch.build.targets.sdist]
include = ["sain", "sain/**/*.py"]

[tool.hatch.build.targets.wheel]
include = ["sain", "sain/**/*.py"]

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.isort]
profile = "black"
force_single_line = true

[tool.pyright]
include = ["sain", "examples"]
pythonVersion = "3.12"
typeCheckingMode = "strict"

reportUnnecessaryTypeIgnoreComment = "warning"
reportMissingTypeStubs = "none"
# This will always cause warnings above license.
reportIncompatibleVariableOverride = "none"
reportMissingImports = "error"
reportImportCycles = "none"
reportOverlappingOverload = "none"
reportUnboundVariable = "error"
reportUnknownParameterType = "error"
reportUnknownLambdaType = "warning"
reportUnknownMemberType = "warning"
reportUnknownArgumentType = "error"
reportUnknownVariableType = "error"
reportMissingModuleSource = "error"
reportMissingParameterType = "error"
reportMissingTypeArgument = "error"
reportGeneralTypeIssues = "warning"
reportPrivateUsage = "error"
reportIncompatibleMethodOverride = "none"
reportUnusedVariable = "error"
reportUnusedImport = "error"

[tool.pytest.ini_options]
xfail_strict = true
norecursedirs = [
    "docs",
    "*.egg-info",
    ".git",
    ".nox",
    ".pytest_cache",
    ".venv",
    "venv",
    "ci",
]

[tool.slotscheck]
strict-imports = true
require-superclass = true
require-subclass = false
exclude-classes = """
(
    ^sain\\.collections\\.buf:(Bytes|BytesMut)$|
    ^sain\\.collections\\.hash_map:(HashMap|RefMut)$
)
"""
