mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-24 05:22:22 +02:00
1.2 KiB
1.2 KiB
backend — conventions (Python)
All conventions in the root CLAUDE.md apply here. Python-specific emphasis:
- No leading
_; usep_for private (no-underscore-names), and ap_name used outside its file/class must be made public (p-private). Both are linter-enforced forbackend/. - Absolute imports only —
from backend.apps.foo import bar, neverfrom .foo import bar. - No barrels —
__init__.pymust not exist solely to re-export. @typecheckedon every function, and prefertypinggenerics (List,Dict,Optional) over builtins. Pyright/Pylance strict.- Classes are pydantic
BaseModel(model_config = ConfigDict(validate_assignment=True),InstanceOf[...]for unrecognized field types). Don't use plain classes or baredicts for structured data — model it. Legitimate dicts: dynamic-key registries and external protocol shapes (SDK hook returns,model_dumpoutput). - Single-purpose file naming — a one-export file is named after its export.
Touch a file → it must be clean under these rules. Pre-existing debt is grandfathered in
linter/config/config.json; don't mass-migrate untouched files.