1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-10-24 20:59:27 +03:00
Files
diffusers/.ai/references/code_style.md
Dhruv Nair 3681e65996 Restructure skill files and reference guides for CLI based installation. (#14454)
* restructure guides as skill references

* reorganize AGENTS.md and references

* clean up

* clean up

* clean up

* fix AGENTS.md references and add check_ai to Makefile

* clean up

* update paths

* clean up
2026-08-20 18:16:49 +05:30

1.4 KiB

Coding style and copied code

Shared reference for how diffusers code should read, and for the # Copied from mechanism.

Coding style

Strive to write code as simple and explicit as possible.

  • Prefer inlining small helper/utility functions over factoring them out — a reader should be able to follow the full flow without jumping between functions. If a private helper has only one caller, inlining it at the call site is usually the cleaner choice.
  • No defensive code, unused code paths, or legacy stubs — do not add fallback paths, safety checks, or configuration options "just in case"; do not carry unused method parameters "for API consistency", backwards-compatibility aliases for names that never shipped, or deprecation shims for code that was never released. When porting from a research repo, delete training-time code paths, experimental flags, and ablation branches entirely — only keep the inference path you are actually integrating.
  • Do not guess user intent and silently correct behavior. Make the expected inputs clear in the docstring, and raise a concise error for unsupported cases rather than adding complex fallback logic.

Copied code

  • Many classes are kept in sync with a source via a # Copied from ... header comment
  • Do not edit a # Copied from block directly — run make fix-copies to propagate changes from the source
  • Remove the header to intentionally break the link