PY-21175 Add write instructions for assignments to attributes in CFG

to handle, in particular, lazy initialization scenarios

For instance, the statement "foo.bar = 42" should add a node
"WRITE ACCESS foo.bar" containing the corresponding target expression.

Additionally, "Unused local" inspection doesn't consider writes to
attributes, since, strictly speaking, these are not local names.
This commit is contained in:
Mikhail Golubev
2017-07-24 14:38:41 +03:00
parent 58f32e7a70
commit 247e0aeeb1
6 changed files with 37 additions and 21 deletions
@@ -2,5 +2,6 @@
1(2) WRITE ACCESS: self
2(3) WRITE ACCESS: args
3(4) element: PyAssignmentStatement
4(5) READ ACCESS: self
5() element: null
4(5) WRITE ACCESS: self.args
5(6) READ ACCESS: self
6() element: null
@@ -1,7 +1,8 @@
0(1) element: null
1(2) WRITE ACCESS: self
2(3) element: PyAssignmentStatement
3(4) READ ACCESS: self
4(5) element: PyPrintStatement
5(6) READ ACCESS: self
6() element: null
3(4) WRITE ACCESS: self.foo
4(5) READ ACCESS: self
5(6) element: PyPrintStatement
6(7) READ ACCESS: self
7() element: null