Skip to content

chore: drop redundant None default on dict.get() (ruff SIM910)#165

Open
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-sim910-drop-redundant-none-default
Open

chore: drop redundant None default on dict.get() (ruff SIM910)#165
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-sim910-drop-redundant-none-default

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 3, 2026

Summary

Ruff rule SIM910 flags d.get(key, None) where the explicit None default is redundant — dict.get() already returns None by default when the key is missing. The replacement is byte-identical. 2 occurrences, both auto-fixable.

-    edge_distances = node_distances.get("RelationType_relationship_name", None)
+    edge_distances = node_distances.get("RelationType_relationship_name")

Semantic equivalence

From the CPython dict.get() docs:

get(key[, default]) — Return the value for key if key is in the dictionary, else default. If default is not given, it defaults to None, so that this method never raises a KeyError.

d.get(k) and d.get(k, None) return identically in every case. No type-hint or call-site contract shifts.

Scope

2 files, 2 sites, +2 / −2.

File Sites
m_flow/retrieval/episodic/bundle_search.py 1
m_flow/retrieval/utils/fine_grained_triplet_search.py 1

Verification

$ uv run ruff check . --exclude 'm_flow/baml_client' --exclude 'm_flow-frontend' --select SIM910
All checks passed!

$ for f in $(git diff --name-only main); do uv run python -c "import ast; ast.parse(open('$f').read())"; done
# clean across both files

No behavior change. Generated code under m_flow/baml_client/ is untouched.

I affirm that all code in every commit of this pull request conforms to the terms of the M-flow Developer Certificate of Origin

Ruff rule SIM910 flags `d.get(key, None)` where the default is redundant —
`dict.get()` already returns `None` by default when the key is missing, so
dropping the explicit `None` is byte-identical.

Verification:
- `uv run ruff check ... --select SIM910` is now clean
- ast.parse on every touched file: clean

No behavior change.
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