[build-system]
requires = [
    "setuptools>=42", # Minimum version for pyproject.toml support
    "wheel",
]
build-backend = "setuptools.build_meta"

[project]
name = "lightning-thunder"
# Version is dynamically set during build time by setup.py
dynamic = ["version", "dependencies", "readme"]
description = "Lightning Thunder is a source-to-source compiler for PyTorch, enabling PyTorch programs to run on different hardware accelerators and graph compilers."
authors = [
    { name = "Lightning AI", email = "support@lightning.ai" },
]
license = "Apache-2.0"
requires-python = ">=3.10, <3.15"
keywords = ["deep learning", "AI", "compiler"]
classifiers=[
    "Environment :: Console",
    "Natural Language :: English",
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Developers",
    "Topic :: Scientific/Engineering :: Artificial Intelligence",
    "Topic :: Scientific/Engineering :: Information Analysis",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13", # Add 3.13 if supported, remove <3.14 above if so
]

[project.urls]
Homepage = "https://github.com/Lightning-AI/lightning-thunder"
"Bug Tracker" = "https://github.com/Lightning-AI/lightning-thunder/issues"
Documentation = "https://lightning-thunder.rtfd.io/en/latest/"
Source = "https://github.com/Lightning-AI/lightning-thunder"


# Consider adding 'all' or 'dev' aggregates if useful
[project.optional-dependencies]
# Populated from requirements/*.txt files (excluding base, devel, docs)
# sdpa = ["thunder-sdpa"]
# apex = ["apex"]
# triton = ["triton>=2.1.0"]

[tool.check-manifest]
ignore = [
    "*.yml",
    ".github",
    ".github/*"
]


[tool.pytest.ini_options]
norecursedirs = [
    ".git",
    ".github",
    "dist",
    "build",
    "docs",
]
addopts = [
    "--strict-markers",
    "--doctest-modules",
    "--color=yes",
    "--disable-pytest-warnings",
    "--benchmark-timer=torch.utils.benchmark.utils.timer.timer",
    "--benchmark-warmup=on",
]
markers = [
    "standalone: mark a test as standalone",
]
filterwarnings = [
    "error::FutureWarning",
]
timeout = 900
# xfail_strict = true  # todo
junit_duration_report = "call"

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "pass",
]

[tool.codespell]
# Todo: enable also python files in a next step
# Gives false positives in fsdp_tutorial.ipynb
skip = '*.py,*fsdp_tutorial.ipynb,*extend_thunder_with_cuda_python.ipynb, *thunder_trace_intro.ipynb'
quiet-level = 3
# comma separated list of words; waiting for:
#  https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603
# also adding links until they ignored by its: nature
#  https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960
# documen is used in an url in README
ignore-words-list = """
    documen, \
    te
"""


[tool.black]
# https://github.com/psf/black
line-length = 120
target-version = ['py310']


[tool.isort]
known_first_party = [
    "thunder",
    "tests"
]
skip_glob = []
profile = "black"
line_length = 120


[tool.ruff]
line-length = 120
# Always generate Python 3.10-compatible code.
target-version = "py310"
#extend-select = [
#    "C4",  # see: https://pypi.org/project/flake8-comprehensions
#    "PT",  # see: https://pypi.org/project/flake8-pytest-style
#    "RET",  # see: https://pypi.org/project/flake8-return
#    "SIM",  # see: https://pypi.org/project/flake8-simplify
#]
# Exclude a variety of commonly ignored directories.
exclude = [
    ".eggs",
    ".git",
    ".mypy_cache",
    ".ruff_cache",
    "__pypackages__",
    "_build",
    "build",
    "dist",
    "docs",
    "examples",
    "notebooks",
]

[tool.ruff.lint]
# Enable Pyflakes `E` and `F` codes by default.
select = [
    "E", "W",  # see: https://pypi.org/project/pycodestyle
    "F",  # see: https://pypi.org/project/pyflakes
#    "D",  # see: https://pypi.org/project/pydocstyle
#    "N",  # see: https://pypi.org/project/pep8-naming
    "RUF100",  # see: https://docs.astral.sh/ruff/rules/unused-noqa/
]
ignore = [
    "E501",  # todo: Line too long (235 > 120 characters)
    # TODO(crcrpar): Resolves the following ignores as these are added while enabling ruff check in pre-commit
    "F821",  # https://docs.astral.sh/ruff/rules/undefined-name/
    "E402",  # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file/
    "F405",  # https://docs.astral.sh/ruff/rules/undefined-local-with-import-star-usage/
    "E712",  # https://docs.astral.sh/ruff/rules/true-false-comparison/
    "E721",  # https://docs.astral.sh/ruff/rules/type-comparison/
]

[tool.ruff.lint.per-file-ignores]
"setup.py" = ["D100", "SIM115"]
"__about__.py" = ["D100"]
"__init__.py" = ["D100"]
# The default is `true` and this option is deprecated as per
# https://docs.astral.sh/ruff/settings/#lint_ignore-init-module-imports
# "ignore-init-module-imports" = true

[tool.ruff.lint.pydocstyle]
# Use Google-style docstrings.
convention = "google"

#[tool.ruff.pycodestyle]
#ignore-overlong-task-comments = true

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10


[tool.mypy]
files = [
    "thunder",
]
install_types = true
non_interactive = true
disallow_untyped_defs = true
ignore_missing_imports = true
show_error_codes = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true
allow_redefinition = true
# disable this rule as the Trainer attributes are defined in the connectors, not in its __init__
disable_error_code = "attr-defined"
# style choices
warn_no_return = false

# Ignore mypy errors for these files
# TODO: the goal is for this to be empty
[[tool.mypy.overrides]]
module = [
    "thunder",
    "thunder.core.dtypes",
    "thunder.langs.torch",
    "thunder.core.lang",
    "thunder.core.prims",
    "thunder.core.proxies",
    "thunder.core.trace",
    "thunder.core.transforms",
    "thunder.core.utils",
    "thunder.executors.nvfuser",
    "thunder.executors.torch",
    "thunder.tests.framework",
    "thunder.tests.nanogpt_model",
    "thunder.tests.opinfos",
    "thunder.tests.test_core",
    "thunder.tests.test_elementwise",
    "thunder.tests.test_networks",
    "thunder.tests.test_ops",
    "thunder.tests.test_reductions",
    "thunder.tests.test_script",
]
ignore_errors = true
