google / pasta

Library to refactor python code through AST manipulation.
Apache License 2.0
341 stars 40 forks source link

Add the ability to lookup scopes created under the root scope #34

Closed soupytwist closed 6 years ago

soupytwist commented 6 years ago

This will make it possible to do things like find out what arguments to a function are unused, and should help with determining whether non-top-level imports are used.

soupytwist commented 6 years ago

@akov I think I misunderstood your concern-- calling root_scope.create_scope(parent_scope, node) is a bit awkward, the new scope is indeed being created under the parent_scope given, but the scope -> Node association needs to be stored at the root. Being as any scope can find the root though, it makes sense to change to parent_scope.create_scope(node) to make the hierarchy clear.

Thanks for your input!