Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-splitters: Bump ruff version to 0.9 #29231

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libs/text-splitters/langchain_text_splitters/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ def split_text(self, text: str) -> List[Document]:

if current_content:
lines_with_metadata.append(
{"content": "\n".join(current_content), "metadata": current_metadata}
{
"content": "\n".join(current_content),
"metadata": current_metadata,
}
)

# lines_with_metadata has each line with associated header metadata
Expand Down
40 changes: 20 additions & 20 deletions libs/text-splitters/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion libs/text-splitters/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ ignore_missing_imports = "True"
python = ">=3.9,<4.0"
langchain-core = "^0.3.29"

[tool.ruff]
target-version = "py39"

[tool.ruff.lint]
select = ["E", "F", "I", "T201", "D"]
ignore = ["D100"]
Expand Down Expand Up @@ -72,7 +75,8 @@ convention = "google"
"tests/**" = ["D"]

[tool.poetry.group.lint.dependencies]
ruff = "^0.5"
ruff = "^0.9.2"




Expand All @@ -84,12 +88,14 @@ tiktoken = "^0.8.0"




[tool.poetry.group.dev.dependencies]
jupyter = "^1.0.0"





[tool.poetry.group.test.dependencies]
pytest = "^8"
freezegun = "^1.2.2"
Expand All @@ -101,6 +107,7 @@ pytest-xdist = "^3.6.1"




[tool.poetry.group.test_integration]
optional = true

Expand All @@ -112,18 +119,21 @@ sentence-transformers = { version = ">=2.6.0", python = "<3.13" }




[tool.poetry.group.lint.dependencies.langchain-core]
path = "../core"
develop = true




[tool.poetry.group.dev.dependencies.langchain-core]
path = "../core"
develop = true




[tool.poetry.group.test.dependencies.langchain-core]
path = "../core"
develop = true
17 changes: 5 additions & 12 deletions libs/text-splitters/tests/unit_tests/test_text_splitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,12 +1229,7 @@ def test_md_header_text_splitter_fenced_code_block(fence: str) -> None:
"""Test markdown splitter by header: Fenced code block."""

markdown_document = (
"# This is a Header\n\n"
f"{fence}\n"
"foo()\n"
"# Not a header\n"
"bar()\n"
f"{fence}"
f"# This is a Header\n\n{fence}\nfoo()\n# Not a header\nbar()\n{fence}"
)

headers_to_split_on = [
Expand Down Expand Up @@ -1299,9 +1294,7 @@ def test_md_header_text_splitter_fenced_code_block_interleaved(
def test_md_header_text_splitter_with_invisible_characters(characters: str) -> None:
"""Test markdown splitter by header: Fenced code block."""

markdown_document = (
f"{characters}# Foo\n\n" "foo()\n" f"{characters}## Bar\n\n" "bar()"
)
markdown_document = f"{characters}# Foo\n\nfoo()\n{characters}## Bar\n\nbar()"

headers_to_split_on = [
("#", "Header 1"),
Expand Down Expand Up @@ -2041,9 +2034,9 @@ def test_haskell_code_splitter() -> None:

@pytest.fixture
@pytest.mark.requires("bs4")
def html_header_splitter_splitter_factory() -> (
Callable[[List[Tuple[str, str]]], HTMLHeaderTextSplitter]
):
def html_header_splitter_splitter_factory() -> Callable[
[List[Tuple[str, str]]], HTMLHeaderTextSplitter
]:
"""
Fixture to create an HTMLHeaderTextSplitter instance with given headers.
This factory allows dynamic creation of splitters with different headers.
Expand Down
Loading