Skip to content

Replace black with ruff and fix code formatting#279

Open
z-a-f wants to merge 3 commits intoandrewyng:mainfrom
z-a-f:linter
Open

Replace black with ruff and fix code formatting#279
z-a-f wants to merge 3 commits intoandrewyng:mainfrom
z-a-f:linter

Conversation

@z-a-f
Copy link

@z-a-f z-a-f commented Feb 27, 2026

This replaces the black with ruff as linter and formatter:

  • Ruff is faster and more accurate
  • There are more rules enabled in Ruff than in Black
  • Ruff is more configurable and has more options

Warning

This will cause a lot of changes to the codebase.

Note

Code changes (beyond ruff enablement) are automated refactoring by linters

@z-a-f z-a-f force-pushed the linter branch 2 times, most recently from ea91a67 to 508924f Compare February 27, 2026 00:11
This replaces the `black` with `ruff` as linter and formatter:
- Ruff is faster and more accurate
- There are more rules enabled in Ruff than in Black
- Ruff is more configurable and has more options

> [!WARNING]
> This will cause a lot of changes to the codebase.
> This commit is ignoring those changes for now.
After changing the linter and formatter, we need to make sure
all the codebase is formatted correctly.

This commit is a massive change to the codebase,
and needs careful review.

```shell
/home/zatoichi/.cache/pypoetry/virtualenvs/aisuite-H335D-c1-py3.10/lib/python3.10/site-packages/pytest_asyncio/plugin.py:208: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
======================================================================================= test session starts ========================================================================================
platform linux -- Python 3.10.19, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/zatoichi/Desktop/Git/aisuite
configfile: pyproject.toml
testpaths: tests
plugins: anyio-4.8.0, cov-6.0.0, asyncio-0.24.0
asyncio: mode=strict, default_loop_scope=None
collected 274 items / 76 deselected / 198 selected

tests/client/test_client.py ..............................                                                                                                                                   [ 15%]
tests/framework/test_asr_models.py .......                                                                                                                                                   [ 18%]
tests/framework/test_asr_params.py ...............................................                                                                                                           [ 42%]
tests/providers/test_anthropic_converter.py .......                                                                                                                                          [ 45%]
tests/providers/test_asr_parameter_passthrough.py ........                                                                                                                                   [ 50%]
tests/providers/test_aws_converter.py ....                                                                                                                                                   [ 52%]
tests/providers/test_azure_provider.py ....                                                                                                                                                  [ 54%]
tests/providers/test_cerebras_provider.py ..                                                                                                                                                 [ 55%]
tests/providers/test_cohere_provider.py .                                                                                                                                                    [ 55%]
tests/providers/test_deepgram_provider.py .........                                                                                                                                          [ 60%]
tests/providers/test_deepseek_provider.py ..                                                                                                                                                 [ 61%]
tests/providers/test_google_converter.py .....                                                                                                                                               [ 63%]
tests/providers/test_google_provider.py ............                                                                                                                                         [ 69%]
tests/providers/test_groq_provider.py ..                                                                                                                                                     [ 70%]
tests/providers/test_huggingface_provider.py ..........                                                                                                                                      [ 75%]
tests/providers/test_inception_provider.py .                                                                                                                                                 [ 76%]
tests/providers/test_lmstudio_provider.py .                                                                                                                                                  [ 76%]
tests/providers/test_mistral_provider.py ..                                                                                                                                                  [ 77%]
tests/providers/test_nebius_provider.py .                                                                                                                                                    [ 78%]
tests/providers/test_ollama_provider.py .                                                                                                                                                    [ 78%]
tests/providers/test_openai_provider.py ..........                                                                                                                                           [ 83%]
tests/providers/test_sambanova_provider.py ..                                                                                                                                                [ 84%]
tests/providers/test_watsonx_provider.py s                                                                                                                                                   [ 85%]
tests/test_provider.py ........                                                                                                                                                              [ 89%]
tests/utils/test_mcp_memory_integration.py ...                                                                                                                                               [ 90%]
tests/utils/test_tool_manager.py ......                                                                                                                                                      [ 93%]
tests/utils/test_tools_mcp_schema.py ............                                                                                                                                            [100%]

========================================================================================= warnings summary =========================================================================================
tests/providers/test_deepgram_provider.py::TestDeepgramProvider::test_provider_initialization
  /home/zatoichi/.cache/pypoetry/virtualenvs/aisuite-H335D-c1-py3.10/lib/python3.10/site-packages/websockets/legacy/__init__.py:6: DeprecationWarning: websockets.legacy is deprecated; see https://websockets.readthedocs.io/en/stable/howto/upgrade.html for upgrade instructions
    warnings.warn(  # deprecated in 14.0 - 2024-11-09

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================== 197 passed, 1 skipped, 76 deselected, 1 warning in 8.24s =====================================================================
```
@z-a-f z-a-f changed the title Replace black with ruff Replace black with ruff and fix code formatting Feb 27, 2026
@z-a-f
Copy link
Author

