mirror of
https://github.com/karpathy/nanochat.git
synced 2025-12-06 04:12:13 +00:00
Adds pre-commit configuration to automate code formatting and linting. This includes: - ruff-check for linting - ruff-format for code formatting - pre-commit-hooks for various checks (whitespace, large files, etc.) - codespell for fixing common misspellings in text Special configurations added to `pyproject.toml`: - Line length: 120 (more flexible than black's 88) - Quote style: preserve (keeps existing quotes) Rename ruff hook (avoid using legacy alias)
104 lines
2.0 KiB
TOML
104 lines
2.0 KiB
TOML
[project]
|
|
name = "nanochat"
|
|
version = "0.1.0"
|
|
description = "the minimal full-stack ChatGPT clone"
|
|
readme = "README.md"
|
|
requires-python = ">=3.10"
|
|
dependencies = [
|
|
"datasets>=4.0.0",
|
|
"fastapi>=0.117.1",
|
|
"files-to-prompt>=0.6",
|
|
"psutil>=7.1.0",
|
|
"regex>=2025.9.1",
|
|
"setuptools>=80.9.0",
|
|
"tiktoken>=0.11.0",
|
|
"tokenizers>=0.22.0",
|
|
"torch>=2.8.0",
|
|
"uvicorn>=0.36.0",
|
|
"wandb>=0.21.3",
|
|
]
|
|
|
|
[build-system]
|
|
requires = ["maturin>=1.7,<2.0"]
|
|
build-backend = "maturin"
|
|
|
|
[tool.maturin]
|
|
module-name = "rustbpe"
|
|
bindings = "pyo3"
|
|
python-source = "."
|
|
manifest-path = "rustbpe/Cargo.toml"
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"maturin>=1.9.4",
|
|
"pytest>=8.0.0",
|
|
"pre-commit>=3.8.0",
|
|
]
|
|
|
|
[tool.pytest.ini_options]
|
|
markers = [
|
|
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
]
|
|
testpaths = ["tests"]
|
|
python_files = ["test_*.py"]
|
|
python_classes = ["Test*"]
|
|
python_functions = ["test_*"]
|
|
|
|
# target torch to cuda 12.8 or CPU
|
|
[tool.uv.sources]
|
|
torch = [
|
|
{ index = "pytorch-cpu", extra = "cpu" },
|
|
{ index = "pytorch-cu128", extra = "gpu" },
|
|
]
|
|
|
|
[[tool.uv.index]]
|
|
name = "pytorch-cpu"
|
|
url = "https://download.pytorch.org/whl/cpu"
|
|
explicit = true
|
|
|
|
[[tool.uv.index]]
|
|
name = "pytorch-cu128"
|
|
url = "https://download.pytorch.org/whl/cu128"
|
|
explicit = true
|
|
|
|
[project.optional-dependencies]
|
|
cpu = [
|
|
"torch>=2.8.0",
|
|
]
|
|
gpu = [
|
|
"torch>=2.8.0",
|
|
]
|
|
|
|
[tool.uv]
|
|
conflicts = [
|
|
[
|
|
{ extra = "cpu" },
|
|
{ extra = "gpu" },
|
|
],
|
|
]
|
|
|
|
[tool.ruff]
|
|
target-version = "py310"
|
|
line-length = 120
|
|
fix = true
|
|
unsafe-fixes = true
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"F", # Pyflakes (unused imports) - replaces autoflake
|
|
"I", # isort - replaces isort
|
|
"UP", # pyupgrade - replaces pyupgrade
|
|
]
|
|
|
|
[tool.ruff.lint.isort]
|
|
known-first-party = ["nanochat"]
|
|
|
|
[tool.ruff.format]
|
|
quote-style = "preserve"
|
|
|
|
[tool.codespell]
|
|
write-changes = true
|
|
interactive = 1
|
|
skip = "tests/*,dev/*,scripts/tok_eval.py,tasks/spellingbee.py"
|
|
ignore-words-list = "re-use,astroid"
|