mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-04 18:53:02 +00:00
core: Add ruff rules TD and FIX (#30654)
Add ruff rules: * FIX: https://docs.astral.sh/ruff/rules/#flake8-fixme-fix * TD: https://docs.astral.sh/ruff/rules/#flake8-todos-td Code cleanup: * [`libs/core/langchain_core/outputs/chat_generation.py`](diffhunk://#diff-a1017ee46f58fa4005b110ffd4f8e1fb08f6a2a11d6ca4c78ff8be641cbb89e5L56-R56): Removed the "HACK" prefix from a comment in the `set_text` method. Configuration adjustments: * [`libs/core/pyproject.toml`](diffhunk://#diff-06baaee12b22a370fef9f170c9ed13e2727e377d3b32f5018430f4f0a39d3537R85-R93): Added new rules `FIX002`, `TD002`, and `TD003` to the ignore list. * [`libs/core/pyproject.toml`](diffhunk://#diff-06baaee12b22a370fef9f170c9ed13e2727e377d3b32f5018430f4f0a39d3537L102-L108): Removed the `FIX` and `TD` rules from the ignore list. Test refinement: * [`libs/core/tests/unit_tests/runnables/test_runnable.py`](diffhunk://#diff-06bed920c0dad0cfd41d57a8d9e47a7b56832409649c10151061a791860d5bb5L3231-R3232): Updated a TODO comment to improve clarity in the `test_map_stream` function.
This commit is contained in:
parent
a007c57285
commit
43b5dc7191
@ -53,7 +53,7 @@ class ChatGeneration(Generation):
|
||||
text = ""
|
||||
if isinstance(self.message.content, str):
|
||||
text = self.message.content
|
||||
# HACK: Assumes text in content blocks in OpenAI format.
|
||||
# Assumes text in content blocks in OpenAI format.
|
||||
# Uses first text block.
|
||||
elif isinstance(self.message.content, list):
|
||||
for block in self.message.content:
|
||||
|
@ -82,12 +82,15 @@ ignore = [
|
||||
"C90", # McCabe complexity
|
||||
"COM812", # Messes with the formatter
|
||||
"FA100", # Can't activate since we exclude UP007 for now
|
||||
"FIX002", # Line contains TODO
|
||||
"ISC001", # Messes with the formatter
|
||||
"PERF203", # Rarely useful
|
||||
"PLR09", # Too many something (arg, statements, etc)
|
||||
"TC001", # Doesn't play well with Pydantic
|
||||
"TC002", # Doesn't play well with Pydantic
|
||||
"TC003", # Doesn't play well with Pydantic
|
||||
"TD002", # Missing author in TODO
|
||||
"TD003", # Missing issue link in TODO
|
||||
"UP007", # Doesn't play well with Pydantic in Python 3.9
|
||||
|
||||
# TODO rules
|
||||
@ -99,13 +102,11 @@ ignore = [
|
||||
"DTZ",
|
||||
"FBT001",
|
||||
"FBT002",
|
||||
"FIX",
|
||||
"PGH",
|
||||
"PLR",
|
||||
"PYI",
|
||||
"RUF",
|
||||
"SLF",
|
||||
"TD",
|
||||
]
|
||||
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
|
||||
|
@ -3228,7 +3228,8 @@ def test_map_stream() -> None:
|
||||
{"llm": "i"},
|
||||
{"chat": _any_id_ai_message_chunk(content="i")},
|
||||
]
|
||||
if not ( # TODO(Rewrite properly) statement above
|
||||
if not (
|
||||
# TODO: Rewrite properly the statement above
|
||||
streamed_chunks[0] == {"llm": "i"}
|
||||
or {"chat": _any_id_ai_message_chunk(content="i")}
|
||||
):
|
||||
|
Loading…
Reference in New Issue
Block a user