chore: prefer iterable unpacking over list concatenation (ruff RUF005)#168
Open
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
Open
chore: prefer iterable unpacking over list concatenation (ruff RUF005)#168alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
adapters/graph/get_graph_adapter.pylist(d.keys()) + [...]→[*d.keys(), ...]adapters/vector/create_vector_engine.pydebug/__main__.py[sys.argv[0]] + sys.argv[2:]→[sys.argv[0], *sys.argv[2:]]memory/episodic/entity_description_merger.pyexisting_texts + [new_text]→[*existing_texts, new_text]tests/cli_tests/cli_unit_tests/test_cli_edge_cases.pytest_paths + ["--dataset-name", ...]→[*test_paths, ...]For the two adapter helpers I also removed a redundant
list(...)wrapper that ruff's autofix preserved —dict_keysviews unpack natively.Verification