From 706a66eccd9fa042d6c8715acd9236e21f052183 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 7 Jul 2025 14:13:10 -0400 Subject: [PATCH] fix: automatically fix issues with ruff (#31897) * Perform safe automatic fixes instead of only selecting [isort](https://docs.astral.sh/ruff/rules/#isort-i) --- Makefile | 4 ++-- libs/cli/Makefile | 2 +- libs/langchain/Makefile | 2 +- libs/partners/anthropic/Makefile | 2 +- libs/partners/chroma/Makefile | 2 +- libs/partners/deepseek/Makefile | 2 +- libs/partners/exa/Makefile | 2 +- libs/partners/fireworks/Makefile | 2 +- libs/partners/groq/Makefile | 2 +- libs/partners/huggingface/Makefile | 2 +- libs/partners/mistralai/Makefile | 2 +- libs/partners/nomic/Makefile | 2 +- libs/partners/ollama/Makefile | 2 +- libs/partners/openai/Makefile | 2 +- libs/partners/perplexity/Makefile | 2 +- libs/partners/prompty/Makefile | 2 +- libs/partners/qdrant/Makefile | 2 +- libs/partners/xai/Makefile | 2 +- libs/standard-tests/Makefile | 2 +- libs/text-splitters/Makefile | 2 +- scripts/update_mypy_ruff.py | 5 +++-- 21 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index e295c066dd2..f5e750c6371 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ spell_fix: lint lint_package lint_tests: uv run --group lint ruff check docs cookbook uv run --group lint ruff format docs cookbook cookbook --diff - uv run --group lint ruff check --select I docs cookbook + uv run --group lint ruff check docs cookbook git --no-pager grep 'from langchain import' docs cookbook | grep -vE 'from langchain import (hub)' && echo "Error: no importing langchain from root in docs, except for hub" && exit 1 || exit 0 git --no-pager grep 'api.python.langchain.com' -- docs/docs ':!docs/docs/additional_resources/arxiv_references.mdx' ':!docs/docs/integrations/document_loaders/sitemap.ipynb' || exit 0 && \ @@ -81,7 +81,7 @@ lint lint_package lint_tests: ## format: Format the project files. format format_diff: uv run --group lint ruff format docs cookbook - uv run --group lint ruff check --select I --fix docs cookbook + uv run --group lint ruff check --fix docs cookbook update-package-downloads: uv run python docs/scripts/packages_yml_get_downloads.py diff --git a/libs/cli/Makefile b/libs/cli/Makefile index b62dc1ab703..1dbec29a610 100644 --- a/libs/cli/Makefile +++ b/libs/cli/Makefile @@ -22,7 +22,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --group typing --group lint ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --group typing --group lint ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --group typing --group lint ruff check --fix $(PYTHON_FILES) test tests: _test _e2e_test diff --git a/libs/langchain/Makefile b/libs/langchain/Makefile index c5705e34ff8..f08261b3502 100644 --- a/libs/langchain/Makefile +++ b/libs/langchain/Makefile @@ -64,7 +64,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/anthropic/Makefile b/libs/partners/anthropic/Makefile index 917ad66dded..494352a0eda 100644 --- a/libs/partners/anthropic/Makefile +++ b/libs/partners/anthropic/Makefile @@ -43,7 +43,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/chroma/Makefile b/libs/partners/chroma/Makefile index acd70b4a224..ea9fe087c3f 100644 --- a/libs/partners/chroma/Makefile +++ b/libs/partners/chroma/Makefile @@ -41,7 +41,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/deepseek/Makefile b/libs/partners/deepseek/Makefile index c32b67ebad4..08cefe3a33d 100644 --- a/libs/partners/deepseek/Makefile +++ b/libs/partners/deepseek/Makefile @@ -42,7 +42,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/exa/Makefile b/libs/partners/exa/Makefile index c467487d303..ce85556f3f0 100644 --- a/libs/partners/exa/Makefile +++ b/libs/partners/exa/Makefile @@ -41,7 +41,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/fireworks/Makefile b/libs/partners/fireworks/Makefile index cc8d95e4c5a..7cb001a6fe6 100644 --- a/libs/partners/fireworks/Makefile +++ b/libs/partners/fireworks/Makefile @@ -40,7 +40,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/groq/Makefile b/libs/partners/groq/Makefile index b6d880613b0..e0981cec452 100644 --- a/libs/partners/groq/Makefile +++ b/libs/partners/groq/Makefile @@ -41,7 +41,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/huggingface/Makefile b/libs/partners/huggingface/Makefile index d69d408c86c..a6564f43dfe 100644 --- a/libs/partners/huggingface/Makefile +++ b/libs/partners/huggingface/Makefile @@ -41,7 +41,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/mistralai/Makefile b/libs/partners/mistralai/Makefile index 9b84121b82d..ede572f9e46 100644 --- a/libs/partners/mistralai/Makefile +++ b/libs/partners/mistralai/Makefile @@ -43,7 +43,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/nomic/Makefile b/libs/partners/nomic/Makefile index d10dda08795..0b6e5c3babf 100644 --- a/libs/partners/nomic/Makefile +++ b/libs/partners/nomic/Makefile @@ -41,7 +41,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/ollama/Makefile b/libs/partners/ollama/Makefile index 5c3c15e5c2e..97b63798e9d 100644 --- a/libs/partners/ollama/Makefile +++ b/libs/partners/ollama/Makefile @@ -47,7 +47,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/openai/Makefile b/libs/partners/openai/Makefile index b77a1731370..512cff409e1 100644 --- a/libs/partners/openai/Makefile +++ b/libs/partners/openai/Makefile @@ -54,7 +54,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/perplexity/Makefile b/libs/partners/perplexity/Makefile index 12b9e8b7305..9bff2953226 100644 --- a/libs/partners/perplexity/Makefile +++ b/libs/partners/perplexity/Makefile @@ -40,7 +40,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/prompty/Makefile b/libs/partners/prompty/Makefile index 9f9e6f5d7a1..3df127b25ec 100644 --- a/libs/partners/prompty/Makefile +++ b/libs/partners/prompty/Makefile @@ -39,7 +39,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/qdrant/Makefile b/libs/partners/qdrant/Makefile index cd53df9d78d..1c78ffd21e0 100644 --- a/libs/partners/qdrant/Makefile +++ b/libs/partners/qdrant/Makefile @@ -42,7 +42,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/partners/xai/Makefile b/libs/partners/xai/Makefile index 2d3eafc0ae7..92198d1a529 100644 --- a/libs/partners/xai/Makefile +++ b/libs/partners/xai/Makefile @@ -40,7 +40,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/standard-tests/Makefile b/libs/standard-tests/Makefile index 8fa7c0bbaa0..afa09134485 100644 --- a/libs/standard-tests/Makefile +++ b/libs/standard-tests/Makefile @@ -39,7 +39,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/libs/text-splitters/Makefile b/libs/text-splitters/Makefile index e76de79860e..7ee6d99a5cb 100644 --- a/libs/text-splitters/Makefile +++ b/libs/text-splitters/Makefile @@ -49,7 +49,7 @@ lint lint_diff lint_package lint_tests: format format_diff: [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) - [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --select I --fix $(PYTHON_FILES) + [ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES) spell_check: uv run --all-groups codespell --toml pyproject.toml diff --git a/scripts/update_mypy_ruff.py b/scripts/update_mypy_ruff.py index fb085da5bfa..3bfd1439691 100644 --- a/scripts/update_mypy_ruff.py +++ b/scripts/update_mypy_ruff.py @@ -32,7 +32,7 @@ def main(): cwd = "/".join(path.split("/")[:-1]) subprocess.run( - "poetry lock --no-update; poetry install --with lint; poetry run ruff format .; poetry run ruff --select I --fix .", + "poetry lock --no-update; poetry install --with lint; poetry run ruff format .; poetry run ruff --fix .", cwd=cwd, shell=True, capture_output=True, @@ -74,12 +74,13 @@ def main(): f.write("".join(file_lines)) subprocess.run( - "poetry lock --no-update; poetry install --with lint; poetry run ruff format .; poetry run ruff --select I --fix .", + "poetry lock --no-update; poetry install --with lint; poetry run ruff format .; poetry run ruff --fix .", cwd=cwd, shell=True, capture_output=True, text=True, ) + if __name__ == "__main__": main()