Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions libs/text-splitters/langchain_text_splitters/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ def _json_size(data: dict[str, Any]) -> int:
def _set_nested_dict(
d: dict[str, Any],
path: list[str],
value: Any,
value: Any, # noqa: ANN401
) -> None:
"""Set a value in a nested dictionary based on the given path."""
for key in path[:-1]:
d = d.setdefault(key, {})
d[path[-1]] = value

def _list_to_dict_preprocessing(self, data: Any) -> Any:
def _list_to_dict_preprocessing(
self,
data: Any, # noqa: ANN401
) -> Any: # noqa: ANN401
if isinstance(data, dict):
# Process each key-value pair in the dictionary
return {k: self._list_to_dict_preprocessing(v) for k, v in data.items()}
Expand All @@ -77,7 +80,7 @@ def _list_to_dict_preprocessing(self, data: Any) -> Any:

def _json_split(
self,
data: Any,
data: Any, # noqa: ANN401
current_path: list[str] | None = None,
chunks: list[dict[str, Any]] | None = None,
) -> list[dict[str, Any]]:
Expand Down
11 changes: 2 additions & 9 deletions libs/text-splitters/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,14 @@ docstring-code-format = true
[tool.ruff.lint]
select = [ "ALL",]
ignore = [
"ANN401", # Dynamically typed expressions (typing.Any)
"C90", # McCabe complexity
"C901", # Complexity
"COM812", # Messes with the formatter
"CPY", # No copyright
"FIX002", # Line contains TODO
"ISC001", # Messes with the formatter
"PERF203", # Rarely useful
"PLR2004", # Magic value used in comparison
"PLR0915", # Too many statements
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR09", # Too many something (arg, statements, etc)
"RUF012", # Doesn't play well with Pydantic
"S112", # Rarely useful
"TC001", # Doesn't play well with Pydantic
"TC002", # Doesn't play well with Pydantic
"TC003", # Doesn't play well with Pydantic
Expand All @@ -100,7 +94,6 @@ 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",]
pyupgrade.keep-runtime-typing = true

[tool.ruff.lint.pydocstyle]
convention = "google"
Expand Down
Loading