griffe icon indicating copy to clipboard operation
griffe copied to clipboard

feature: could you make `colorama` an optional dependenncy

Open samuelcolvin opened this issue 3 months ago • 5 comments

Is your feature request related to a problem? Please describe.

AFAIK colorama is only used in the griffe CLI. We're using griffe programatically in pydantic-ai-slim where we care a lot about minimizing the SBOM.

Describe the solution you'd like

Would you consider removing the colorama dependency, or making it optional in a cli dependency group. 🙏

samuelcolvin avatar Sep 10 '25 04:09 samuelcolvin

Yes good idea, I like reducing dependencies too 🙂

pawamoy avatar Sep 10 '25 08:09 pawamoy

I see two options:

  1. Move library code into a new package called griffelib. Have griffe depend on it (as well as colorama, like before). Re-expose the API from griffe. Library users like Pydantic-AI can start depending on griffelib instead of griffe to get minimal dependencies. No breaking changes.
  2. Start putting colorama under an extra. Small breaking change for users who use colored output.

I myself prefer option 1. Never got to write this blog post but that's how I want to architect my CLI/lib projects from now on:

  • <pkg>lib stores the library only, with minimal dependencies
  • <pkg> is the CLI, it depends on <pkg>lib and maybe re-exposes its whole API
  • (optional) <pkg>-tui (or <pkg>tui without dash) provides a TUI (with Textual of course)

The reason I like this architecture is that users don't have to learn/know about extras. It makes commands shorter (uvx pkg command instead of uvx --from pkg[cli] pkg command, or uvx pkgtui instead of uvx --from pkg[tui] pkg tui). I find it intuitive that installing the main pkg package gets you both the library + CLI. In such cases as above, it also makes a smooth transition without breaking changes (so, takes into account the evolution of a project).

pawamoy avatar Sep 10 '25 09:09 pawamoy

yup, option 1 makes sense.

It's roughly the same idea as how we have pydantic-ai-slim with all the application logic (includes the pydantic_ai module), but only minimal dependencies, then pydantic-ai is a dependency only library that includes pydantic-ai-slim and lots of dependencies.

samuelcolvin avatar Sep 10 '25 12:09 samuelcolvin

I'm also +1 on the first option.

johnslavik avatar Sep 10 '25 16:09 johnslavik

I filed #408 to track the migration. Any migration-related discussion is welcome there.

johnslavik avatar Sep 17 '25 18:09 johnslavik