MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _python_attribute_is_store

Function _python_attribute_is_store

graphify/extractors/engine.py:4035–4045  ·  view source on GitHub ↗

`x.a = ...`, `for x.a in ...`, `del x.a`: not a read of `a`. `x.a += ...` is: it reads `a` (the getter runs) before it writes it.

(node)

Source from the content-addressed store, hash-verified

4033
4034
4035def _python_attribute_is_store(node) -> bool:
4036 """`x.a = ...`, `for x.a in ...`, `del x.a`: not a read of `a`. `x.a += ...`
4037 is: it reads `a` (the getter runs) before it writes it."""
4038 child, parent = node, node.parent
4039 while parent is not None and parent.type in ("pattern_list", "tuple_pattern", "list_pattern"):
4040 child, parent = parent, parent.parent
4041 if parent is None:
4042 return False
4043 if parent.type in ("assignment", "for_statement", "for_in_clause"):
4044 return _same_node(parent.child_by_field_name("left"), child)
4045 return parent.type == "delete_statement"
4046
4047
4048def _python_property_reads(

Callers 1

_python_property_readsFunction · 0.85

Calls 1

_same_nodeFunction · 0.85

Tested by

no test coverage detected