From 4215261be1cdb7df3bf74d1f291977fff486b1a3 Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Mon, 7 Jul 2025 19:30:48 +0200 Subject: [PATCH] core: Cleanup pyproject (#31857) * Reorganize some toml properties * Fix some E501: line too long Co-authored-by: Mason Daugherty --- libs/core/pyproject.toml | 11 ++-------- .../tests/unit_tests/prompts/test_chat.py | 6 +++-- .../tests/unit_tests/runnables/test_graph.py | 6 +++-- .../unit_tests/runnables/test_runnable.py | 22 ++++++++++++++----- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/libs/core/pyproject.toml b/libs/core/pyproject.toml index a7e3cb26252..06587170d4c 100644 --- a/libs/core/pyproject.toml +++ b/libs/core/pyproject.toml @@ -103,11 +103,10 @@ ignore = [ "PLC0415", "PLR2004", ] -unfixable = ["PLW1510",] - -flake8-type-checking.runtime-evaluated-base-classes = ["pydantic.BaseModel","langchain_core.load.serializable.Serializable","langchain_core.runnables.base.RunnableSerializable"] flake8-annotations.allow-star-arg-any = true flake8-annotations.mypy-init-return = true +flake8-type-checking.runtime-evaluated-base-classes = ["pydantic.BaseModel","langchain_core.load.serializable.Serializable","langchain_core.runnables.base.RunnableSerializable"] +pep8-naming.classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",] pydocstyle.convention = "google" pydocstyle.ignore-var-parameters = true pyupgrade.keep-runtime-typing = true @@ -122,14 +121,8 @@ asyncio_mode = "auto" filterwarnings = [ "ignore::langchain_core._api.beta_decorator.LangChainBetaWarning",] asyncio_default_fixture_loop_scope = "function" -[tool.ruff.lint.pep8-naming] -classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",] - [tool.ruff.lint.per-file-ignores] "langchain_core/utils/mustache.py" = [ "PLW0603",] -"tests/unit_tests/prompts/test_chat.py" = [ "E501",] -"tests/unit_tests/runnables/test_runnable.py" = [ "E501",] -"tests/unit_tests/runnables/test_graph.py" = [ "E501",] "tests/unit_tests/test_tools.py" = [ "ARG",] "tests/**" = [ "D", "S", "SLF",] "scripts/**" = [ "INP", "S",] diff --git a/libs/core/tests/unit_tests/prompts/test_chat.py b/libs/core/tests/unit_tests/prompts/test_chat.py index da755b65e69..f873deb0877 100644 --- a/libs/core/tests/unit_tests/prompts/test_chat.py +++ b/libs/core/tests/unit_tests/prompts/test_chat.py @@ -781,7 +781,8 @@ async def test_chat_tmpl_from_messages_multipart_formatting_with_path() -> None: ) with pytest.raises( ValueError, - match="Loading images from 'path' has been removed as of 0.3.15 for security reasons.", + match="Loading images from 'path' has been removed " + "as of 0.3.15 for security reasons.", ): template.format_messages( name="R2D2", @@ -791,7 +792,8 @@ async def test_chat_tmpl_from_messages_multipart_formatting_with_path() -> None: with pytest.raises( ValueError, - match="Loading images from 'path' has been removed as of 0.3.15 for security reasons.", + match="Loading images from 'path' has been removed " + "as of 0.3.15 for security reasons.", ): await template.aformat_messages( name="R2D2", diff --git a/libs/core/tests/unit_tests/runnables/test_graph.py b/libs/core/tests/unit_tests/runnables/test_graph.py index 45e1cb1b7f9..7944d0b1da4 100644 --- a/libs/core/tests/unit_tests/runnables/test_graph.py +++ b/libs/core/tests/unit_tests/runnables/test_graph.py @@ -86,10 +86,12 @@ def test_trim_multi_edge() -> None: graph.add_edge(a, last) graph.add_edge(start, last) - graph.trim_first_node() # should not remove __start__ since it has 2 outgoing edges + # trim_first_node() should not remove __start__ since it has 2 outgoing edges + graph.trim_first_node() assert graph.first_node() is start - graph.trim_last_node() # should not remove the __end__ node since it has 2 incoming edges + # trim_last_node() should not remove __end__ since it has 2 incoming edges + graph.trim_last_node() assert graph.last_node() is last diff --git a/libs/core/tests/unit_tests/runnables/test_runnable.py b/libs/core/tests/unit_tests/runnables/test_runnable.py index 8ca68f06a6e..98a8ae09eb0 100644 --- a/libs/core/tests/unit_tests/runnables/test_runnable.py +++ b/libs/core/tests/unit_tests/runnables/test_runnable.py @@ -2785,7 +2785,12 @@ Question: response_metadata={}, ), HumanMessage( - content="Context:\n[Document(metadata={}, page_content='foo'), Document(metadata={}, page_content='bar')]\n\nQuestion:\nWhat is your name?", + content="Context:\n" + "[Document(metadata={}, page_content='foo'), " + "Document(metadata={}, page_content='bar')]\n" + "\n" + "Question:\n" + "What is your name?", additional_kwargs={}, response_metadata={}, ), @@ -4140,7 +4145,8 @@ def test_seq_batch_return_exceptions(mocker: MockerFixture) -> None: if value.startswith(self.fail_starts_with): outputs.append( ValueError( - f"ControlledExceptionRunnable({self.fail_starts_with}) fail for {value}" + f"ControlledExceptionRunnable({self.fail_starts_with}) " + f"fail for {value}" ) ) else: @@ -4280,7 +4286,8 @@ async def test_seq_abatch_return_exceptions(mocker: MockerFixture) -> None: if value.startswith(self.fail_starts_with): outputs.append( ValueError( - f"ControlledExceptionRunnable({self.fail_starts_with}) fail for {value}" + f"ControlledExceptionRunnable({self.fail_starts_with}) " + f"fail for {value}" ) ) else: @@ -4931,7 +4938,8 @@ def test_runnable_gen_context_config() -> None: @pytest.mark.skipif( sys.version_info < (3, 11), - reason="Python 3.10 and below don't support running async tasks in a specific context", + reason="Python 3.10 and below don't support running " + "async tasks in a specific context", ) async def test_runnable_gen_context_config_async() -> None: """Test that a generator can call other runnables with config @@ -5057,7 +5065,8 @@ def test_runnable_iter_context_config() -> None: @pytest.mark.skipif( sys.version_info < (3, 11), - reason="Python 3.10 and below don't support running async tasks in a specific context", + reason="Python 3.10 and below don't support running " + "async tasks in a specific context", ) async def test_runnable_iter_context_config_async() -> None: """Test that a generator can call other runnables with config @@ -5179,7 +5188,8 @@ def test_runnable_lambda_context_config() -> None: @pytest.mark.skipif( sys.version_info < (3, 11), - reason="Python 3.10 and below don't support running async tasks in a specific context", + reason="Python 3.10 and below don't support running " + "async tasks in a specific context", ) async def test_runnable_lambda_context_config_async() -> None: """Test that a function can call other runnables with config