Repository navigation
fix(graph): accept float props in add_node/add_edge and validate before writing (#358) - #360
Open
Chaithanya123123 wants to merge 1 commit into
Open
Chaithanya123123 wants to merge 1 commit into
Chaithanya123123 wants to merge 1 commit into
Conversation
…re writing (codeforstartups#358) add_node() and add_edge() now convert props the same way import_graph() does, so floats such as confidence scores are stored as Decimal instead of raising TypeError. add_edge() validates its weight and props before creating either endpoint, so a rejected edge no longer leaves orphan nodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Description
GraphStore.add_node()andGraphStore.add_edge()raisedTypeErrorfor float props such as a confidence score, whileimport_graph()stored the same props. They now convert props the same wayimport_graph()does, so floats are stored asDecimal.add_edge()also created both endpoint nodes before an invalid edge was rejected. It now validates the weight and props first, so a failed call writes nothing.Related issue
Fixes #358
Changes
add_node()andadd_edge()convert props with the existing_properties()helper used byimport_graph(). The caller's dict is not modified._edge_weight()helper, shared byadd_edge()andimport_graph(), rejects non-finite weights such asnanandinf.add_edge()builds and validates the edge before creating its endpoints.Testing
development.ruff check src benchmarks);mypypasses.Checklist
🤖 Generated with Claude Code