z-a-f commented Feb 27, 2026

Please, review individual commits

/home/zatoichi/.cache/pypoetry/virtualenvs/aisuite-H335D-c1-py3.10/lib/python3.10/site-packages/pytest_asyncio/plugin.py:208: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
======================================================================================= test session starts ========================================================================================
platform linux -- Python 3.10.19, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/zatoichi/Desktop/Git/aisuite
configfile: pyproject.toml
testpaths: tests
plugins: anyio-4.8.0, cov-6.0.0, asyncio-0.24.0
asyncio: mode=strict, default_loop_scope=None
collected 274 items / 76 deselected / 198 selected

tests/client/test_client.py ..............................                                                                                                                                   [ 15%]
tests/framework/test_asr_models.py .......                                                                                                                                                   [ 18%]
tests/framework/test_asr_params.py ...............................................                                                                                                           [ 42%]
tests/providers/test_anthropic_converter.py .......                                                                                                                                          [ 45%]
tests/providers/test_asr_parameter_passthrough.py ........                                                                                                                                   [ 50%]
tests/providers/test_aws_converter.py ....                                                                                                                                                   [ 52%]
tests/providers/test_azure_provider.py ....                                                                                                                                                  [ 54%]
tests/providers/test_cerebras_provider.py ..                                                                                                                                                 [ 55%]
tests/providers/test_cohere_provider.py .                                                                                                                                                    [ 55%]
tests/providers/test_deepgram_provider.py .........                                                                                                                                          [ 60%]
tests/providers/test_deepseek_provider.py ..                                                                                                                                                 [ 61%]
tests/providers/test_google_converter.py .....                                                                                                                                               [ 63%]
tests/providers/test_google_provider.py ............                                                                                                                                         [ 69%]
tests/providers/test_groq_provider.py ..                                                                                                                                                     [ 70%]
tests/providers/test_huggingface_provider.py ..........                                                                                                                                      [ 75%]
tests/providers/test_inception_provider.py .                                                                                                                                                 [ 76%]
tests/providers/test_lmstudio_provider.py .                                                                                                                                                  [ 76%]
tests/providers/test_mistral_provider.py ..                                                                                                                                                  [ 77%]
tests/providers/test_nebius_provider.py .                                                                                                                                                    [ 78%]
tests/providers/test_ollama_provider.py .                                                                                                                                                    [ 78%]
tests/providers/test_openai_provider.py ..........                                                                                                                                           [ 83%]
tests/providers/test_sambanova_provider.py ..                                                                                                                                                [ 84%]
tests/providers/test_watsonx_provider.py s                                                                                                                                                   [ 85%]
tests/test_provider.py ........                                                                                                                                                              [ 89%]
tests/utils/test_mcp_memory_integration.py ...                                                                                                                                               [ 90%]
tests/utils/test_tool_manager.py ......                                                                                                                                                      [ 93%]
tests/utils/test_tools_mcp_schema.py ............                                                                                                                                            [100%]

========================================================================================= warnings summary =========================================================================================
tests/providers/test_deepgram_provider.py::TestDeepgramProvider::test_provider_initialization
  /home/zatoichi/.cache/pypoetry/virtualenvs/aisuite-H335D-c1-py3.10/lib/python3.10/site-packages/websockets/legacy/__init__.py:6: DeprecationWarning: websockets.legacy is deprecated; see https://websockets.readthedocs.io/en/stable/howto/upgrade.html for upgrade instructions
    warnings.warn(  # deprecated in 14.0 - 2024-11-09

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================== 197 passed, 1 skipped, 76 deselected, 1 warning in 8.24s =====================================================================

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.

1 participant