Skip to content

Commit 4215261

Browse files
cbornetmdrxy
andauthored
core: Cleanup pyproject (#31857)
* Reorganize some toml properties * Fix some E501: line too long Co-authored-by: Mason Daugherty <[email protected]>
1 parent a751a23 commit 4215261

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

libs/core/pyproject.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ ignore = [
103103
"PLC0415",
104104
"PLR2004",
105105
]
106-
unfixable = ["PLW1510",]
107-
108-
flake8-type-checking.runtime-evaluated-base-classes = ["pydantic.BaseModel","langchain_core.load.serializable.Serializable","langchain_core.runnables.base.RunnableSerializable"]
109106
flake8-annotations.allow-star-arg-any = true
110107
flake8-annotations.mypy-init-return = true
108+
flake8-type-checking.runtime-evaluated-base-classes = ["pydantic.BaseModel","langchain_core.load.serializable.Serializable","langchain_core.runnables.base.RunnableSerializable"]
109+
pep8-naming.classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",]
111110
pydocstyle.convention = "google"
112111
pydocstyle.ignore-var-parameters = true
113112
pyupgrade.keep-runtime-typing = true
@@ -122,14 +121,8 @@ asyncio_mode = "auto"
122121
filterwarnings = [ "ignore::langchain_core._api.beta_decorator.LangChainBetaWarning",]
123122
asyncio_default_fixture_loop_scope = "function"
124123

125-
[tool.ruff.lint.pep8-naming]
126-
classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",]
127-
128124
[tool.ruff.lint.per-file-ignores]
129125
"langchain_core/utils/mustache.py" = [ "PLW0603",]
130-
"tests/unit_tests/prompts/test_chat.py" = [ "E501",]
131-
"tests/unit_tests/runnables/test_runnable.py" = [ "E501",]
132-
"tests/unit_tests/runnables/test_graph.py" = [ "E501",]
133126
"tests/unit_tests/test_tools.py" = [ "ARG",]
134127
"tests/**" = [ "D", "S", "SLF",]
135128
"scripts/**" = [ "INP", "S",]

libs/core/tests/unit_tests/prompts/test_chat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ async def test_chat_tmpl_from_messages_multipart_formatting_with_path() -> None:
781781
)
782782
with pytest.raises(
783783
ValueError,
784-
match="Loading images from 'path' has been removed as of 0.3.15 for security reasons.",
784+
match="Loading images from 'path' has been removed "
785+
"as of 0.3.15 for security reasons.",
785786
):
786787
template.format_messages(
787788
name="R2D2",
@@ -791,7 +792,8 @@ async def test_chat_tmpl_from_messages_multipart_formatting_with_path() -> None:
791792

792793
with pytest.raises(
793794
ValueError,
794-
match="Loading images from 'path' has been removed as of 0.3.15 for security reasons.",
795+
match="Loading images from 'path' has been removed "
796+
"as of 0.3.15 for security reasons.",
795797
):
796798
await template.aformat_messages(
797799
name="R2D2",

libs/core/tests/unit_tests/runnables/test_graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ class Scheme(BaseModel):
8686
graph.add_edge(a, last)
8787
graph.add_edge(start, last)
8888

89-
graph.trim_first_node() # should not remove __start__ since it has 2 outgoing edges
89+
# trim_first_node() should not remove __start__ since it has 2 outgoing edges
90+
graph.trim_first_node()
9091
assert graph.first_node() is start
9192

92-
graph.trim_last_node() # should not remove the __end__ node since it has 2 incoming edges
93+
# trim_last_node() should not remove __end__ since it has 2 incoming edges
94+
graph.trim_last_node()
9395
assert graph.last_node() is last
9496

9597

libs/core/tests/unit_tests/runnables/test_runnable.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,7 +2785,12 @@ def test_seq_dict_prompt_llm(
27852785
response_metadata={},
27862786
),
27872787
HumanMessage(
2788-
content="Context:\n[Document(metadata={}, page_content='foo'), Document(metadata={}, page_content='bar')]\n\nQuestion:\nWhat is your name?",
2788+
content="Context:\n"
2789+
"[Document(metadata={}, page_content='foo'), "
2790+
"Document(metadata={}, page_content='bar')]\n"
2791+
"\n"
2792+
"Question:\n"
2793+
"What is your name?",
27892794
additional_kwargs={},
27902795
response_metadata={},
27912796
),
@@ -4140,7 +4145,8 @@ def _batch(
41404145
if value.startswith(self.fail_starts_with):
41414146
outputs.append(
41424147
ValueError(
4143-
f"ControlledExceptionRunnable({self.fail_starts_with}) fail for {value}"
4148+
f"ControlledExceptionRunnable({self.fail_starts_with}) "
4149+
f"fail for {value}"
41444150
)
41454151
)
41464152
else:
@@ -4280,7 +4286,8 @@ async def _abatch(
42804286
if value.startswith(self.fail_starts_with):
42814287
outputs.append(
42824288
ValueError(
4283-
f"ControlledExceptionRunnable({self.fail_starts_with}) fail for {value}"
4289+
f"ControlledExceptionRunnable({self.fail_starts_with}) "
4290+
f"fail for {value}"
42844291
)
42854292
)
42864293
else:
@@ -4931,7 +4938,8 @@ def gen(_: Iterator[Any]) -> Iterator[int]:
49314938

49324939
@pytest.mark.skipif(
49334940
sys.version_info < (3, 11),
4934-
reason="Python 3.10 and below don't support running async tasks in a specific context",
4941+
reason="Python 3.10 and below don't support running "
4942+
"async tasks in a specific context",
49354943
)
49364944
async def test_runnable_gen_context_config_async() -> None:
49374945
"""Test that a generator can call other runnables with config
@@ -5057,7 +5065,8 @@ def gen(value: str) -> Iterator[int]:
50575065

50585066
@pytest.mark.skipif(
50595067
sys.version_info < (3, 11),
5060-
reason="Python 3.10 and below don't support running async tasks in a specific context",
5068+
reason="Python 3.10 and below don't support running "
5069+
"async tasks in a specific context",
50615070
)
50625071
async def test_runnable_iter_context_config_async() -> None:
50635072
"""Test that a generator can call other runnables with config
@@ -5179,7 +5188,8 @@ def fun(value: str) -> int:
51795188

51805189
@pytest.mark.skipif(
51815190
sys.version_info < (3, 11),
5182-
reason="Python 3.10 and below don't support running async tasks in a specific context",
5191+
reason="Python 3.10 and below don't support running "
5192+
"async tasks in a specific context",
51835193
)
51845194
async def test_runnable_lambda_context_config_async() -> None:
51855195
"""Test that a function can call other runnables with config

0 commit comments

Comments
 (0)