core: Cleanup pyproject (#31857)

* Reorganize some toml properties
* Fix some E501: line too long

Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
Christophe Bornet 2025-07-07 19:30:48 +02:00 committed by GitHub
parent a751a23c4e
commit 4215261be1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 19 deletions

View File

@ -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",]

View File

@ -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",

View File

@ -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

View File

@ -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