microsoft / gather

Spit shine for Jupyter notebooks 🧽✨
https://microsoft.github.io/gather
MIT License
532 stars 38 forks source link

Slicing: Fails to include import for symbol used in method #10

Closed andrewhead closed 5 years ago

andrewhead commented 5 years ago

Describe the bug

When a symbol is imported then used within a method, the import is not included even if the method is included in the slice. Originally reported by @barik.

To Reproduce

Here's an example of the part of a notebook where this bug occurs.

image

Expected behavior

import re should also be highlighted.

Desktop (please complete the following information):

andrewhead commented 5 years ago

Woohoo! It works as of https://github.com/Microsoft/gather/commit/980f711c3dff553ca4cbd90794d645f1abf1af28. The problem was that the name re was not getting discovered by the slicer's name detector, because of a bug in the AST traversal code.

andrewhead commented 5 years ago

The beautiful proof:

image