2012-07-06 | Paul Boddie | raw annotate files changeset graph | Added module global modification/invalidation upon imports. Reverted the separate module processing phases introduced in 8824b42d7b71. Established a mechanism for modifying module globals, updating Attr assignment statistics and recording each name. Changed the update method on the Attr class to use a separate assignments update method, fixing the number of assignments recorded. Changed the get_context and get_value methods on the Attr class to test the number of assignments as well as the length of the list of recorded values. Changed one of the tests to more thoroughly demonstrate the effects of global modification on attribute usage and constant value identification. |
1 #!/usr/bin/env python 2 3 import imported 4 5 imported.attr = 456 # detected with warning 6 7 m = imported 8 imported.a = 9 # detected with warning 9 m.a = 8 # detected with warning (m is always imported) 10 11 imported.x = 1 # detected with warning (despite no collision) 12 13 class C: # hack: make an attribute called y known to the system 14 y = None # hack: this prevents compilation errors with the statements 15 # hack: below 16 17 n = None 18 n = imported 19 n.y = 2 # not detected due to reassignment of n 20 n.y = 3 # not detected due to reassignment of n 21 22 # vim: tabstop=4 expandtab shiftwidth=4