Skip to content

chore: prefer iterable unpacking over list concatenation (ruff RUF005)#168

Open
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/iterable-unpack-and-list-set-fixes
Open

chore: prefer iterable unpacking over list concatenation (ruff RUF005)#168
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/iterable-unpack-and-list-set-fixes

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 8, 2026

5 ruff RUF005 fixes — a + [b, c] / [a] + b[*a, b, c] / [a, *b].

Unpacking form builds the result directly instead of creating an intermediate list and concatenating, and is the canonical idiom on Python 3.5+.

Changes

File Pattern
adapters/graph/get_graph_adapter.py list(d.keys()) + [...][*d.keys(), ...]
adapters/vector/create_vector_engine.py same
debug/__main__.py [sys.argv[0]] + sys.argv[2:][sys.argv[0], *sys.argv[2:]]
memory/episodic/entity_description_merger.py existing_texts + [new_text][*existing_texts, new_text]
tests/cli_tests/cli_unit_tests/test_cli_edge_cases.py test_paths + ["--dataset-name", ...][*test_paths, ...]

For the two adapter helpers I also removed a redundant list(...) wrapper that ruff's autofix preserved — dict_keys views unpack natively.

Verification

ruff check <touched files> --select RUF005   # clean
python -m py_compile <touched files>          # clean

`a + [b, c]` and `[a] + b` create two intermediate lists; the unpacking
form builds the result directly and is the idiomatic style on Python
3.5+.

Replacements (5 total):
- m_flow/adapters/graph/get_graph_adapter.py
- m_flow/adapters/vector/create_vector_engine.py
- m_flow/debug/__main__.py
- m_flow/memory/episodic/entity_description_merger.py
- m_flow/tests/cli_tests/cli_unit_tests/test_cli_edge_cases.py

For the two adapter helpers I also dropped a redundant `list(` wrapper
introduced by ruff's autofix — the dict_keys view is unpackable
directly.

Verification:
  ruff check --select RUF005 on touched files: clean
  py_compile on all touched files: clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant