Skip to content

Conversation

@Chesars
Copy link
Contributor

@Chesars Chesars commented Nov 6, 2025

Title

chore: Apply Black code formatting

Relevant issues

Fixes #16283 (part 1 of 2)

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🧹 Refactoring

Changes

Problem

The CI currently runs cd litellm && poetry run black . on every PR, reformatting 512 files but discarding the changes. This wastes ~59 seconds per PR.

Solution (Part 1)

This PR applies Black formatting to the litellm/ directory (512 files).

Before merge:

  • CI reformats 512 files on every PR (~59 seconds wasted)
  • Changes discarded, process repeats next PR

After + Part 2:

  • CI verifies formatting with black --check (~1 second)
  • Fails CI if code not formatted (prompts developers to format locally)
  • Saves ~96 minutes per 100 PRs

What Black Does

Black applies consistent Python code formatting:

  • Line length limits (88 characters by default)
  • Consistent string quotes
  • Standardized indentation and spacing
  • PEP 8 compliant formatting

No Breaking Changes

Black preserves the AST (Abstract Syntax Tree) and only modifies code style - no functional changes.

Official guarantee: Black checks that reformatted code produces a valid AST equivalent to the original.

References: Black docs | GitHub

Changes

  • Ran cd litellm && poetry run black . to format 512 files (PEP 8 compliant)
  • No functional changes - Black is AST-preserving and only modifies code style
  • Includes 504 core files + 8 enterprise files (via symlink in litellm/proxy/enterprise)

⚠️ Important: Merge Conflicts Warning

This PR modifies 512 files, which means:

  • ⚠️ Active PRs will likely have merge conflicts when rebasing/merging after this
  • ⚠️ Contributors should run cd litellm && poetry run black . locally to resolve conflicts
  • ⚠️ Recommend coordinating merge timing.
  • ✅ After merge, all future PRs will need Black formatting to pass CI (Part 2)

Type of Changes

  • Non-breaking changes - Only code style/formatting modified
  • No functional changes - Logic, behavior, and APIs remain identical
  • No dependency changes - Same runtime and development dependencies
  • Automated formatting - All changes made by Black formatter tool

Run Black formatter on the litellm/ directory to ensure consistent code formatting across the codebase. This matches the formatting that the CI pipeline applies.

- Formatted 512 files
- No functional changes - Black preserves AST and only modifies code style
- Helps reduce CI failures and merge conflicts from formatting issues

Related to BerriAI#16283
@vercel
Copy link

vercel bot commented Nov 6, 2025

@Chesars is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CI: Black formatting runs on every PR but changes are discarded.

1 participant