Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Last active February 15, 2024 18:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayakpaul/a48a0f63d0e346164a97c687f27c5b51 to your computer and use it in GitHub Desktop.
Save sayakpaul/a48a0f63d0e346164a97c687f27c5b51 to your computer and use it in GitHub Desktop.
Utilities for formatting Python projects. Inspired from what's done in `diffusers`.
  1. Get a Makefile from here: https://github.com/huggingface/diffusion-fast/blob/main/Makefile.
  2. Install ruff: pip install ruff.
  3. Get the ruff configuration file through pyproject.toml: https://github.com/huggingface/diffusion-fast/blob/main/pyproject.toml.

Keep both the Makefile and pyproject.toml files at the root level of your project.

Before staging your changes, run the following from the root of your project directory:

make style && make quality

That's it 🤗

The Makefile and the pyproject.toml files were adapted from from the diffusers repo.

You can, of course, configure formatting in a more automated way (e.g., pre-commits, Ctrl + Save IDE callbacks, etc.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment