Skip to content

Commit 4b082b4

Browse files
Maffoochclaude
andcommitted
style(locations): lint-clean the unset-context filter
Replace the crash-prone set-membership filter with a truthiness dict comprehension: never hashes the value (crash-robust for any parser input), and satisfies the repo's ruff rules (no manual loop, no != "" comparison). Drops None/""/0/empty — all "no data" for the code location's context fields. Same fix, lint-clean form. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent dc08c80 commit 4b082b4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

dojo/tools/locations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ def code(
6868
"source_file_path": source_file_path,
6969
"source_line": source_line,
7070
}
71-
# Tuple (not set) membership: uses == rather than hashing, so an unset
72-
# check never crashes on an unhashable value a parser might pass.
73-
data.update({key: value for key, value in context.items() if value not in ("", None)})
71+
# Truthiness filter (not set membership): never hashes `value`, so the
72+
# unset check can't crash on an unhashable value a parser might pass.
73+
# Drops None/""/0/empty — all "no data" for these context fields.
74+
data.update({key: value for key, value in context.items() if value})
7475
return cls(type="code", data=data)
7576

7677
@classmethod

0 commit comments

Comments
 (0)