Replace black with ruff and fix code formatting#279
Open
z-a-f wants to merge 3 commits intoandrewyng:mainfrom
Open
Replace black with ruff and fix code formatting#279z-a-f wants to merge 3 commits intoandrewyng:mainfrom
black with ruff and fix code formatting#279z-a-f wants to merge 3 commits intoandrewyng:mainfrom
Conversation
ea91a67 to
508924f
Compare
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 ===================================================================== ```
black with ruffblack with ruff and fix code formatting
Author
|
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 ===================================================================== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces the
blackwithruffas linter and formatter:Warning
This will cause a lot of changes to the codebase.
Note
Code changes (beyond
ruffenablement) are automated refactoring by linters