Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Repo Overview
- `dandischema` is a pure-Python library defining the DANDI metadata schemata (no CLI).
- Source lives under `dandischema/`, tests under `dandischema/tests/`.
- Helper scripts (schema publishing, license fetching, etc.) live under `tools/`.
- `pyproject.toml` is the single source of truth for dependencies and tool config; `tox.ini` orchestrates testing/linting; `.pre-commit-config.yaml` runs auto-formatters.

## Build/Test Commands
- Run full test suite: `tox -e py3` (or `tox -e py` to use the active interpreter).
- Run a single test: `tox -e py3 -- dandischema/tests/test_models.py::test_function -v`.
- Inside an active venv (`uv venv` / `source .venv/bin/activate`): `python -m pytest dandischema`.
- Lint: `tox -e lint` (runs `codespell` + `flake8` over `dandischema/`).
- Type checking: `tox -e typing` (runs `mypy dandischema`).
- Lint + types together: `tox -e lint,typing`.
- Set `DANDI_TESTS_NONETWORK=1` to make tests refuse outbound HTTP (the `disable_http` autouse fixture in `dandischema/tests/conftest.py` points proxies at a dead address).
- DataCite-dependent tests require `DATACITE_DEV_LOGIN` / `DATACITE_DEV_PASSWORD`; set `NO_ET=1` to disable etelemetry. Both are passed through by tox.
- There is no `docker-compose` in this repo and no `hatch run test:run` env — don't suggest those (the dandi-cli pattern doesn't apply here).

## Pre-commit
- Install hooks if missing (no `.git/hooks/pre-commit` present): `pre-commit install`.
- Hooks run: trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files, black, isort, codespell, flake8.
- If a commit fails because hooks auto-fixed files, just re-run `git commit` — the second attempt usually succeeds. Investigate further only if it fails twice.

## Test Markers
- Mark AI-generated tests with `@pytest.mark.ai_generated`.
Comment thread
yarikoptic marked this conversation as resolved.
- This project does **not** have a `pytest_plugin.py`. If a new marker is introduced, register it under a `[pytest]`/`markers =` block in `tox.ini` (or via `pytest.ini`/`conftest.py`) — otherwise `filterwarnings = error` (set in `tox.ini`) will turn the unregistered-marker warning into a failure.

## Code Style
- Black-formatted, line length 100 (see `.flake8: max-line-length = 100`; flake8 ignores `E203,W503`).
- isort with `profile = "black"`, `force_sort_within_sections = true`, `reverse_relative = true`, `known_first_party = ["dandischema"]`.
- Type annotations required for all new code — `mypy` runs in strict-ish mode (`allow_untyped_defs = false`, `warn_return_any`, `warn_unreachable`, `pydantic.mypy` plugin enabled). Models use Pydantic v2 (`pydantic[email]~=2.4`).
- Class names: CamelCase; functions/variables: snake_case.
- Exception names end with `Error` (see `dandischema/exceptions.py`).
- Docstrings in NumPy style for public APIs; keep them in sync with signature changes.
- Prefer specific exceptions over generic ones.
- Imports organized stdlib / third-party / local, alphabetical within groups (isort handles ordering).
- All imports at module top — no function-local imports (per global rule), unless guarding an optional dep with `try/except ImportError`.

## Schema / Data Files
- `dandischema/*.yaml` (e.g. `standards.yaml`, `model_standards.yaml`, `personinfo.yaml`) are tracked schema/data inputs — don't reformat or rename casually; downstream consumers and `tools/pubschemata.py` rely on them.
- `dandischema/_version.py` is generated by `versioningit` (see `[tool.versioningit.write]`); don't edit by hand.
Comment thread
yarikoptic marked this conversation as resolved.
Loading