BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
14.01k stars 1.66k forks source link

[Feature]: Adopting ruff for Unified Code Formatting and Linting #1073

Closed Undertone0809 closed 5 months ago

Undertone0809 commented 11 months ago

The Feature

Hi there,

To ensure our project's code quality and consistency, I propose that we consider adopting ruff as our primary tool for code formatting and linting. [ruff]() is a cutting-edge tool that amalgamates the capabilities of black, isort, and flake8, facilitating the automation of code style standardization to enhance readability and maintainability.

ref: enhancing-python-code-quality-a-comprehensive-guide-to-linting-with-ruff

I have explored configuring ruff and found that we can seamlessly integrate it by adding some basic settings to our pyproject.toml. This approach ensures uniform code styling without the need for manual adjustments across multiple tools. For reference, here's a template: Python Package Template.

image

Within our development workflow, we can format our code using the following command:

poetry run ruff format --config pyproject.toml litellm

This command will format the code within the hooks and tests directories, ensuring consistency before commits.

Moreover, I recommend integrating ruff into our pre-commit hooks. This automatic check will prevent code style inconsistencies from being merged into our codebase.

Finally, to guarantee consistent code styling throughout our project, I suggest employing GitHub Actions to automate code format checking. This ensures that any commits not adhering to our styling standards are flagged for correction before merging into the main branch.

image

By adopting ruff, I believe we can further elevate our code quality and foster a smoother collaborative experience for our team. I look forward to hearing your thoughts and am happy to answer any questions regarding this proposal.

There projects use code format tool as references.

Developers can not pass the github actions check if there is no formatting. To ensure consistency in code style.

image

Motivation, pitchzh

To ensure our project's code quality and consistency.

Undertone0809 commented 11 months ago

@krrishdholakia Hope to receive your feedback 👋

ishaan-jaff commented 5 months ago

FYI we use isort + flake8 linting throughout the litellm code base now

@Undertone0809 I'm closing this issue since we've address the concern of adding linting / code formatting

Feel free to open a new issue for moving to ruff